TerriermonXAntibody_BT16_038.cs 8.8 KB

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