P_117.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.P
  9. {
  10. public class P_117 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Activate Cost Reduction
  16. if (timing == EffectTiming.BeforePayCost)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Reduce the digivolution cost by 1", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. activateClass.SetHashString("DigivolutionCost-1_P_117");
  23. string EffectDiscription()
  24. {
  25. return "[Your Turn] [Once Per Turn] When this Digimon would digivolve into a Digimon card with the [Free] trait, if you have a Tamer, reduce the digivolution cost by 1.";
  26. }
  27. bool PermanentCondition(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  30. {
  31. if (permanent == card.PermanentOfThisCard())
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. bool HasProperTrait(CardSource source)
  39. {
  40. return source.IsDigimon &&
  41. source.EqualsTraits("Free");
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  46. {
  47. if (CardEffectCommons.IsOwnerTurn(card))
  48. {
  49. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, HasProperTrait))
  50. {
  51. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanActivateCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. if (isExistOnField(card))
  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 cardSource.EqualsTraits("Free");
  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. }
  141. #endregion
  142. if (timing == EffectTiming.OnAllyAttack)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  147. activateClass.SetIsInheritedEffect(true);
  148. cardEffects.Add(activateClass);
  149. string EffectDiscription()
  150. {
  151. return "[When Attacking] If this Digimon has 2 or more colors, <Draw 1> (Draw 1 card from your deck).";
  152. }
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.IsExistOnBattleArea(card))
  160. {
  161. if (card.PermanentOfThisCard().TopCard.CardColors.Count >= 2)
  162. {
  163. return true;
  164. }
  165. }
  166. return false;
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  169. {
  170. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  171. }
  172. }
  173. return cardEffects;
  174. }
  175. }
  176. }