LM_004.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace DCGO.CardEffects.LM
  6. {
  7. public class LM_004 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play/When Digivolving
  13. bool CanSelectCardCondition(CardSource cardSource)
  14. {
  15. if (cardSource.HasCardColor(CardColor.Blue))
  16. {
  17. return true;
  18. }
  19. return false;
  20. }
  21. bool CanSelectDigimonCondition(Permanent permanent)
  22. {
  23. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  24. }
  25. bool CanSelectTamerCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  28. {
  29. if (permanent.IsTamer)
  30. {
  31. if (permanent.TopCard.CardNames.Contains("Kiyoshiro Higashimitarai") || permanent.TopCard.CardNames.Contains("KiyoshiroHigashimitarai"))
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. if (CardEffectCommons.IsExistOnBattleArea(card))
  40. {
  41. if (card.Owner.HandCards.Count >= 2)
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. #endregion
  49. #region On Play
  50. if (timing == EffectTiming.OnEnterFieldAnyone)
  51. {
  52. ActivateClass activateClass = new ActivateClass();
  53. activateClass.SetUpICardEffect("Can't be deleted by battle", CanUseCondition, card);
  54. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  55. cardEffects.Add(activateClass);
  56. string EffectDiscription()
  57. {
  58. return "[On Play] By trashing 2 blue cards in your hand, unsuspend 1 of your Digimon and 1 of your [Kiyoshiro Higashimitarai], and this Digimon gains <Blocker> until the end of your opponent's turn.";
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. bool discarded = false;
  67. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  68. selectHandEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectCardCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: 2,
  74. canNoSelect: true,
  75. canEndNotMax: false,
  76. isShowOpponent: true,
  77. selectCardCoroutine: null,
  78. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  79. mode: SelectHandEffect.Mode.Discard,
  80. cardEffect: activateClass);
  81. yield return StartCoroutine(selectHandEffect.Activate());
  82. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  83. {
  84. if (cardSources.Count == 2)
  85. {
  86. discarded = true;
  87. yield return null;
  88. }
  89. }
  90. if (discarded)
  91. {
  92. yield return UnsuspendTargetPermenants(CanSelectDigimonCondition);
  93. yield return UnsuspendTargetPermenants(CanSelectTamerCondition);
  94. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(targetPermanent: card.PermanentOfThisCard(), effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  95. }
  96. }
  97. IEnumerator UnsuspendTargetPermenants(Func<Permanent,bool> selectCondition)
  98. {
  99. if (CardEffectCommons.HasMatchConditionPermanent(selectCondition))
  100. {
  101. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(selectCondition));
  102. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: selectCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: maxCount,
  109. canNoSelect: false,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: null,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.UnTap,
  114. cardEffect: activateClass);
  115. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  116. }
  117. }
  118. }
  119. #endregion
  120. #region When Digivolving
  121. if (timing == EffectTiming.OnEnterFieldAnyone)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect("Can't be deleted by battle", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  126. cardEffects.Add(activateClass);
  127. string EffectDiscription()
  128. {
  129. return "[When Digivolving] By trashing 2 blue cards in your hand, unsuspend 1 of your Digimon and 1 of your [Kiyoshiro Higashimitarai], and this Digimon gains <Blocker> until the end of your opponent's turn.";
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  134. }
  135. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  136. {
  137. bool discarded = false;
  138. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  139. selectHandEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectCardCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: 2,
  145. canNoSelect: true,
  146. canEndNotMax: false,
  147. isShowOpponent: true,
  148. selectCardCoroutine: null,
  149. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  150. mode: SelectHandEffect.Mode.Discard,
  151. cardEffect: activateClass);
  152. yield return StartCoroutine(selectHandEffect.Activate());
  153. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  154. {
  155. if (cardSources.Count == 2)
  156. {
  157. discarded = true;
  158. yield return null;
  159. }
  160. }
  161. if (discarded)
  162. {
  163. yield return UnsuspendTargetPermenants(CanSelectDigimonCondition);
  164. yield return UnsuspendTargetPermenants(CanSelectTamerCondition);
  165. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(targetPermanent: card.PermanentOfThisCard(), effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  166. }
  167. }
  168. IEnumerator UnsuspendTargetPermenants(Func<Permanent, bool> selectCondition)
  169. {
  170. if (CardEffectCommons.HasMatchConditionPermanent(selectCondition))
  171. {
  172. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(selectCondition));
  173. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  174. selectPermanentEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: selectCondition,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: maxCount,
  180. canNoSelect: false,
  181. canEndNotMax: false,
  182. selectPermanentCoroutine: null,
  183. afterSelectPermanentCoroutine: null,
  184. mode: SelectPermanentEffect.Mode.UnTap,
  185. cardEffect: activateClass);
  186. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  187. }
  188. }
  189. }
  190. #endregion
  191. #region All Turns - Inherited Effect
  192. if (timing == EffectTiming.OnDiscardHand)
  193. {
  194. ActivateClass activateClass = new ActivateClass();
  195. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  196. activateClass.SetUpActivateClass(CanActivateAllTurnsCondition, ActivateCoroutine, 1, true, EffectAllTurnsDiscription());
  197. activateClass.SetIsInheritedEffect(true);
  198. activateClass.SetHashString("Unsuspend_LM-004");
  199. cardEffects.Add(activateClass);
  200. string EffectAllTurnsDiscription()
  201. {
  202. return "[All Turns] [Once Per Turn] When a card with [Jellymon] in its text is trashed from your hand, you may unsuspend this Digimon.";
  203. }
  204. bool CardCondition(CardSource cardSource)
  205. {
  206. if (cardSource.Owner == card.Owner)
  207. {
  208. if (cardSource.HasText("Jellymon"))
  209. {
  210. return true;
  211. }
  212. }
  213. return false;
  214. }
  215. bool CanUseCondition(Hashtable hashtable)
  216. {
  217. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  218. {
  219. if (CardEffectCommons.CanTriggerOnTrashHand(hashtable, null, CardCondition))
  220. {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. bool CanActivateAllTurnsCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  229. }
  230. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  231. {
  232. Permanent selectedPermanent = card.PermanentOfThisCard();
  233. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  234. }
  235. }
  236. #endregion
  237. return cardEffects;
  238. }
  239. }
  240. }