BT25_040.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // MagnaAngemon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_040 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. bool Condition(Permanent permanent)
  18. {
  19. return permanent.TopCard.HasTSTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: Condition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region When Trashed
  25. if (timing == EffectTiming.OnDiscardSecurity)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Angel] or [Iliad] card", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  30. activateClass.SetIsSkippable(true);
  31. cardEffects.Add(activateClass);
  32. string EffectDescription()
  33. {
  34. return "When effects trashing this card from the security stack, you may play 1 level 4 or lower [Angel] or [Iliad] trait card from your hand without paying the cost.";
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerOnTrashSelfSecurity(hashtable, cardEffect => cardEffect != null, card);
  39. }
  40. bool CanPlayCardCondition(CardSource cardSource)
  41. {
  42. return cardSource.HasPlayCost
  43. && cardSource.HasLevel
  44. && cardSource.Level <= 4
  45. && (cardSource.EqualsTraits("Angel") || cardSource.EqualsTraits("Iliad"))
  46. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnTrash(card)
  51. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayCardCondition);
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  56. canTargetCondition: CanPlayCardCondition,
  57. SelectCardEffect.Root.Hand,
  58. activateClass,
  59. payCost: false
  60. ));
  61. }
  62. }
  63. #endregion
  64. #region Ascension
  65. if (timing == EffectTiming.OnDestroyedAnyone)
  66. {
  67. cardEffects.Add(CardEffectFactory.AscensionSelfEffect(isInheritedEffect: false, card: card, condition: null));
  68. }
  69. #endregion
  70. #endregion
  71. #region Shared OP/WD
  72. string SharedEffectName = "By trashing top or bottom security card, 1 opponent digimon gains -8k DP until their turn ends";
  73. string SharedEffectDescription(string tag) => $"[{tag}] By trashing your top or bottom security card, 1 of your opponent's Digimon gets -8000 DP until their turn ends.";
  74. bool CanSelectPermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  75. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  76. {
  77. bool requiresSelection = card.Owner.SecurityCards.Count >= 2;
  78. if (card.Owner.SecurityCards.Any())
  79. {
  80. #region Setup Location Selection
  81. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  82. if (requiresSelection)
  83. {
  84. selectionElements.Add(new SelectionElement<int>("Top", 1, 0));
  85. selectionElements.Add(new SelectionElement<int>("Bottom", 2, 0));
  86. }
  87. else selectionElements.Add(new SelectionElement<int>("Trash only security card", 1, 0));
  88. selectionElements.Add(new SelectionElement<int>("Don't trash", 3, 1));
  89. string selectPlayerMessage = "Will you trash your security?";
  90. string notSelectPlayerMessage = "The opponent is choosing to trash their security";
  91. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  92. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  93. #endregion
  94. bool doTrash = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  95. bool fromTop = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  96. if (doTrash)
  97. {
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult(
  99. player: card.Owner,
  100. trashAmount: 1,
  101. activateClass: activateClass,
  102. fromTop: fromTop,
  103. successProcess: SuccessProcess,
  104. failureProcess: null));
  105. IEnumerator SuccessProcess(List<CardSource> cardSources)
  106. {
  107. Permanent selectedPermanent = null;
  108. #region Select Opponent's Digimon
  109. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  110. {
  111. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  112. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition));
  113. selectPermanentEffect.SetUp(
  114. selectPlayer: card.Owner,
  115. canTargetCondition: CanSelectPermanentCondition,
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. maxCount: maxCount,
  119. canNoSelect: false,
  120. canEndNotMax: false,
  121. selectPermanentCoroutine: SelectPermanentCoroutine,
  122. afterSelectPermanentCoroutine: null,
  123. mode: SelectPermanentEffect.Mode.Custom,
  124. cardEffect: activateClass);
  125. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  126. {
  127. selectedPermanent = permanent;
  128. yield return null;
  129. }
  130. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to give -8K DP", "The opponent is selecting a digimon to give -8K DP");
  131. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  132. }
  133. #endregion
  134. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  135. targetPermanent: selectedPermanent,
  136. changeValue: -8000,
  137. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  138. activateClass: activateClass));
  139. }
  140. }
  141. }
  142. }
  143. CardEffectFactory.ActivateClassesForSharedEffects
  144. (ref cardEffects, timing, card,
  145. SharedEffectName,
  146. SharedActivateCoroutine,
  147. SharedEffectDescription,
  148. optional: false,
  149. isSkippable: true,
  150. onPlay: true,
  151. whenDigivolving: true);
  152. #endregion
  153. #region All Turns
  154. if (timing == EffectTiming.OnLoseSecurity)
  155. {
  156. ActivateClass activateClass = new ActivateClass();
  157. activateClass.SetUpICardEffect("1 of your opponent's Digimon gets -4000 DP", CanUseCondition, card);
  158. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  159. activateClass.SetHashString("BT25_040_WST_AT");
  160. activateClass.SetIsInheritedEffect(true);
  161. cardEffects.Add(activateClass);
  162. string EffectDescription() => "[All Turns] [Once Per Turn] When your security stack is removed from, 1 of your opponent's Digimon gets -4000 DP for the turn.";
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  166. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner);
  167. }
  168. bool CanActivateCondition(Hashtable hashtable)
  169. {
  170. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable hashtable)
  173. {
  174. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  175. {
  176. Permanent selectedPermanent = null;
  177. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  178. selectPermanentEffect.SetUp(
  179. selectPlayer: card.Owner,
  180. canTargetCondition: CanSelectPermanentCondition,
  181. canTargetCondition_ByPreSelecetedList: null,
  182. canEndSelectCondition: null,
  183. maxCount: 1,
  184. canNoSelect: false,
  185. canEndNotMax: false,
  186. selectPermanentCoroutine: SelectPermanentCoroutine,
  187. afterSelectPermanentCoroutine: null,
  188. mode: SelectPermanentEffect.Mode.Custom,
  189. cardEffect: activateClass);
  190. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  191. "The opponent is selecting 1 Digimon that will get DP -4000.");
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  194. {
  195. selectedPermanent = permanent;
  196. yield return null;
  197. }
  198. if (selectedPermanent != null)
  199. {
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  201. targetPermanent: selectedPermanent,
  202. changeValue: -4000,
  203. effectDuration: EffectDuration.UntilEachTurnEnd,
  204. activateClass: activateClass));
  205. }
  206. }
  207. }
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }