BT14_102.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_102 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardNames.Contains("Patamon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 2,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null));
  24. }
  25. if (timing == EffectTiming.OnAllyAttack)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Delete this Digimon to select effects", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  30. cardEffects.Add(activateClass);
  31. string EffectDiscription()
  32. {
  33. return "[When Attacking] By deleting this Digimon, activate 1 of the effects below: - Place 1 of your opponent's Digimon with the [Virus] trait at the bottom of their security stack. - 1 of your opponent's Digimon gets -5000 DP for the turn.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. return true;
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  48. {
  49. bool deleted = false;
  50. if (CardEffectCommons.IsExistOnBattleArea(card))
  51. {
  52. Permanent permanent = card.PermanentOfThisCard();
  53. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  54. targetPermanents: new List<Permanent>() { permanent },
  55. activateClass: activateClass,
  56. successProcess: permanents => SuccessProcess(),
  57. failureProcess: null));
  58. IEnumerator SuccessProcess()
  59. {
  60. deleted = true;
  61. yield return null;
  62. }
  63. }
  64. if (deleted)
  65. {
  66. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  67. {
  68. new SelectionElement<int>(message: $"Place 1 Digimon with the [Virus] trait at the bottom of security", value : 0, spriteIndex: 0),
  69. new SelectionElement<int>(message: $"DP -5000", value : 1, spriteIndex: 0),
  70. };
  71. string selectPlayerMessage = "Which effect will you activate?";
  72. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  73. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  74. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  75. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  76. switch (actionID)
  77. {
  78. case 0:
  79. {
  80. bool CanSelectPermanentCondition(Permanent permanent)
  81. {
  82. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  83. {
  84. if (permanent.TopCard.CardTraits.Contains("Virus"))
  85. {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  92. {
  93. int maxCount = 1;
  94. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  95. selectPermanentEffect.SetUp(
  96. selectPlayer: card.Owner,
  97. canTargetCondition: CanSelectPermanentCondition,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: maxCount,
  101. canNoSelect: false,
  102. canEndNotMax: false,
  103. selectPermanentCoroutine: SelectPermanentCoroutine,
  104. afterSelectPermanentCoroutine: null,
  105. mode: SelectPermanentEffect.Mode.Custom,
  106. cardEffect: activateClass);
  107. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place to security.", "The opponent is selecting 1 Digimon to place to security.");
  108. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  109. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  110. {
  111. Permanent selectedPermanent = permanent;
  112. if (selectedPermanent != null)
  113. {
  114. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(selectedPermanent, CardEffectCommons.CardEffectHashtable(activateClass), toTop: false).PutSecurity());
  115. }
  116. }
  117. }
  118. }
  119. break;
  120. case 1:
  121. {
  122. bool CanSelectPermanentCondition(Permanent permanent)
  123. {
  124. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  125. }
  126. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  127. {
  128. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  129. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  130. selectPermanentEffect.SetUp(
  131. selectPlayer: card.Owner,
  132. canTargetCondition: CanSelectPermanentCondition,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. maxCount: maxCount,
  136. canNoSelect: false,
  137. canEndNotMax: false,
  138. selectPermanentCoroutine: SelectPermanentCoroutine,
  139. afterSelectPermanentCoroutine: null,
  140. mode: SelectPermanentEffect.Mode.Custom,
  141. cardEffect: activateClass);
  142. selectPermanentEffect.SetUpCustomMessage(customMessageArray: CardEffectCommons.customPermanentMessageArray_ChangeDP(changeValue: -5000, maxCount: maxCount));
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  145. {
  146. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  147. targetPermanent: permanent,
  148. changeValue: -5000,
  149. effectDuration: EffectDuration.UntilEachTurnEnd,
  150. activateClass: activateClass));
  151. }
  152. }
  153. }
  154. break;
  155. }
  156. }
  157. }
  158. }
  159. if (timing == EffectTiming.OnDestroyedAnyone)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("Place this card at the bottom of security and hatch", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  164. cardEffects.Add(activateClass);
  165. string EffectDiscription()
  166. {
  167. return "[On Deletion] Place this card at the bottom of your security stack. Then, if you have a Tamer, you may hatch in your breeding area.";
  168. }
  169. bool CanUseCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  172. }
  173. bool CanActivateCondition(Hashtable hashtable)
  174. {
  175. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  176. {
  177. if (card.Owner.CanAddSecurity(activateClass))
  178. {
  179. return true;
  180. }
  181. }
  182. return false;
  183. }
  184. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  185. {
  186. if (CardEffectCommons.IsExistOnTrash(card))
  187. {
  188. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false));
  189. }
  190. if (card.Owner.GetBattleAreaPermanents().Some(permanent => permanent.IsTamer))
  191. {
  192. yield return ContinuousController.instance.StartCoroutine(new HatchDigiEggClass(player: card.Owner, hashtable: CardEffectCommons.CardEffectHashtable(activateClass)).Hatch());
  193. }
  194. }
  195. }
  196. if (timing == EffectTiming.OnDestroyedAnyone)
  197. {
  198. ActivateClass activateClass = new ActivateClass();
  199. activateClass.SetUpICardEffect("Place 1 card from hand at the bottom security", CanUseCondition, card);
  200. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  201. activateClass.SetIsInheritedEffect(true);
  202. cardEffects.Add(activateClass);
  203. string EffectDiscription()
  204. {
  205. return "[On Deletion] Place 1 yellow card with the [Vaccine] trait from your hand at the bottom of your security stack. ";
  206. }
  207. bool CanSelectCardCondition1(CardSource cardSource)
  208. {
  209. if (cardSource.CardTraits.Contains("Vaccine"))
  210. {
  211. if (cardSource.HasCardColor(CardColor.Yellow))
  212. {
  213. return true;
  214. }
  215. }
  216. return false;
  217. }
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  221. }
  222. bool CanActivateCondition(Hashtable hashtable)
  223. {
  224. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  225. {
  226. if (card.Owner.HandCards.Count >= 1)
  227. {
  228. if (card.Owner.CanAddSecurity(activateClass))
  229. {
  230. return true;
  231. }
  232. }
  233. }
  234. return false;
  235. }
  236. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  237. {
  238. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  239. {
  240. List<CardSource> selectedCards = new List<CardSource>();
  241. int maxCount = 1;
  242. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  243. selectHandEffect.SetUp(
  244. selectPlayer: card.Owner,
  245. canTargetCondition: CanSelectCardCondition1,
  246. canTargetCondition_ByPreSelecetedList: null,
  247. canEndSelectCondition: null,
  248. maxCount: maxCount,
  249. canNoSelect: true,
  250. canEndNotMax: false,
  251. isShowOpponent: true,
  252. selectCardCoroutine: SelectCardCoroutine1,
  253. afterSelectCardCoroutine: null,
  254. mode: SelectHandEffect.Mode.Custom,
  255. cardEffect: activateClass);
  256. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the bottom of security.", "The opponent is selecting 1 card to place at the bottom of security.");
  257. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  258. yield return StartCoroutine(selectHandEffect.Activate());
  259. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  260. {
  261. selectedCards.Add(cardSource);
  262. yield return null;
  263. }
  264. foreach (CardSource cardSource in selectedCards)
  265. {
  266. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: false));
  267. }
  268. }
  269. }
  270. }
  271. return cardEffects;
  272. }
  273. }
  274. }