BT21_065.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //BT21_065 Ghostmon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_065 : 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("Reduce the digivolution cost by 1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Your Turn] When this Digimon would digivolve into a Digimon card with the [Ghost] trait, reduce the digivolution cost by 1.";
  22. }
  23. bool PermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent == card.PermanentOfThisCard())
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool HasProperTrait(CardSource source)
  35. {
  36. return source.IsDigimon && source.EqualsTraits("Ghost");
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  41. {
  42. if (CardEffectCommons.IsOwnerTurn(card))
  43. {
  44. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, HasProperTrait))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. if (isExistOnField(card))
  59. {
  60. Hashtable hashtable = new Hashtable();
  61. hashtable.Add("CardEffect", activateClass);
  62. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  63. ChangeCostClass changeCostClass = new ChangeCostClass();
  64. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  65. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  66. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  67. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  68. bool CanUseCondition1(Hashtable hashtable)
  69. {
  70. return true;
  71. }
  72. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  73. {
  74. if (CardSourceCondition(cardSource))
  75. {
  76. if (RootCondition(root))
  77. {
  78. if (PermanentsCondition(targetPermanents))
  79. {
  80. Cost -= 1;
  81. }
  82. }
  83. }
  84. return Cost;
  85. }
  86. bool PermanentsCondition(List<Permanent> targetPermanents)
  87. {
  88. if (targetPermanents != null)
  89. {
  90. if (targetPermanents.Count(PermanentCondition) >= 1)
  91. {
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. bool PermanentCondition(Permanent targetPermanent)
  98. {
  99. if (targetPermanent.TopCard != null)
  100. {
  101. if (targetPermanent.TopCard.Owner == card.Owner)
  102. {
  103. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  104. {
  105. return true;
  106. }
  107. }
  108. }
  109. return false;
  110. }
  111. bool CardSourceCondition(CardSource cardSource)
  112. {
  113. if (cardSource != null)
  114. {
  115. if (cardSource.Owner == card.Owner)
  116. {
  117. return cardSource.EqualsTraits("Ghost");
  118. }
  119. }
  120. return false;
  121. }
  122. bool RootCondition(SelectCardEffect.Root root)
  123. {
  124. return true;
  125. }
  126. bool isUpDown()
  127. {
  128. return true;
  129. }
  130. }
  131. }
  132. }
  133. #endregion
  134. #region On Deletion inherit
  135. if (timing == EffectTiming.OnDestroyedAnyone)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  139. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  140. activateClass.SetIsInheritedEffect(true);
  141. cardEffects.Add(activateClass);
  142. string EffectDescription()
  143. {
  144. return "[On Deletion] Gain 1 memory.";
  145. }
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  153. {
  154. if (card.Owner.CanAddMemory(activateClass))
  155. {
  156. return true;
  157. }
  158. }
  159. return false;
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  164. }
  165. }
  166. #endregion
  167. return cardEffects;
  168. }
  169. }
  170. }