ST21_12.cs 7.9 KB

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