ST20_12.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //ST20 Sora & Kari
  4. namespace DCGO.CardEffects.ST20
  5. {
  6. public class ST20_12 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Start of main mem gain
  12. if (timing == EffectTiming.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return "[Start of Your Main Phase] If you have a Digimon with the [ADVENTURE] trait, gain 1 memory.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. if (CardEffectCommons.IsExistOnBattleArea(card))
  25. {
  26. if (CardEffectCommons.IsOwnerTurn(card))
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanActivateCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. if (card.Owner.CanAddMemory(activateClass))
  38. {
  39. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, permanent => permanent.IsDigimon && permanent.TopCard.EqualsTraits("ADVENTURE"))){
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable hashtable)
  47. {
  48. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  49. }
  50. }
  51. #endregion
  52. #region Cost reduction
  53. if (timing == EffectTiming.BeforePayCost)
  54. {
  55. ActivateClass activateClass = new ActivateClass();
  56. activateClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition, card);
  57. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  58. cardEffects.Add(activateClass);
  59. string EffectDiscription()
  60. {
  61. return "[Your Turn] When any Digimon cards with the [ADVENTURE] trait would be played from your hand, by suspending this Tamer, reduce the play cost by 1.";
  62. }
  63. bool PlayCardCondition(CardSource cardSource)
  64. {
  65. if (CardEffectCommons.IsExistOnHand(cardSource))
  66. {
  67. return cardSource.EqualsTraits("ADVENTURE");
  68. }
  69. return false;
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. if (CardEffectCommons.IsExistOnBattleArea(card))
  74. {
  75. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, PlayCardCondition);
  76. }
  77. return false;
  78. }
  79. bool CanActivateCondition(Hashtable hashtable)
  80. {
  81. if (CardEffectCommons.IsOwnerTurn(card))
  82. {
  83. if (CardEffectCommons.IsExistOnBattleArea(card))
  84. {
  85. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  86. {
  87. return true;
  88. }
  89. }
  90. }
  91. return false;
  92. }
  93. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  94. {
  95. if (CardEffectCommons.IsExistOnBattleArea(card))
  96. {
  97. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  100. new List<Permanent>() { card.PermanentOfThisCard() },
  101. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  102. if (card.PermanentOfThisCard().IsSuspended)
  103. {
  104. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  105. ChangeCostClass changeCostClass = new ChangeCostClass();
  106. changeCostClass.SetUpICardEffect("Cost -1", CanUseChangeCostCondition, card);
  107. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  108. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  109. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  110. bool CanUseChangeCostCondition(Hashtable hashtable)
  111. {
  112. return true;
  113. }
  114. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  115. {
  116. if (CardSourceCondition(cardSource))
  117. {
  118. if (RootCondition(root))
  119. {
  120. if (PermanentsCondition(targetPermanents))
  121. {
  122. Cost -= 1;
  123. }
  124. }
  125. }
  126. return Cost;
  127. }
  128. bool PermanentsCondition(List<Permanent> targetPermanents)
  129. {
  130. return targetPermanents != null;
  131. }
  132. bool CardSourceCondition(CardSource cardSource)
  133. {
  134. if (cardSource != null)
  135. {
  136. return cardSource.Owner == card.Owner;
  137. }
  138. return false;
  139. }
  140. bool RootCondition(SelectCardEffect.Root root)
  141. {
  142. return true;
  143. }
  144. bool isUpDown()
  145. {
  146. return true;
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. #endregion
  154. if (timing == EffectTiming.SecuritySkill)
  155. {
  156. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  157. }
  158. return cardEffects;
  159. }
  160. }
  161. }