EX9_003.cs 6.6 KB

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