BT16_038.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class 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, false, 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. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  36. {
  37. if (permanent == card.PermanentOfThisCard())
  38. {
  39. return true;
  40. }
  41. }
  42. return false;
  43. }
  44. bool CardCondition(CardSource cardSource)
  45. {
  46. if (cardSource.IsDigimon)
  47. {
  48. if (cardSource.ContainsCardName("Gargomon"))
  49. {
  50. return true;
  51. }
  52. if (cardSource.ContainsCardName("Rapidmon"))
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. if (CardEffectCommons.IsExistOnBattleArea(card))
  62. {
  63. if (CardEffectCommons.IsOwnerTurn(card))
  64. {
  65. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. bool CanActivateCondition(Hashtable hashtable)
  74. {
  75. if (CardEffectCommons.IsExistOnBattleArea(card))
  76. {
  77. return true;
  78. }
  79. return false;
  80. }
  81. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  82. {
  83. if (isExistOnField(card))
  84. {
  85. Hashtable hashtable = new Hashtable();
  86. hashtable.Add("CardEffect", activateClass);
  87. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  88. ChangeCostClass changeCostClass = new ChangeCostClass();
  89. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  90. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  91. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  92. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  93. bool CanUseCondition1(Hashtable hashtable)
  94. {
  95. return true;
  96. }
  97. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  98. {
  99. if (CardSourceCondition(cardSource))
  100. {
  101. if (RootCondition(root))
  102. {
  103. if (PermanentsCondition(targetPermanents))
  104. {
  105. Cost -= 1;
  106. }
  107. }
  108. }
  109. return Cost;
  110. }
  111. bool PermanentsCondition(List<Permanent> targetPermanents)
  112. {
  113. if (targetPermanents != null)
  114. {
  115. if (targetPermanents.Count(PermanentCondition) >= 1)
  116. {
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. bool PermanentCondition(Permanent targetPermanent)
  123. {
  124. if (targetPermanent.TopCard != null)
  125. {
  126. if (targetPermanent.TopCard.Owner == card.Owner)
  127. {
  128. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  129. {
  130. return true;
  131. }
  132. }
  133. }
  134. return false;
  135. }
  136. bool CardSourceCondition(CardSource cardSource)
  137. {
  138. if (cardSource != null)
  139. {
  140. if (cardSource.Owner == card.Owner)
  141. {
  142. if (cardSource.ContainsCardName("Gargomon"))
  143. {
  144. return true;
  145. }
  146. if (cardSource.ContainsCardName("Rapidmon"))
  147. {
  148. return true;
  149. }
  150. }
  151. }
  152. return false;
  153. }
  154. bool RootCondition(SelectCardEffect.Root root)
  155. {
  156. return true;
  157. }
  158. bool isUpDown()
  159. {
  160. return true;
  161. }
  162. }
  163. }
  164. }
  165. #endregion
  166. #region Inherit
  167. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  168. {
  169. bool Condition()
  170. {
  171. if (CardEffectCommons.IsExistOnBattleArea(card))
  172. {
  173. if (CardEffectCommons.IsOwnerTurn(card))
  174. {
  175. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Gargomon"))
  176. {
  177. return true;
  178. }
  179. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Rapidmon"))
  180. {
  181. return true;
  182. }
  183. }
  184. }
  185. return false;
  186. }
  187. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  188. }
  189. #endregion
  190. return cardEffects;
  191. }
  192. }
  193. }