EX9_036.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_036 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Requirements
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.ContainsTraits("WG") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 2;
  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("Digivolution Cost -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 [WG] 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 CardCondition(CardSource cardSource)
  45. {
  46. return cardSource.IsDigimon && cardSource.ContainsTraits("WG");
  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, CardCondition))
  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. Hashtable hashtable = new Hashtable();
  69. hashtable.Add("CardEffect", activateClass);
  70. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  71. ChangeCostClass changeCostClass = new ChangeCostClass();
  72. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  73. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  74. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  75. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  76. bool CanUseCondition1(Hashtable hashtable)
  77. {
  78. return true;
  79. }
  80. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  81. {
  82. if (CardSourceCondition(cardSource))
  83. {
  84. if (RootCondition(root))
  85. {
  86. if (PermanentsCondition(targetPermanents))
  87. {
  88. Cost -= 1;
  89. }
  90. }
  91. }
  92. return Cost;
  93. }
  94. bool PermanentsCondition(List<Permanent> targetPermanents)
  95. {
  96. if (targetPermanents != null)
  97. {
  98. if (targetPermanents.Count(PermanentCondition) >= 1)
  99. {
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105. bool PermanentCondition(Permanent targetPermanent)
  106. {
  107. if (targetPermanent.TopCard != null)
  108. {
  109. if (targetPermanent.TopCard.Owner == card.Owner)
  110. {
  111. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. return false;
  118. }
  119. bool CardSourceCondition(CardSource cardSource)
  120. {
  121. if (cardSource != null)
  122. {
  123. if (cardSource.Owner == card.Owner)
  124. {
  125. return CardCondition(cardSource);
  126. }
  127. }
  128. return false;
  129. }
  130. bool RootCondition(SelectCardEffect.Root root)
  131. {
  132. return true;
  133. }
  134. bool isUpDown()
  135. {
  136. return true;
  137. }
  138. }
  139. }
  140. #endregion
  141. #region Inherit
  142. if (timing == EffectTiming.None)
  143. {
  144. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(
  145. changeValue: () => 1000,
  146. isInheritedEffect: true,
  147. card: card,
  148. condition: null));
  149. }
  150. #endregion
  151. return cardEffects;
  152. }
  153. }
  154. }