BT19_039.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT19
  4. {
  5. public class BT19_039 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region On Play
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Trash your top security, delete a Digimon and get 1 memory", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[On Play] By trashing your top security card, delete 1 of your opponent's level 4 or lower Digimon and gain 1 memory.";
  20. }
  21. bool CanSelectPermanentCondition(Permanent permanent)
  22. {
  23. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.IsDigimon && permanent.TopCard.HasLevel && permanent.Level <= 4;
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  32. {
  33. if (card.Owner.SecurityCards.Count >= 1)
  34. {
  35. return true;
  36. }
  37. }
  38. return false;
  39. }
  40. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  41. {
  42. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  43. player: card.Owner,
  44. destroySecurityCount: 1,
  45. cardEffect: activateClass,
  46. fromTop: true).DestroySecurity());
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  50. selectPermanentEffect.SetUp(
  51. selectPlayer: card.Owner,
  52. canTargetCondition: CanSelectPermanentCondition,
  53. canTargetCondition_ByPreSelecetedList: null,
  54. canEndSelectCondition: null,
  55. maxCount: 1,
  56. canNoSelect: false,
  57. canEndNotMax: false,
  58. selectPermanentCoroutine: null,
  59. afterSelectPermanentCoroutine: null,
  60. mode: SelectPermanentEffect.Mode.Destroy,
  61. cardEffect: activateClass);
  62. selectPermanentEffect.SetUpCustomMessage("Select 1 level 4 or lower Digimon to delete.", "The opponent is selecting 1 level 4 or lower Digimon to delete.");
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. }
  65. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  66. }
  67. }
  68. #endregion
  69. #region When Digivolving
  70. if (timing == EffectTiming.OnEnterFieldAnyone)
  71. {
  72. ActivateClass activateClass = new ActivateClass();
  73. activateClass.SetUpICardEffect("Trash your top security, delete a Digimon and get 1 memory", CanUseCondition, card);
  74. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  75. cardEffects.Add(activateClass);
  76. string EffectDiscription()
  77. {
  78. return "[When Digivolving] By trashing your top security card, delete 1 of your opponent's level 4 or lower Digimon and gain 1 memory.";
  79. }
  80. bool CanSelectPermanentCondition(Permanent permanent)
  81. {
  82. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.IsDigimon && permanent.TopCard.HasLevel && permanent.Level <= 4;
  83. }
  84. bool CanUseCondition(Hashtable hashtable)
  85. {
  86. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  87. {
  88. if(CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  89. {
  90. return true;
  91. }
  92. }
  93. return false;
  94. }
  95. bool CanActivateCondition(Hashtable hashtable)
  96. {
  97. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  98. {
  99. if (card.Owner.SecurityCards.Count >= 1)
  100. {
  101. return true;
  102. }
  103. }
  104. return false;
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  107. {
  108. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  109. player: card.Owner,
  110. destroySecurityCount: 1,
  111. cardEffect: activateClass,
  112. fromTop: true).DestroySecurity());
  113. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  114. {
  115. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  116. selectPermanentEffect.SetUp(
  117. selectPlayer: card.Owner,
  118. canTargetCondition: CanSelectPermanentCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. maxCount: 1,
  122. canNoSelect: false,
  123. canEndNotMax: false,
  124. selectPermanentCoroutine: null,
  125. afterSelectPermanentCoroutine: null,
  126. mode: SelectPermanentEffect.Mode.Destroy,
  127. cardEffect: activateClass);
  128. selectPermanentEffect.SetUpCustomMessage("Select 1 level 4 or lower Digimon to delete.", "The opponent is selecting 1 level 4 or lower Digimon to delete.");
  129. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  130. }
  131. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  132. }
  133. }
  134. #endregion
  135. #region On Deletion
  136. if (timing == EffectTiming.OnDestroyedAnyone)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect("Recovery +1", CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  141. cardEffects.Add(activateClass);
  142. string EffectDiscription()
  143. {
  144. return "[On Deletion] <Recovery +1>.";
  145. }
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  153. {
  154. if (card.Owner.LibraryCards.Count >= 1)
  155. {
  156. if (card.Owner.CanAddSecurity(activateClass))
  157. {
  158. return true;
  159. }
  160. }
  161. }
  162. return false;
  163. }
  164. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  165. {
  166. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  167. }
  168. }
  169. #endregion
  170. #region Inherit
  171. if (timing == EffectTiming.OnLoseSecurity)
  172. {
  173. ActivateClass activateClass = new ActivateClass();
  174. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  175. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  176. activateClass.SetHashString("Unsuspend_SkullBaluchimon_BT19_039");
  177. activateClass.SetIsInheritedEffect(true);
  178. cardEffects.Add(activateClass);
  179. string EffectDiscription()
  180. {
  181. return "[All Turns][Once Per Turn] When your security is reduced, you may unsuspend this Digimon.";
  182. }
  183. bool CanUseCondition(Hashtable hashtable)
  184. {
  185. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  186. {
  187. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner))
  188. {
  189. return true;
  190. }
  191. }
  192. return false;
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  199. {
  200. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  201. }
  202. }
  203. #endregion
  204. return cardEffects;
  205. }
  206. }
  207. }