P_200.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Kanan Yuki
  7. namespace DCGO.CardEffects.P
  8. {
  9. public class P_200 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Start Of Your Main Phase
  15. if (timing == EffectTiming.OnStartMainPhase)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Suspend 1 digimon", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[Start of Your Main Phase] If you have 4 or less memory, suspend 1 of your opponent's Digimon.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.IsExistOnBattleArea(card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleArea(card)
  32. && CardEffectCommons.IsOwnerTurn(card)
  33. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)
  34. && card.Owner.MemoryForPlayer <= 4;
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  39. }
  40. IEnumerator ActivateCoroutine(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  43. {
  44. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  45. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  46. selectPermanentEffect.SetUp(
  47. selectPlayer: card.Owner,
  48. canTargetCondition: CanSelectPermanentCondition,
  49. canTargetCondition_ByPreSelecetedList: null,
  50. canEndSelectCondition: null,
  51. maxCount: maxCount,
  52. canNoSelect: false,
  53. canEndNotMax: false,
  54. selectPermanentCoroutine: null,
  55. afterSelectPermanentCoroutine: null,
  56. mode: SelectPermanentEffect.Mode.Tap,
  57. cardEffect: activateClass);
  58. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  59. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  60. }
  61. }
  62. }
  63. #endregion
  64. #region Your Turn
  65. if (timing == EffectTiming.BeforePayCost)
  66. {
  67. ActivateClass activateClass = new ActivateClass();
  68. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  69. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  70. activateClass.SetHashString("Digivolve-1_P_200");
  71. cardEffects.Add(activateClass);
  72. string EffectDiscription()
  73. {
  74. return "[Your Turn] When any of your Digimon would digivolve into a Digimon card with the [TS] trait, by suspending this Tamer, reduce the digivolution cost by 1.";
  75. }
  76. bool PermanentCondition(Permanent permanent)
  77. {
  78. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  79. }
  80. bool CardCondition(CardSource cardSource)
  81. {
  82. return cardSource.HasTSTraits;
  83. }
  84. bool CanUseCondition(Hashtable hashtable)
  85. {
  86. if (CardEffectCommons.IsExistOnBattleArea(card))
  87. {
  88. if (CardEffectCommons.IsOwnerTurn(card))
  89. {
  90. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  91. {
  92. return true;
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanActivateCondition(Hashtable hashtable)
  99. {
  100. if (CardEffectCommons.IsExistOnBattleArea(card))
  101. {
  102. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  103. {
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  110. {
  111. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  112. new List<Permanent>() { card.PermanentOfThisCard() },
  113. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  114. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  115. ChangeCostClass changeCostClass = new ChangeCostClass();
  116. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  117. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  118. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  119. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  120. bool CanUseCondition1(Hashtable hashtable)
  121. {
  122. return true;
  123. }
  124. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  125. {
  126. if (CardSourceCondition(cardSource))
  127. {
  128. if (RootCondition(root))
  129. {
  130. if (PermanentsCondition(targetPermanents))
  131. {
  132. Cost -= 1;
  133. }
  134. }
  135. }
  136. return Cost;
  137. }
  138. bool PermanentsCondition(List<Permanent> targetPermanents)
  139. {
  140. if (targetPermanents != null)
  141. {
  142. if (targetPermanents.Count(PermanentCondition) >= 1)
  143. {
  144. return true;
  145. }
  146. }
  147. return false;
  148. }
  149. bool PermanentCondition(Permanent targetPermanent)
  150. {
  151. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  152. }
  153. bool CardSourceCondition(CardSource cardSource)
  154. {
  155. return true;
  156. }
  157. bool RootCondition(SelectCardEffect.Root root)
  158. {
  159. return true;
  160. }
  161. bool isUpDown()
  162. {
  163. return true;
  164. }
  165. }
  166. }
  167. #endregion
  168. #region Security
  169. if (timing == EffectTiming.SecuritySkill)
  170. {
  171. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  172. }
  173. #endregion
  174. return cardEffects;
  175. }
  176. }
  177. }