BT20_029.cs 8.7 KB

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