BT19_031.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Starmons
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_031 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 2 &&
  18. targetPermanent.TopCard.EqualsTraits("Xros Heart");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  21. digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Decoy
  25. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  26. {
  27. bool CanSelectPermanentCondition(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  30. {
  31. if (permanent != card.PermanentOfThisCard())
  32. {
  33. if (permanent.willBeRemoveField)
  34. {
  35. if (permanent.TopCard.EqualsTraits("Xros Heart"))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. string EffectDescription()
  45. {
  46. return "<Decoy (Xros Heart)>";
  47. }
  48. cardEffects.Add(CardEffectFactory.DecoySelfEffect(
  49. isInheritedEffect: false,
  50. card: card,
  51. condition: null,
  52. permanentCondition: CanSelectPermanentCondition,
  53. effectName: "Decoy (Xros Heart)",
  54. effectDiscription: EffectDescription()));
  55. }
  56. #endregion
  57. #region On Deletion
  58. if (timing == EffectTiming.OnDestroyedAnyone)
  59. {
  60. ActivateClass activateClass = new ActivateClass();
  61. activateClass.SetUpICardEffect("Play [ShootingStarmon] from under your Tamers", CanUseCondition, card);
  62. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  63. cardEffects.Add(activateClass);
  64. string EffectDescription()
  65. {
  66. return
  67. "[On Deletion] You may play 1 [ShootingStarmon] from under your Tamers without paying the cost. Then, place 1 [Starmons] and 1 [Pickmons] from your trash as that Digimon's bottom digivolution cards.";
  68. }
  69. bool CanUseCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  72. }
  73. bool PlayCardCondition(CardSource cardSource)
  74. {
  75. return cardSource.IsDigimon && cardSource.EqualsCardName("ShootingStarmon") &&
  76. CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.DigivolutionCards);
  77. }
  78. bool TamerHasDigimonCondition(Permanent permanent)
  79. {
  80. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  81. permanent.IsTamer && permanent.DigivolutionCards.Count(PlayCardCondition) >= 1;
  82. }
  83. bool IsStarmonsCardCondition(CardSource cardSource)
  84. {
  85. return cardSource.IsDigimon && cardSource.EqualsCardName("Starmons");
  86. }
  87. bool IsPickmonsCardCondition(CardSource cardSource)
  88. {
  89. return cardSource.IsDigiEgg && cardSource.EqualsCardName("Pickmons");
  90. }
  91. bool CanActivateCondition(Hashtable hashtable)
  92. {
  93. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  94. CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimonCondition);
  95. }
  96. IEnumerator ActivateCoroutine(Hashtable hashtable)
  97. {
  98. bool played = false;
  99. Permanent selectedTamer = null;
  100. List<CardSource> selectedCards = new List<CardSource>();
  101. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  102. selectPermanentEffect.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: TamerHasDigimonCondition,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. maxCount: 1,
  108. canNoSelect: true,
  109. canEndNotMax: false,
  110. selectPermanentCoroutine: SelectPermanentCoroutine,
  111. afterSelectPermanentCoroutine: null,
  112. mode: SelectPermanentEffect.Mode.Custom,
  113. cardEffect: activateClass);
  114. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  115. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  116. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  117. {
  118. selectedTamer = permanent;
  119. yield return null;
  120. }
  121. if (selectedTamer != null)
  122. {
  123. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  124. selectCardEffect.SetUp(
  125. canTargetCondition: PlayCardCondition,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. canNoSelect: () => true,
  129. selectCardCoroutine: SelectCardCoroutine,
  130. afterSelectCardCoroutine: null,
  131. message: "Select 1 digivolution card to play.",
  132. maxCount: 1,
  133. canEndNotMax: false,
  134. isShowOpponent: true,
  135. mode: SelectCardEffect.Mode.Custom,
  136. root: SelectCardEffect.Root.Custom,
  137. customRootCardList: selectedTamer.DigivolutionCards,
  138. canLookReverseCard: true,
  139. selectPlayer: card.Owner,
  140. cardEffect: activateClass);
  141. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.",
  142. "The opponent is selecting 1 digivolution card to play.");
  143. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  144. yield return StartCoroutine(selectCardEffect.Activate());
  145. IEnumerator SelectCardCoroutine(CardSource cardSource)
  146. {
  147. selectedCards.Add(cardSource);
  148. played = true;
  149. yield return null;
  150. }
  151. if(selectedCards.Count > 0)
  152. {
  153. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  154. cardSources: selectedCards,
  155. activateClass: activateClass,
  156. payCost: false,
  157. isTapped: false,
  158. root: SelectCardEffect.Root.DigivolutionCards,
  159. activateETB: true));
  160. played = true;
  161. }
  162. }
  163. if (played)
  164. {
  165. List<Permanent> playedPermanent = selectedCards.Map(source => source.PermanentOfThisCard());
  166. List<CardSource> selectedSourceCards = new List<CardSource>();
  167. IEnumerator SelectCardCoroutine(CardSource cardSource)
  168. {
  169. selectedSourceCards.Add(cardSource);
  170. yield return null;
  171. }
  172. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  173. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsStarmonsCardCondition))
  174. {
  175. selectCardEffect.SetUp(
  176. canTargetCondition: IsStarmonsCardCondition,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. canNoSelect: () => true,
  180. selectCardCoroutine: SelectCardCoroutine,
  181. afterSelectCardCoroutine: null,
  182. message: "Select 1 [Starmons] to place on bottom of digivolution cards.",
  183. maxCount: 1,
  184. canEndNotMax: true,
  185. isShowOpponent: true,
  186. mode: SelectCardEffect.Mode.Custom,
  187. root: SelectCardEffect.Root.Trash,
  188. customRootCardList: null,
  189. canLookReverseCard: true,
  190. selectPlayer: card.Owner,
  191. cardEffect: activateClass);
  192. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  193. selectCardEffect.SetUpCustomMessage("Select 1 [Starmons] to place on bottom of digivolution cards.",
  194. "The opponent is selecting 1 [Starmons] to place on bottom of digivolution cards.");
  195. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  196. }
  197. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsPickmonsCardCondition))
  198. {
  199. selectCardEffect.SetUp(
  200. canTargetCondition: IsPickmonsCardCondition,
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. canNoSelect: () => true,
  204. selectCardCoroutine: SelectCardCoroutine,
  205. afterSelectCardCoroutine: null,
  206. message: "Select 1 [Pickmons] to place on bottom of digivolution cards.",
  207. maxCount: 1,
  208. canEndNotMax: true,
  209. isShowOpponent: true,
  210. mode: SelectCardEffect.Mode.Custom,
  211. root: SelectCardEffect.Root.Trash,
  212. customRootCardList: null,
  213. canLookReverseCard: true,
  214. selectPlayer: card.Owner,
  215. cardEffect: activateClass);
  216. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  217. selectCardEffect.SetUpCustomMessage("Select 1 [Pickmons] to place on bottom of digivolution cards.",
  218. "The opponent is selecting 1 [Pickmons] to place on bottom of digivolution cards.");
  219. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  220. }
  221. yield return ContinuousController.instance.StartCoroutine(playedPermanent[0]
  222. .AddDigivolutionCardsBottom(selectedSourceCards, activateClass));
  223. }
  224. }
  225. }
  226. #endregion
  227. #region When Attacking - ESS
  228. if (timing == EffectTiming.OnAllyAttack)
  229. {
  230. ActivateClass activateClass = new ActivateClass();
  231. activateClass.SetUpICardEffect("DP -2000 if this Digimon has [Xros Heart] trait", CanUseCondition, card);
  232. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  233. activateClass.SetIsInheritedEffect(true);
  234. cardEffects.Add(activateClass);
  235. string EffectDescription()
  236. {
  237. return
  238. "[When Attacking] If this Digimon has the [Xros Heart] trait, 1 of your opponent's Digimon gets -2000 DP for the turn.";
  239. }
  240. bool CanUseCondition(Hashtable hashtable)
  241. {
  242. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  243. }
  244. bool CanSelectPermanentCondition(Permanent permanent)
  245. {
  246. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  247. }
  248. bool CanActivateCondition(Hashtable hashtable)
  249. {
  250. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  251. card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart");
  252. }
  253. IEnumerator ActivateCoroutine(Hashtable hashtable)
  254. {
  255. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  256. {
  257. Permanent selectedPermanent = null;
  258. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  259. selectPermanentEffect.SetUp(
  260. selectPlayer: card.Owner,
  261. canTargetCondition: CanSelectPermanentCondition,
  262. canTargetCondition_ByPreSelecetedList: null,
  263. canEndSelectCondition: null,
  264. maxCount: 1,
  265. canNoSelect: false,
  266. canEndNotMax: false,
  267. selectPermanentCoroutine: SelectPermanentCoroutine,
  268. afterSelectPermanentCoroutine: null,
  269. mode: SelectPermanentEffect.Mode.Custom,
  270. cardEffect: activateClass);
  271. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -2000.",
  272. "The opponent is selecting 1 Digimon that will get DP -2000.");
  273. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  274. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  275. {
  276. selectedPermanent = permanent;
  277. yield return null;
  278. }
  279. if (selectedPermanent != null)
  280. {
  281. yield return ContinuousController.instance.StartCoroutine(
  282. CardEffectCommons.ChangeDigimonDP(targetPermanent: selectedPermanent, changeValue: -2000,
  283. effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  284. }
  285. }
  286. }
  287. }
  288. #endregion
  289. return cardEffects;
  290. }
  291. }
  292. }