LM_013.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.LM
  7. {
  8. public class LM_013 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. //Counter - Blast Digivolve
  14. if (timing == EffectTiming.OnCounterTiming)
  15. {
  16. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  17. }
  18. #region On Play/When Digivolving Shared
  19. bool CanSelectSharedPermanentCondition(Permanent permanent)
  20. {
  21. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  22. }
  23. bool HasNoUnsuspendDigimon()
  24. {
  25. if (card.Owner.Enemy.GetBattleAreaDigimons().Count == 0)
  26. {
  27. return true;
  28. }
  29. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaDigimons())
  30. {
  31. if (!permanent.IsSuspended)
  32. return false;
  33. }
  34. return true;
  35. }
  36. #endregion
  37. #region On Play
  38. if (timing == EffectTiming.OnEnterFieldAnyone)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect("Gain Memory +2", CanUseCondition, card);
  42. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  43. cardEffects.Add(activateClass);
  44. string EffectDiscription()
  45. {
  46. return "[On Play] Suspend 1 of your opponent's Digimon. Then, if they have no unsuspended Digimon, gain 2 memory.";
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.IsExistOnBattleArea(card);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable hashtable)
  57. {
  58. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  59. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectSharedPermanentCondition))
  60. {
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectSharedPermanentCondition));
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectSharedPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: null,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Tap,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to Suspend.", "The opponent is selecting 1 Digimon to Suspend.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. }
  77. if (card.Owner.CanAddMemory(activateClass))
  78. {
  79. if (HasNoUnsuspendDigimon())
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  82. }
  83. }
  84. }
  85. }
  86. #endregion
  87. #region When Digivolving
  88. if (timing == EffectTiming.OnEnterFieldAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Gain Memory +2", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  93. cardEffects.Add(activateClass);
  94. string EffectDiscription()
  95. {
  96. return "[When Digivolving] Suspend 1 of your opponent's Digimon. Then, if they have no unsuspended Digimon, gain 2 memory.";
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleArea(card);
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable hashtable)
  107. {
  108. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  109. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectSharedPermanentCondition))
  110. {
  111. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectSharedPermanentCondition));
  112. selectPermanentEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: CanSelectSharedPermanentCondition,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: maxCount,
  118. canNoSelect: false,
  119. canEndNotMax: false,
  120. selectPermanentCoroutine: null,
  121. afterSelectPermanentCoroutine: null,
  122. mode: SelectPermanentEffect.Mode.Tap,
  123. cardEffect: activateClass);
  124. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to Suspend.", "The opponent is selecting 1 Digimon to Suspend.");
  125. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  126. }
  127. if (card.Owner.CanAddMemory(activateClass))
  128. {
  129. if (HasNoUnsuspendDigimon())
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  132. }
  133. }
  134. }
  135. }
  136. #endregion
  137. #region When Attacking
  138. if (timing == EffectTiming.OnAllyAttack)
  139. {
  140. ActivateClass activateClass = new ActivateClass();
  141. activateClass.SetUpICardEffect("Play 1 Digimon card with [Angoramon] in its name from hand", CanUseCondition, card);
  142. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  143. activateClass.SetHashString("PlayAngoramon_LM_013");
  144. cardEffects.Add(activateClass);
  145. string EffectDiscription()
  146. {
  147. return "[When Attacking] You may play 1 Digimon card with [Angoramon] in its text from your hand without paying the cost. At the end of your opponents turn, return that Digimon to the hand.";
  148. }
  149. bool CanSelectCardCondition(CardSource cardSource)
  150. {
  151. if (cardSource.IsDigimon)
  152. {
  153. if (cardSource.HasText("Angoramon"))
  154. {
  155. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  156. {
  157. return true;
  158. }
  159. }
  160. }
  161. return false;
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. if (CardEffectCommons.IsExistOnBattleArea(card))
  170. {
  171. if (card.Owner.HandCards.Count >= 1)
  172. {
  173. if(card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  174. return true;
  175. }
  176. }
  177. return false;
  178. }
  179. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  180. {
  181. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  182. List<CardSource> selectedCards = new List<CardSource>();
  183. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  184. selectHandEffect.SetUp(
  185. selectPlayer: card.Owner,
  186. canTargetCondition: CanSelectCardCondition,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. maxCount: 1,
  190. canNoSelect: true,
  191. canEndNotMax: false,
  192. isShowOpponent: true,
  193. selectCardCoroutine: SelectCardCoroutine,
  194. afterSelectCardCoroutine: null,
  195. mode: SelectHandEffect.Mode.Custom,
  196. cardEffect: activateClass);
  197. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  198. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  199. yield return StartCoroutine(selectHandEffect.Activate());
  200. IEnumerator SelectCardCoroutine(CardSource cardSource)
  201. {
  202. selectedCards.Add(cardSource);
  203. yield return null;
  204. }
  205. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  206. if (selectedCards.Count > 0)
  207. {
  208. Permanent selectedPermanent = selectedCards[0].PermanentOfThisCard();
  209. ActivateClass activateClass1 = new ActivateClass();
  210. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  211. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  212. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  213. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  214. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  215. {
  216. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  217. }
  218. string EffectDiscription1()
  219. {
  220. return "[End of Opponent's Turn] Return this Digimon to the hand.";
  221. }
  222. bool CanUseCondition1(Hashtable hashtable1)
  223. {
  224. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  225. {
  226. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer != selectedPermanent.TopCard.Owner)
  227. {
  228. return true;
  229. }
  230. }
  231. return false;
  232. }
  233. bool CanActivateCondition1(Hashtable hashtable1)
  234. {
  235. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  236. {
  237. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  238. {
  239. return true;
  240. }
  241. }
  242. return false;
  243. }
  244. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  245. {
  246. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  247. {
  248. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
  249. targetPermanents: new List<Permanent>() { selectedPermanent },
  250. activateClass: activateClass1,
  251. successProcess: null,
  252. failureProcess: null));
  253. }
  254. }
  255. ICardEffect GetCardEffect(EffectTiming _timing)
  256. {
  257. if (_timing == EffectTiming.OnEndTurn)
  258. {
  259. return activateClass1;
  260. }
  261. return null;
  262. }
  263. }
  264. }
  265. }
  266. #endregion
  267. return cardEffects;
  268. }
  269. }
  270. }