BT16_044.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_044 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolve Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool HasPulsmonInText(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasText("Pulsemon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: HasPulsmonInText, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region On Play/When Digivolving Shared
  22. bool PermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. return false;
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Suspend and/or gain memory", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[On Play] If you have 3 or more security cards, suspend 1 of your opponent's Digimon. If you have 3 or fewer security cards, gain 1 memory.";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  47. {
  48. if (card.Owner.SecurityCards.Count >= 3)
  49. {
  50. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentCondition))
  51. {
  52. return true;
  53. }
  54. }
  55. if (card.Owner.SecurityCards.Count <= 3)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable hashtable)
  63. {
  64. if (card.Owner.SecurityCards.Count >= 3)
  65. {
  66. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: PermanentCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: null,
  77. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  78. mode: SelectPermanentEffect.Mode.Tap,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend and give effects.", "The opponent is selecting 1 Digimon to suspend and give effects.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  83. {
  84. foreach (Permanent selectedPermanent in permanents)
  85. {
  86. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendNextActivePhase(
  89. targetPermanent: selectedPermanent,
  90. activateClass: activateClass
  91. ));
  92. }
  93. }
  94. yield return null;
  95. }
  96. }
  97. if (card.Owner.SecurityCards.Count <= 3)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  100. }
  101. }
  102. }
  103. #endregion
  104. #region When Digivolving
  105. if (timing == EffectTiming.OnEnterFieldAnyone)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect("Suspend and/or gain memory", CanUseCondition, card);
  109. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[When Digivolving] If you have 3 or more security cards, suspend 1 of your opponent's Digimon. If you have 3 or fewer security cards, gain 1 memory.";
  114. }
  115. bool CanUseCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  118. }
  119. bool CanActivateCondition(Hashtable hashtable)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  122. {
  123. if (card.Owner.SecurityCards.Count >= 3)
  124. {
  125. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentCondition))
  126. {
  127. return true;
  128. }
  129. }
  130. if (card.Owner.SecurityCards.Count <= 3)
  131. {
  132. return true;
  133. }
  134. }
  135. return false;
  136. }
  137. IEnumerator ActivateCoroutine(Hashtable hashtable)
  138. {
  139. if (card.Owner.SecurityCards.Count >= 3)
  140. {
  141. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  142. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  143. selectPermanentEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition: PermanentCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. maxCount: maxCount,
  149. canNoSelect: false,
  150. canEndNotMax: false,
  151. selectPermanentCoroutine: null,
  152. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  153. mode: SelectPermanentEffect.Mode.Tap,
  154. cardEffect: activateClass);
  155. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend and give effects.", "The opponent is selecting 1 Digimon to suspend and give effects.");
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  158. {
  159. foreach (Permanent selectedPermanent in permanents)
  160. {
  161. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendNextActivePhase(
  164. targetPermanent: selectedPermanent,
  165. activateClass: activateClass
  166. ));
  167. }
  168. }
  169. yield return null;
  170. }
  171. }
  172. if (card.Owner.SecurityCards.Count <= 3)
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  175. }
  176. }
  177. }
  178. #endregion
  179. #region Inherit
  180. if (timing == EffectTiming.OnEndAttack)
  181. {
  182. ActivateClass activateClass = new ActivateClass();
  183. activateClass.SetUpICardEffect("Unsuspend this Digimon.", CanUseCondition, card);
  184. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  185. activateClass.SetIsInheritedEffect(true);
  186. activateClass.SetHashString("Unsuspend_BT16_044");
  187. cardEffects.Add(activateClass);
  188. string EffectDiscription()
  189. {
  190. return "[End of Attack][Once per turn] If this Digimon has [Pulsemon] in its text, by trashing the top card of your security stack, unsuspend this Digimon.";
  191. }
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  195. }
  196. bool CanActivateCondition(Hashtable hashtable)
  197. {
  198. if (CardEffectCommons.IsExistOnBattleArea(card))
  199. {
  200. if (card.PermanentOfThisCard().TopCard.HasText("Pulsemon"))
  201. {
  202. if (card.Owner.SecurityCards.Count >= 1)
  203. {
  204. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  205. {
  206. return true;
  207. }
  208. }
  209. }
  210. }
  211. return false;
  212. }
  213. bool PermanentHasPulsemonInText(Permanent permanent)
  214. {
  215. if (permanent == card.PermanentOfThisCard())
  216. {
  217. if (card.PermanentOfThisCard().TopCard.HasText("Pulsemon"))
  218. {
  219. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  220. {
  221. return true;
  222. }
  223. }
  224. }
  225. return false;
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  228. {
  229. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  230. player: card.Owner,
  231. destroySecurityCount: 1,
  232. cardEffect: activateClass,
  233. fromTop: true).DestroySecurity());
  234. if (CardEffectCommons.HasMatchConditionPermanent(PermanentHasPulsemonInText))
  235. {
  236. Permanent selectedPermanent = card.PermanentOfThisCard();
  237. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  238. }
  239. }
  240. }
  241. #endregion
  242. return cardEffects;
  243. }
  244. }
  245. }