BT21_011.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Shoutmon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_011 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Cost
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.IsDigimon && targetPermanent.Level == 2)
  18. {
  19. if (targetPermanent.TopCard.EqualsTraits("Xros Heart") || targetPermanent.TopCard.EqualsTraits("Hero"))
  20. {
  21. return true;
  22. }
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Your Turn
  30. if (timing == EffectTiming.BeforePayCost)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Reduce the digivolution cost by 1", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. => "[Your Turn] When this Digimon would digivolve into a Digimon card with the [Xros Heart]/[Hero] trait, reduce the digivolution cost by 1.";
  38. bool PermanentCondition(Permanent permanent)
  39. {
  40. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  41. {
  42. if (permanent == card.PermanentOfThisCard())
  43. {
  44. return true;
  45. }
  46. }
  47. return false;
  48. }
  49. bool HasProperTrait(CardSource source)
  50. {
  51. return source.IsDigimon &&
  52. (source.EqualsTraits("Xros Heart") || source.EqualsTraits("Hero"));
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  57. {
  58. if (CardEffectCommons.IsOwnerTurn(card))
  59. {
  60. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, HasProperTrait))
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. return false;
  67. }
  68. bool CanActivateCondition(Hashtable hashtable)
  69. {
  70. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  73. {
  74. if (isExistOnField(card))
  75. {
  76. Hashtable hashtable = new Hashtable
  77. {
  78. { "CardEffect", activateClass }
  79. };
  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. return (cardSource.EqualsTraits("Xros Heart") || cardSource.EqualsTraits("Hero"));
  136. }
  137. }
  138. return false;
  139. }
  140. bool RootCondition(SelectCardEffect.Root root)
  141. {
  142. return true;
  143. }
  144. bool isUpDown()
  145. {
  146. return true;
  147. }
  148. }
  149. }
  150. }
  151. #endregion
  152. #region On Deletion
  153. if (timing == EffectTiming.OnDestroyedAnyone)
  154. {
  155. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  156. }
  157. #endregion
  158. #region ESS
  159. if (timing == EffectTiming.None)
  160. {
  161. bool Condition()
  162. {
  163. return card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart");
  164. }
  165. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  166. }
  167. #endregion
  168. return cardEffects;
  169. }
  170. }
  171. }