LM_009.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using System.Linq;
  6. namespace DCGO.CardEffects.LM
  7. {
  8. public class LM_009 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Your Turn - when card would be played
  14. if (timing == EffectTiming.BeforePayCost)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Reduce Play/Digivolution Cost", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  19. activateClass.SetHashString("PlayDigivolutionCost-_LM_009");
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[Your Turn] When a card with [Angoramon] in its text would be played or one of your Digimon would digivolve into such a card, by suspending this Digimon, reduce the play or digivolution cost by 2.";
  24. }
  25. bool PermanentCondition(Permanent permanent)
  26. {
  27. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  28. {
  29. return true;
  30. }
  31. return false;
  32. }
  33. bool PlayCardCondition(CardSource cardSource)
  34. {
  35. if (CardEffectCommons.IsExistOnHand(cardSource))
  36. {
  37. if (cardSource.HasText("Angoramon"))
  38. return true;
  39. }
  40. return false;
  41. }
  42. bool DigivolveCardCondition(CardSource cardSource)
  43. {
  44. if (cardSource.IsDigimon)
  45. if (cardSource.HasText("Angoramon"))
  46. return true;
  47. return false;
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. if (CardEffectCommons.IsExistOnBattleArea(card))
  52. {
  53. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, PlayCardCondition))
  54. {
  55. return true;
  56. }
  57. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, DigivolveCardCondition))
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if(CardEffectCommons.IsOwnerTurn(card))
  67. {
  68. if(CardEffectCommons.IsExistOnBattleArea(card))
  69. {
  70. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  71. {
  72. return true;
  73. }
  74. }
  75. }
  76. return false;
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  79. {
  80. if(CardEffectCommons.IsExistOnBattleArea(card))
  81. {
  82. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  85. new List<Permanent>() { card.PermanentOfThisCard() },
  86. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  87. if (card.PermanentOfThisCard().IsSuspended)
  88. {
  89. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  90. ChangeCostClass changeCostClass = new ChangeCostClass();
  91. changeCostClass.SetUpICardEffect("Cost -2", CanUseChangeCostCondition, card);
  92. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  93. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  94. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  95. bool CanUseChangeCostCondition(Hashtable hashtable)
  96. {
  97. return true;
  98. }
  99. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  100. {
  101. if (CardSourceCondition(cardSource))
  102. {
  103. if (RootCondition(root))
  104. {
  105. if (PermanentsCondition(targetPermanents))
  106. {
  107. Cost -= 2;
  108. }
  109. }
  110. }
  111. return Cost;
  112. }
  113. bool PermanentsCondition(List<Permanent> targetPermanents)
  114. {
  115. if (targetPermanents != null)
  116. {
  117. return true;
  118. }
  119. return false;
  120. }
  121. bool CardSourceCondition(CardSource cardSource)
  122. {
  123. if (cardSource != null)
  124. {
  125. if (cardSource.Owner == card.Owner)
  126. {
  127. return true;
  128. }
  129. }
  130. return false;
  131. }
  132. bool RootCondition(SelectCardEffect.Root root)
  133. {
  134. return true;
  135. }
  136. bool isUpDown()
  137. {
  138. return true;
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. #endregion
  146. #region Your Turn - When becomes suspended
  147. if (timing == EffectTiming.OnTappedAnyone)
  148. {
  149. ActivateClass activateClass = new ActivateClass();
  150. activateClass.SetUpICardEffect("gain <Rush>", CanUseCondition, card);
  151. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffecDescription());
  152. cardEffects.Add(activateClass);
  153. string EffecDescription()
  154. {
  155. return "[Your Turn] When this Digimon becomes suspended, 1 of your Digimon with [Angoramon] in its text gains <Rush> for the turn.";
  156. }
  157. bool CanSelectPermanentCondition(Permanent permanent)
  158. {
  159. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent,card))
  160. {
  161. return permanent.TopCard.HasText("Angoramon");
  162. }
  163. return false;
  164. }
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, (permanent) => permanent == card.PermanentOfThisCard());
  168. }
  169. bool CanActivateCondition(Hashtable hashtable)
  170. {
  171. if (CardEffectCommons.IsOwnerTurn(card))
  172. {
  173. if (CardEffectCommons.IsExistOnBattleArea(card))
  174. {
  175. return true;
  176. }
  177. }
  178. return false;
  179. }
  180. IEnumerator ActivateCoroutine(Hashtable hashtable)
  181. {
  182. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  183. {
  184. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  185. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  186. selectPermanentEffect.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: CanSelectPermanentCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: maxCount,
  192. canNoSelect: false,
  193. canEndNotMax: false,
  194. selectPermanentCoroutine: SelectPermanentCoroutine,
  195. afterSelectPermanentCoroutine: null,
  196. mode: SelectPermanentEffect.Mode.Custom,
  197. cardEffect: activateClass);
  198. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  201. {
  202. Permanent selectedPermanent = permanent;
  203. if (selectedPermanent != null)
  204. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(selectedPermanent, EffectDuration.UntilOwnerTurnEnd, activateClass));
  205. }
  206. }
  207. }
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }