ST20_12.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. return CardEffectCommons.IsExistOnHand(cardSource) &&
  66. cardSource.IsDigimon && cardSource.EqualsTraits("ADVENTURE");
  67. }
  68. bool CanUseCondition(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.IsExistOnBattleArea(card))
  71. {
  72. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, PlayCardCondition);
  73. }
  74. return false;
  75. }
  76. bool CanActivateCondition(Hashtable hashtable)
  77. {
  78. if (CardEffectCommons.IsOwnerTurn(card))
  79. {
  80. if (CardEffectCommons.IsExistOnBattleArea(card))
  81. {
  82. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  83. {
  84. return true;
  85. }
  86. }
  87. }
  88. return false;
  89. }
  90. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  91. {
  92. if (CardEffectCommons.IsExistOnBattleArea(card))
  93. {
  94. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  95. {
  96. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  97. new List<Permanent>() { card.PermanentOfThisCard() },
  98. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  99. if (card.PermanentOfThisCard().IsSuspended)
  100. {
  101. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  102. ChangeCostClass changeCostClass = new ChangeCostClass();
  103. changeCostClass.SetUpICardEffect("Cost -1", CanUseChangeCostCondition, card);
  104. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  105. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  106. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  107. bool CanUseChangeCostCondition(Hashtable hashtable)
  108. {
  109. return true;
  110. }
  111. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  112. {
  113. if (CardSourceCondition(cardSource))
  114. {
  115. if (RootCondition(root))
  116. {
  117. if (PermanentsCondition(targetPermanents))
  118. {
  119. Cost -= 1;
  120. }
  121. }
  122. }
  123. return Cost;
  124. }
  125. bool PermanentsCondition(List<Permanent> targetPermanents)
  126. {
  127. return targetPermanents != null;
  128. }
  129. bool CardSourceCondition(CardSource cardSource)
  130. {
  131. if (cardSource != null)
  132. {
  133. return cardSource.Owner == card.Owner;
  134. }
  135. return false;
  136. }
  137. bool RootCondition(SelectCardEffect.Root root)
  138. {
  139. return true;
  140. }
  141. bool isUpDown()
  142. {
  143. return true;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. #endregion
  151. if (timing == EffectTiming.SecuritySkill)
  152. {
  153. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  154. }
  155. return cardEffects;
  156. }
  157. }
  158. }