BT23_005.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Elizamon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_005 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Your Turn
  13. if (timing == EffectTiming.BeforePayCost)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Reduce the digivolution cost by 1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Your Turn] When this Digimon would digivolve into a Digimon card with the [Reptile] or [Dragonkin] trait, reduce the digivolution cost by 1.";
  22. }
  23. bool PermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent == card.PermanentOfThisCard())
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool HasProperTrait(CardSource source)
  35. {
  36. return source.IsDigimon &&
  37. (source.EqualsTraits("Reptile") || source.EqualsTraits("Dragonkin"));
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  42. {
  43. if (CardEffectCommons.IsOwnerTurn(card))
  44. {
  45. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, HasProperTrait))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (isExistOnField(card))
  60. {
  61. Hashtable hashtable = new Hashtable
  62. {
  63. { "CardEffect", activateClass }
  64. };
  65. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  66. ChangeCostClass changeCostClass = new ChangeCostClass();
  67. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  68. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  69. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  70. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  71. bool CanUseCondition1(Hashtable hashtable)
  72. {
  73. return true;
  74. }
  75. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  76. {
  77. if (CardSourceCondition(cardSource))
  78. {
  79. if (RootCondition(root))
  80. {
  81. if (PermanentsCondition(targetPermanents))
  82. {
  83. Cost -= 1;
  84. }
  85. }
  86. }
  87. return Cost;
  88. }
  89. bool PermanentsCondition(List<Permanent> targetPermanents)
  90. {
  91. if (targetPermanents != null)
  92. {
  93. if (targetPermanents.Count(PermanentCondition) >= 1)
  94. {
  95. return true;
  96. }
  97. }
  98. return false;
  99. }
  100. bool PermanentCondition(Permanent targetPermanent)
  101. {
  102. if (targetPermanent.TopCard != null)
  103. {
  104. if (targetPermanent.TopCard.Owner == card.Owner)
  105. {
  106. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  107. {
  108. return true;
  109. }
  110. }
  111. }
  112. return false;
  113. }
  114. bool CardSourceCondition(CardSource cardSource)
  115. {
  116. if (cardSource != null)
  117. {
  118. if (cardSource.Owner == card.Owner)
  119. {
  120. return cardSource.EqualsTraits("Reptile") || cardSource.EqualsTraits("Dragonkin");
  121. }
  122. }
  123. return false;
  124. }
  125. bool RootCondition(SelectCardEffect.Root root)
  126. {
  127. return true;
  128. }
  129. bool isUpDown()
  130. {
  131. return true;
  132. }
  133. }
  134. }
  135. }
  136. #endregion
  137. #region ESS
  138. if (timing == EffectTiming.None)
  139. {
  140. bool Condition()
  141. {
  142. return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.IsOwnerTurn(card);
  143. }
  144. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 2000, isInheritedEffect: true, card: card, condition: Condition));
  145. }
  146. #endregion
  147. return cardEffects;
  148. }
  149. }
  150. }