BT16_080.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_080 : 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 PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasText("Pulsemon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region When Digivolving / End of Attack
  22. if (timing == EffectTiming.OnEnterFieldAnyone || timing == EffectTiming.OnEndAttack)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Give -7000 DP and/or delete 1 of your opponent's unsuspended Digimon.", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  27. activateClass.SetHashString("GiveMinusDPAndOrDelete_BT16_080");
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[When Digivolving] [End of Attack] [Once per turn] If you have 3 or more security cards, 1 of your opponent's Digimon gets -7000 DP for the turn. If you have 3 or fewer security cards, delete 1 of your opponent's unsuspended Digimon.";
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) || CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  36. }
  37. bool PermanentCondition(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  40. {
  41. return true;
  42. }
  43. return false;
  44. }
  45. bool PermanentConditionUnsuspended(Permanent permanent)
  46. {
  47. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  48. {
  49. if (!permanent.IsSuspended)
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (card.Owner.SecurityCards.Count <= 3)
  61. {
  62. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentCondition))
  63. {
  64. return true;
  65. }
  66. }
  67. if (card.Owner.SecurityCards.Count >= 3)
  68. {
  69. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentConditionUnsuspended))
  70. {
  71. return true;
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable hashtable)
  78. {
  79. if (card.Owner.SecurityCards.Count >= 3)
  80. {
  81. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  82. {
  83. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  84. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  85. selectPermanentEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: PermanentCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: maxCount,
  91. canNoSelect: false,
  92. canEndNotMax: false,
  93. selectPermanentCoroutine: SelectPermanentCoroutine,
  94. afterSelectPermanentCoroutine: null,
  95. mode: SelectPermanentEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. selectPermanentEffect.SetUpCustomMessage(
  98. "Select 1 Digimon that will get DP -7000.",
  99. "The opponent is selecting 1 Digimon that will get DP -7000.");
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  104. targetPermanent: permanent,
  105. changeValue: -7000,
  106. effectDuration: EffectDuration.UntilEachTurnEnd,
  107. activateClass: activateClass));
  108. }
  109. }
  110. }
  111. if (card.Owner.SecurityCards.Count <= 3)
  112. {
  113. if (CardEffectCommons.HasMatchConditionPermanent(PermanentConditionUnsuspended))
  114. {
  115. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentConditionUnsuspended));
  116. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  117. selectPermanentEffect.SetUp(
  118. selectPlayer: card.Owner,
  119. canTargetCondition: PermanentConditionUnsuspended,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. maxCount: maxCount,
  123. canNoSelect: false,
  124. canEndNotMax: false,
  125. selectPermanentCoroutine: null,
  126. afterSelectPermanentCoroutine: null,
  127. mode: SelectPermanentEffect.Mode.Destroy,
  128. cardEffect: activateClass);
  129. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. #region All Turns
  136. if (timing == EffectTiming.WhenRemoveField)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect("Trash a security to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  141. activateClass.SetHashString("TrashSecurityToStay_BT16_080");
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[All Turns] When this Digimon would leave the battle area by your opponent's effects, if you have 3 or more security cards, by trashing the top card of your security stack, prevent it from leaving.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleArea(card))
  150. {
  151. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  152. {
  153. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card)))
  154. {
  155. return true;
  156. }
  157. }
  158. }
  159. return false;
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.IsExistOnBattleArea(card))
  164. {
  165. if (card.Owner.SecurityCards.Count >= 3)
  166. {
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  173. {
  174. if (CardEffectCommons.IsExistOnBattleArea(card) || card.Owner.SecurityCards.Count >= 3)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  177. card.Owner,
  178. 1,
  179. activateClass,
  180. true).DestroySecurity());
  181. Permanent thisCardPermanent = card.PermanentOfThisCard();
  182. thisCardPermanent.willBeRemoveField = false;
  183. thisCardPermanent.HideDeleteEffect();
  184. thisCardPermanent.HideHandBounceEffect();
  185. thisCardPermanent.HideDeckBounceEffect();
  186. thisCardPermanent.HideWillRemoveFieldEffect();
  187. yield return null;
  188. }
  189. }
  190. }
  191. #endregion
  192. #region On Deletion
  193. if (timing == EffectTiming.OnDestroyedAnyone)
  194. {
  195. ActivateClass activateClass = new ActivateClass();
  196. activateClass.SetUpICardEffect("Recovery +1 until you have 3 security cards.", CanUseCondition, card);
  197. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  198. cardEffects.Add(activateClass);
  199. string EffectDiscription()
  200. {
  201. return "[On Deletion] <Recovery +1> until you have 3 security cards.)";
  202. }
  203. bool CanUseCondition(Hashtable hashtable)
  204. {
  205. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  206. }
  207. bool CanActivateCondition(Hashtable hashtable)
  208. {
  209. if (CardEffectCommons.IsExistOnTrash(card))
  210. {
  211. if (card.Owner.LibraryCards.Count >= 1)
  212. {
  213. if (card.Owner.SecurityCards.Count <= 3)
  214. {
  215. if (card.Owner.CanAddSecurity(activateClass))
  216. {
  217. return true;
  218. }
  219. }
  220. }
  221. }
  222. return false;
  223. }
  224. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  225. {
  226. while (card.Owner.SecurityCards.Count < 3)
  227. {
  228. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  229. }
  230. }
  231. }
  232. #endregion
  233. return cardEffects;
  234. }
  235. }
  236. }