BT20_038.cs 7.3 KB

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