ST21_13.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //ST21 Matt & T.K
  4. namespace DCGO.CardEffects.ST21
  5. {
  6. public class ST21_13 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Cost reduction
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. 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.";
  21. }
  22. bool PlayCardCondition(CardSource cardSource)
  23. => CardEffectCommons.IsExistOnHand(cardSource) && cardSource.IsDigimon && cardSource.HasAdventureTraits && cardSource.Owner == card.Owner;
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleArea(card))
  27. {
  28. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, PlayCardCondition);
  29. }
  30. return false;
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsOwnerTurn(card))
  35. {
  36. if (CardEffectCommons.IsExistOnBattleArea(card))
  37. {
  38. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  47. {
  48. if (CardEffectCommons.IsExistOnBattleArea(card))
  49. {
  50. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  51. {
  52. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  53. new List<Permanent>() { card.PermanentOfThisCard() },
  54. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  55. if (card.PermanentOfThisCard().IsSuspended)
  56. {
  57. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  58. ChangeCostClass changeCostClass = new ChangeCostClass();
  59. changeCostClass.SetUpICardEffect("Cost -1", CanUseChangeCostCondition, card);
  60. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  61. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  62. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  63. bool CanUseChangeCostCondition(Hashtable hashtable)
  64. {
  65. return true;
  66. }
  67. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  68. {
  69. if (CardSourceCondition(cardSource))
  70. {
  71. if (RootCondition(root))
  72. {
  73. if (PermanentsCondition(targetPermanents))
  74. {
  75. Cost -= 1;
  76. }
  77. }
  78. }
  79. return Cost;
  80. }
  81. bool PermanentsCondition(List<Permanent> targetPermanents)
  82. {
  83. return targetPermanents != null;
  84. }
  85. bool CardSourceCondition(CardSource cardSource)
  86. {
  87. if (cardSource != null)
  88. {
  89. return cardSource.Owner == card.Owner;
  90. }
  91. return false;
  92. }
  93. bool RootCondition(SelectCardEffect.Root root)
  94. {
  95. return true;
  96. }
  97. bool isUpDown()
  98. {
  99. return true;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. #endregion
  107. #region Rush gain
  108. if (timing == EffectTiming.None)
  109. {
  110. bool CanUseCondition()
  111. {
  112. return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.IsOwnerTurn(card);
  113. }
  114. bool PermanentCondition(Permanent permanent)
  115. {
  116. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  117. {
  118. if (permanent.TopCard.HasAdventureTraits && permanent.Level >= 5)
  119. {
  120. return true;
  121. }
  122. }
  123. return false;
  124. }
  125. cardEffects.Add(CardEffectFactory.RushStaticEffect(
  126. permanentCondition: PermanentCondition,
  127. isInheritedEffect: false,
  128. card: card,
  129. condition: CanUseCondition));
  130. }
  131. #endregion
  132. if (timing == EffectTiming.SecuritySkill)
  133. {
  134. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  135. }
  136. return cardEffects;
  137. }
  138. }
  139. }