BT19_026.cs 17 KB

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