BT22_019.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Veemon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_019 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel2 && targetPermanent.TopCard.HasCSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 0,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Your Turn
  29. if (timing == EffectTiming.BeforePayCost)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. activateClass.SetHashString("DigivoltuionCost-1_BT22_019");
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[Your Turn] When this Digimon would digivolve into a Digimon card with [Veedramon] in its name, reduce the digivolution cost by 1.";
  39. }
  40. bool PermanentCondition(Permanent permanent)
  41. {
  42. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  43. {
  44. if (permanent == card.PermanentOfThisCard())
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. bool CardCondition(CardSource cardSource)
  52. {
  53. return cardSource.IsDigimon && cardSource.ContainsCardName("Veedramon");
  54. }
  55. bool CanUseCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  58. {
  59. if (CardEffectCommons.IsOwnerTurn(card))
  60. {
  61. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. bool CanActivateCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  74. {
  75. Hashtable hashtable = new Hashtable();
  76. hashtable.Add("CardEffect", activateClass);
  77. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  78. ChangeCostClass changeCostClass = new ChangeCostClass();
  79. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  80. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  81. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  83. bool CanUseCondition1(Hashtable hashtable)
  84. {
  85. return true;
  86. }
  87. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  88. {
  89. if (CardSourceCondition(cardSource))
  90. {
  91. if (RootCondition(root))
  92. {
  93. if (PermanentsCondition(targetPermanents))
  94. {
  95. Cost -= 1;
  96. }
  97. }
  98. }
  99. return Cost;
  100. }
  101. bool PermanentsCondition(List<Permanent> targetPermanents)
  102. {
  103. if (targetPermanents != null)
  104. {
  105. if (targetPermanents.Count(PermanentCondition) >= 1)
  106. {
  107. return true;
  108. }
  109. }
  110. return false;
  111. }
  112. bool PermanentCondition(Permanent targetPermanent)
  113. {
  114. if (targetPermanent.TopCard != null)
  115. {
  116. if (targetPermanent.TopCard.Owner == card.Owner)
  117. {
  118. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  119. {
  120. return true;
  121. }
  122. }
  123. }
  124. return false;
  125. }
  126. bool CardSourceCondition(CardSource cardSource)
  127. {
  128. if (cardSource != null)
  129. {
  130. if (cardSource.Owner == card.Owner)
  131. {
  132. return CardCondition(cardSource);
  133. }
  134. }
  135. return false;
  136. }
  137. bool RootCondition(SelectCardEffect.Root root)
  138. {
  139. return true;
  140. }
  141. bool isUpDown()
  142. {
  143. return true;
  144. }
  145. }
  146. }
  147. #endregion
  148. #region ESS
  149. if (timing == EffectTiming.WhenRemoveField)
  150. {
  151. ActivateClass activateClass = new ActivateClass();
  152. activateClass.SetUpICardEffect("Suspend to prevent this Digimon from leaving", CanUseCondition, card);
  153. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  154. activateClass.SetHashString("Substitute_BT22_019");
  155. activateClass.SetIsInheritedEffect(true);
  156. cardEffects.Add(activateClass);
  157. string EffectDiscription()
  158. {
  159. return "[All Turns] [Once Per Turn] When this Digimon with [Veedramon] in its name would leave the battle area by your opponent's effects, by suspending this Digimon, it doesn't leave.";
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
  164. CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card));
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  169. CardEffectCommons.CanActivateSuspendCostEffect(card) &&
  170. card.PermanentOfThisCard().TopCard.ContainsCardName("Veedramon");
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable hashtable)
  173. {
  174. Permanent thisCardPermanent = card.PermanentOfThisCard();
  175. IEnumerator StopFieldRemoval()
  176. {
  177. thisCardPermanent.willBeRemoveField = false;
  178. thisCardPermanent.HideDeleteEffect();
  179. thisCardPermanent.HideHandBounceEffect();
  180. thisCardPermanent.HideDeckBounceEffect();
  181. thisCardPermanent.HideWillRemoveFieldEffect();
  182. yield return null;
  183. }
  184. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent> { thisCardPermanent }, hashtable).Tap());
  185. yield return ContinuousController.instance.StartCoroutine(StopFieldRemoval());
  186. }
  187. }
  188. #endregion
  189. return cardEffects;
  190. }
  191. }
  192. }