BT20_028.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_028 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("MetalSeadramon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 2,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null)
  24. );
  25. }
  26. #endregion
  27. #region Security Attack
  28. if (timing == EffectTiming.None)
  29. {
  30. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  31. }
  32. #endregion
  33. #region Reboot
  34. if (timing == EffectTiming.None)
  35. {
  36. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  37. }
  38. #endregion
  39. #region Blocker
  40. if (timing == EffectTiming.None)
  41. {
  42. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  43. }
  44. #endregion
  45. #region When Digivolving
  46. if (timing == EffectTiming.OnEnterFieldAnyone)
  47. {
  48. ActivateClass activateClass = new ActivateClass();
  49. activateClass.SetUpICardEffect("Play 1 Digimon from this Digimon's digivolution cards", CanUseCondition, card);
  50. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  51. activateClass.SetHashString("PlayDigimon_BT20_028");
  52. cardEffects.Add(activateClass);
  53. string EffectDescription()
  54. {
  55. return "[When Digivolving][Once Per Turn] From the digivolution cards of this Digimon with [MetalSeadramon]/[X Antibody] in its digivolution cards, you may play 1 level 5 or lower Digimon card without paying the cost.";
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  60. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  61. return false;
  62. }
  63. bool CanSelectSourceCardCondition(CardSource cardSource)
  64. {
  65. return cardSource.IsDigimon &&
  66. cardSource.HasLevel && cardSource.Level <= 5 &&
  67. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  68. }
  69. bool CanActivateCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  72. && card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition)
  73. && card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.EqualsCardName("MetalSeadramon") || cardSource.EqualsCardName("X Antibody")) >= 1;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable hashtable)
  76. {
  77. List<CardSource> selectedCards = new List<CardSource>();
  78. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  79. selectCardEffect.SetUp(
  80. canTargetCondition: CanSelectSourceCardCondition,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. canNoSelect: () => true,
  84. selectCardCoroutine: SelectCardCoroutine,
  85. afterSelectCardCoroutine: null,
  86. message: "Select 1 digivolution card to play.",
  87. maxCount: 1,
  88. canEndNotMax: false,
  89. isShowOpponent: true,
  90. mode: SelectCardEffect.Mode.Custom,
  91. root: SelectCardEffect.Root.Custom,
  92. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  93. canLookReverseCard: true,
  94. selectPlayer: card.Owner,
  95. cardEffect: activateClass);
  96. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  97. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  98. yield return StartCoroutine(selectCardEffect.Activate());
  99. IEnumerator SelectCardCoroutine(CardSource cardSource)
  100. {
  101. selectedCards.Add(cardSource);
  102. yield return null;
  103. }
  104. yield return ContinuousController.instance.StartCoroutine(
  105. CardEffectCommons.PlayPermanentCards(
  106. cardSources: selectedCards,
  107. activateClass: activateClass,
  108. payCost: false,
  109. isTapped: false,
  110. root: SelectCardEffect.Root.DigivolutionCards,
  111. activateETB: true));
  112. }
  113. }
  114. #endregion
  115. #region When Attacking
  116. if (timing == EffectTiming.OnAllyAttack)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect("Play 1 Digimon from this Digimon's digivolution cards", CanUseCondition, card);
  120. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  121. activateClass.SetHashString("PlayDigimon_BT20_028");
  122. cardEffects.Add(activateClass);
  123. string EffectDescription()
  124. {
  125. return "[When Attacking][Once Per Turn] From the digivolution cards of this Digimon with [MetalSeadramon]/[X Antibody] in its digivolution cards, you may play 1 level 5 or lower Digimon card without paying the cost.";
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  130. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  131. return false;
  132. }
  133. bool CanSelectSourceCardCondition(CardSource cardSource)
  134. {
  135. return cardSource.IsDigimon &&
  136. cardSource.HasLevel && cardSource.Level <= 5 &&
  137. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  138. }
  139. bool CanActivateCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  142. && card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition)
  143. && card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.EqualsCardName("MetalSeadramon") || cardSource.EqualsCardName("X Antibody")) >= 1;
  144. }
  145. IEnumerator ActivateCoroutine(Hashtable hashtable)
  146. {
  147. List<CardSource> selectedCards = new List<CardSource>();
  148. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  149. selectCardEffect.SetUp(
  150. canTargetCondition: CanSelectSourceCardCondition,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. canNoSelect: () => true,
  154. selectCardCoroutine: SelectCardCoroutine,
  155. afterSelectCardCoroutine: null,
  156. message: "Select 1 digivolution card to play.",
  157. maxCount: 1,
  158. canEndNotMax: false,
  159. isShowOpponent: true,
  160. mode: SelectCardEffect.Mode.Custom,
  161. root: SelectCardEffect.Root.Custom,
  162. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  163. canLookReverseCard: true,
  164. selectPlayer: card.Owner,
  165. cardEffect: activateClass);
  166. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  167. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  168. yield return StartCoroutine(selectCardEffect.Activate());
  169. IEnumerator SelectCardCoroutine(CardSource cardSource)
  170. {
  171. selectedCards.Add(cardSource);
  172. yield return null;
  173. }
  174. yield return ContinuousController.instance.StartCoroutine(
  175. CardEffectCommons.PlayPermanentCards(
  176. cardSources: selectedCards,
  177. activateClass: activateClass,
  178. payCost: false,
  179. isTapped: false,
  180. root: SelectCardEffect.Root.DigivolutionCards,
  181. activateETB: true));
  182. }
  183. }
  184. #endregion
  185. #region All Turns
  186. if (timing == EffectTiming.OnEnterFieldAnyone)
  187. {
  188. ActivateClass activateClass = new ActivateClass();
  189. activateClass.SetUpICardEffect("<De-Digivolve 2> 1 of your opponent's Digimon", CanUseCondition, card);
  190. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  191. activateClass.SetHashString("DeDigivolve_BT20_028");
  192. cardEffects.Add(activateClass);
  193. string EffectDescription()
  194. {
  195. return "[All Turns][Once Per Turn] When any of your Digimon are played from digivolution cards, <De-Digivolve 2> 1 of your opponent's Digimon.";
  196. }
  197. bool PermanentCondition(Permanent permanent)
  198. {
  199. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  200. }
  201. bool CanSelectDeDigiPermanentCondition(Permanent permanent)
  202. {
  203. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  204. }
  205. bool CanUseCondition(Hashtable hashtable)
  206. {
  207. if(CardEffectCommons.IsExistOnBattleArea(card))
  208. {
  209. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  210. {
  211. return CardEffectCommons.IsFromDigimonDigivolutionCards(hashtable);
  212. }
  213. }
  214. return false;
  215. }
  216. bool CanSelectPermanentCondition(Permanent permanent)
  217. {
  218. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  219. }
  220. bool CanActivateCondition(Hashtable hashtable)
  221. {
  222. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  223. {
  224. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  225. {
  226. if(CardEffectCommons.IsFromDigimonDigivolutionCards(hashtable))
  227. {
  228. return CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  229. }
  230. }
  231. }
  232. return false;
  233. }
  234. IEnumerator ActivateCoroutine(Hashtable hashtable)
  235. {
  236. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  237. selectPermanentEffect.SetUp(
  238. selectPlayer: card.Owner,
  239. canTargetCondition: CanSelectDeDigiPermanentCondition,
  240. canTargetCondition_ByPreSelecetedList: null,
  241. canEndSelectCondition: null,
  242. maxCount: 1,
  243. canNoSelect: false,
  244. canEndNotMax: false,
  245. selectPermanentCoroutine: SelectPermanentCoroutine,
  246. afterSelectPermanentCoroutine: null,
  247. mode: SelectPermanentEffect.Mode.Custom,
  248. cardEffect: activateClass);
  249. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  250. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  251. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  252. {
  253. yield return ContinuousController.instance.StartCoroutine(
  254. new IDegeneration(permanent, 2, activateClass).Degeneration());
  255. }
  256. }
  257. }
  258. #endregion
  259. return cardEffects;
  260. }
  261. }
  262. }