ST20_12.cs 7.7 KB

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