BT24_101.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. // Jupitermon
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_101 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Conditions
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 &&
  18. targetPermanent.TopCard.HasTSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 5,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. if (timing == EffectTiming.None)
  29. {
  30. bool PermanentCondition(Permanent targetPermanent)
  31. {
  32. return targetPermanent.TopCard.IsLevel5 &&
  33. targetPermanent.TopCard.ContainsCardName("Aegiochusmon");
  34. }
  35. int CostEquation()
  36. {
  37. return card.Owner.SecurityCards.Count;
  38. }
  39. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  40. permanentCondition: PermanentCondition,
  41. digivolutionCost: 5,
  42. ignoreDigivolutionRequirement: false,
  43. card: card,
  44. condition: null,
  45. costEquation: CostEquation)
  46. );
  47. }
  48. #endregion
  49. #region Shared OP / WD
  50. string SharedEffectName() => "Trash top sec, -13k 1 opp Digimon, Maybe Recover 2";
  51. string SharedEffectDescription(string tag) => $"[{tag}] Trash your top security card and 1 of your opponent's Digimon gets -13000 DP until their turn ends. Then, if you have 1 of fewer security cards, <Recovery +2 (Deck)>.";
  52. bool SharedCanActivateCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  55. }
  56. bool SharedPermanentCondition(Permanent permanent)
  57. {
  58. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  59. }
  60. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  61. {
  62. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  63. player: card.Owner,
  64. destroySecurityCount: 1,
  65. cardEffect: activateClass,
  66. fromTop: true).DestroySecurity());
  67. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedPermanentCondition));
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. selectPermanentEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: SharedPermanentCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: false,
  76. canEndNotMax: false,
  77. selectPermanentCoroutine: SelectPermanentCoroutine,
  78. afterSelectPermanentCoroutine: null,
  79. mode: SelectPermanentEffect.Mode.Custom,
  80. cardEffect: activateClass);
  81. selectPermanentEffect.SetUpCustomMessage(
  82. "Select 1 Digimon that will get DP -13000.",
  83. "The opponent is selecting 1 Digimon that will get DP -13000.");
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  86. {
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  88. targetPermanent: permanent,
  89. changeValue: -13000,
  90. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  91. activateClass: activateClass));
  92. }
  93. if(card.Owner.SecurityCards.Count <= 1)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 2, activateClass).Recovery());
  96. }
  97. }
  98. #endregion
  99. #region On Play
  100. if (timing == EffectTiming.OnEnterFieldAnyone)
  101. {
  102. ActivateClass activateClass = new ActivateClass();
  103. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  104. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  105. cardEffects.Add(activateClass);
  106. bool CanUseCondition(Hashtable hashtable)
  107. {
  108. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  109. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  110. }
  111. }
  112. #endregion
  113. #region When Digivolving
  114. if (timing == EffectTiming.OnEnterFieldAnyone)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  118. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  119. cardEffects.Add(activateClass);
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  123. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  124. }
  125. }
  126. #endregion
  127. #region All Turns When Sec Removed
  128. if (timing == EffectTiming.OnLoseSecurity)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect("Trash Opponent's top security", CanUseCondition, card);
  132. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  133. activateClass.SetHashString("BT24_101_AT_Trash_sec");
  134. cardEffects.Add(activateClass);
  135. string EffectDiscription()
  136. {
  137. return "[All Turns] [Once Per Turn] When your security stack is removed from, trash your opponent's top security card.";
  138. }
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  142. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, (player) => player == card.Owner);
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  151. player: card.Owner.Enemy,
  152. destroySecurityCount: 1,
  153. cardEffect: activateClass,
  154. fromTop: true).DestroySecurity());
  155. }
  156. }
  157. #endregion
  158. #region All Turns Protect TS
  159. if (timing == EffectTiming.WhenRemoveField)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("By trashing top security, card doesn't leave", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  164. activateClass.SetHashString("BT24_101_AT_Protect_TS");
  165. cardEffects.Add(activateClass);
  166. string EffectDiscription()
  167. {
  168. return "[All Turns] [Once Per Turn] When any of your [TS] trait Digimon or Tamers would leave the battle area, by trashing your top security card, they don't leave.";
  169. }
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  173. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  178. && card.Owner.SecurityCards.Count > 0;
  179. }
  180. bool PermanentCondition(Permanent permanent)
  181. {
  182. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  183. && (permanent.TopCard.IsDigimon || permanent.TopCard.IsTamer)
  184. && permanent.TopCard.HasTSTraits;
  185. }
  186. IEnumerator ActivateCoroutine(Hashtable hashtable)
  187. {
  188. CardSource secCard = card.Owner.SecurityCards[0];
  189. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  190. player: card.Owner,
  191. destroySecurityCount: 1,
  192. cardEffect: activateClass,
  193. fromTop: true).DestroySecurity());
  194. if(card.Owner.TrashCards.Contains(secCard))
  195. {
  196. List<Permanent> protectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable)
  197. .Filter(PermanentCondition);
  198. foreach (Permanent permanent in protectedPermanents)
  199. {
  200. permanent.willBeRemoveField = false;
  201. permanent.HideDeleteEffect();
  202. permanent.HideHandBounceEffect();
  203. permanent.HideDeckBounceEffect();
  204. permanent.HideWillRemoveFieldEffect();
  205. }
  206. }
  207. }
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }