EX2_057.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_057 : 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. ChangeCostClass changeCostClass = new ChangeCostClass();
  15. changeCostClass.SetUpICardEffect($"Play Cost of [MarineAngemon] reduces by 1", CanUseCondition, card);
  16. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  17. cardEffects.Add(changeCostClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. if (CardEffectCommons.IsExistOnBattleArea(card))
  21. {
  22. if (CardEffectCommons.IsOwnerTurn(card))
  23. {
  24. return true;
  25. }
  26. }
  27. return false;
  28. }
  29. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  30. {
  31. if (CardSourceCondition(cardSource))
  32. {
  33. if (RootCondition(root))
  34. {
  35. if (PermanentsCondition(targetPermanents))
  36. {
  37. Cost -= 1;
  38. }
  39. }
  40. }
  41. return Cost;
  42. }
  43. bool PermanentsCondition(List<Permanent> targetPermanents)
  44. {
  45. if (targetPermanents == null)
  46. {
  47. return true;
  48. }
  49. else
  50. {
  51. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. bool CardSourceCondition(CardSource cardSource)
  59. {
  60. if (cardSource.Owner.HandCards.Contains(cardSource))
  61. {
  62. if (cardSource.Owner == card.Owner)
  63. {
  64. if (cardSource.CardNames.Contains("MarineAngemon"))
  65. {
  66. return true;
  67. }
  68. }
  69. }
  70. return false;
  71. }
  72. bool RootCondition(SelectCardEffect.Root root)
  73. {
  74. return root == SelectCardEffect.Root.Hand;
  75. }
  76. bool isUpDown()
  77. {
  78. return true;
  79. }
  80. }
  81. if (timing == EffectTiming.OnEnterFieldAnyone)
  82. {
  83. ExtendActivateClass activateClass = new ExtendActivateClass(false);
  84. activateClass.SetUpICardEffect("Trash digivolution cards", CanUseCondition, card);
  85. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  86. cardEffects.Add(activateClass);
  87. string EffectDiscription()
  88. {
  89. return "[Your Turn] When you play a blue Digimon, you may suspend this Tamer to trash the bottom digivolution card of 1 of your opponent's Digimon. Then, if the Digimon played is [MarineAngemon], trash the bottom digivolution card of all of your opponent's Digimon.";
  90. }
  91. bool CanSelectPermanentCondition(Permanent permanent)
  92. {
  93. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  94. }
  95. bool PermanentCondition(Permanent permanent)
  96. {
  97. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  98. {
  99. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  100. {
  101. return true;
  102. }
  103. }
  104. return false;
  105. }
  106. bool CanUseCondition(Hashtable hashtable)
  107. {
  108. if (CardEffectCommons.IsExistOnBattleArea(card))
  109. {
  110. if (CardEffectCommons.IsOwnerTurn(card))
  111. {
  112. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  113. {
  114. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  115. hashtable: hashtable,
  116. rootCondition: null);
  117. if (permanents != null)
  118. {
  119. if (permanents.Count(permanent => CardEffectCommons.IsPermanentExistsOnBattleArea(permanent) && permanent.TopCard.CardNames.Contains("MarineAngemon")) >= 1)
  120. {
  121. activateClass.IsMarineAngemon = true;
  122. }
  123. }
  124. return true;
  125. }
  126. }
  127. }
  128. return false;
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleArea(card))
  133. {
  134. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  135. {
  136. return true;
  137. }
  138. }
  139. return false;
  140. }
  141. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  144. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  145. {
  146. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  147. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  148. selectPermanentEffect.SetUp(
  149. selectPlayer: card.Owner,
  150. canTargetCondition: CanSelectPermanentCondition,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. maxCount: maxCount,
  154. canNoSelect: false,
  155. canEndNotMax: false,
  156. selectPermanentCoroutine: SelectPermanentCoroutine,
  157. afterSelectPermanentCoroutine: null,
  158. mode: SelectPermanentEffect.Mode.Custom,
  159. cardEffect: activateClass);
  160. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  161. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  162. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  163. {
  164. Permanent selectedPermanent = permanent;
  165. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: false, activateClass: activateClass));
  166. }
  167. }
  168. if (activateClass.IsMarineAngemon)
  169. {
  170. foreach (Permanent selectedPermanent in card.Owner.Enemy.GetBattleAreaDigimons())
  171. {
  172. if (CanSelectPermanentCondition(selectedPermanent))
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: false, activateClass: activateClass));
  175. }
  176. }
  177. }
  178. }
  179. }
  180. if (timing == EffectTiming.SecuritySkill)
  181. {
  182. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  183. }
  184. return cardEffects;
  185. }
  186. class ExtendActivateClass : ActivateClass
  187. {
  188. public ExtendActivateClass(bool isMarineAngemon)
  189. {
  190. IsMarineAngemon = isMarineAngemon;
  191. }
  192. public bool IsMarineAngemon { get; set; }
  193. }
  194. }
  195. }