BT25_040.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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(card, 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. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  56. selectHandEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanPlayCardCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: 1,
  62. canNoSelect: true,
  63. canEndNotMax: false,
  64. isShowOpponent: true,
  65. selectCardCoroutine: null,
  66. afterSelectCardCoroutine: null,
  67. mode: SelectHandEffect.Mode.PlayForFree,
  68. cardEffect: activateClass);
  69. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  70. }
  71. }
  72. #endregion
  73. #region Ascension
  74. if (timing == EffectTiming.OnDestroyedAnyone)
  75. {
  76. cardEffects.Add(CardEffectFactory.AscensionSelfEffect(isInheritedEffect: false, card: card, condition: null));
  77. }
  78. #endregion
  79. #endregion
  80. #region Shared OP/WD
  81. string SharedEffectName = "By trashing top or bottom security card, 1 opponent digimon gains -8k DP until their turn ends";
  82. 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.";
  83. bool CanSelectPermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  84. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  85. {
  86. bool requiresSelection = card.Owner.SecurityCards.Count >= 2;
  87. if (card.Owner.SecurityCards.Any())
  88. {
  89. #region Setup Location Selection
  90. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  91. if (requiresSelection)
  92. {
  93. selectionElements.Add(new SelectionElement<int>("Top", 1, 0));
  94. selectionElements.Add(new SelectionElement<int>("Bottom", 2, 0));
  95. }
  96. else selectionElements.Add(new SelectionElement<int>("Trash only security card", 1, 0));
  97. selectionElements.Add(new SelectionElement<int>("Don't trash", 3, 1));
  98. string selectPlayerMessage = "Will you trash your security?";
  99. string notSelectPlayerMessage = "The opponent is choosing to trash their security";
  100. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  101. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  102. #endregion
  103. bool doTrash = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  104. bool fromTop = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  105. if (doTrash)
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult(
  108. player: card.Owner,
  109. trashAmount: 1,
  110. activateClass: activateClass,
  111. fromTop: fromTop,
  112. successProcess: SuccessProcess,
  113. failureProcess: null));
  114. IEnumerator SuccessProcess(List<CardSource> cardSources)
  115. {
  116. Permanent selectedPermanent = null;
  117. #region Select Opponent's Digimon
  118. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  119. {
  120. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  121. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition));
  122. selectPermanentEffect.SetUp(
  123. selectPlayer: card.Owner,
  124. canTargetCondition: CanSelectPermanentCondition,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: maxCount,
  128. canNoSelect: false,
  129. canEndNotMax: false,
  130. selectPermanentCoroutine: SelectPermanentCoroutine,
  131. afterSelectPermanentCoroutine: null,
  132. mode: SelectPermanentEffect.Mode.Custom,
  133. cardEffect: activateClass);
  134. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  135. {
  136. selectedPermanent = permanent;
  137. yield return null;
  138. }
  139. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to give -8K DP", "The opponent is selecting a digimon to give -8K DP");
  140. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  141. }
  142. #endregion
  143. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  144. targetPermanent: selectedPermanent,
  145. changeValue: -8000,
  146. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  147. activateClass: activateClass));
  148. }
  149. }
  150. }
  151. }
  152. CardEffectFactory.ActivateClassesForSharedEffects
  153. (ref cardEffects, timing, card,
  154. SharedEffectName,
  155. SharedActivateCoroutine,
  156. SharedEffectDescription,
  157. optional: false,
  158. isSkippable: true,
  159. onPlay: true,
  160. whenDigivolving: true);
  161. #endregion
  162. #region All Turns
  163. if (timing == EffectTiming.OnLoseSecurity)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("1 of your opponent's Digimon gets -4000 DP", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  168. activateClass.SetHashString("BT25_040_WST_AT");
  169. activateClass.SetIsInheritedEffect(true);
  170. cardEffects.Add(activateClass);
  171. string EffectDescription() => "[All Turns] (Once Per Turn) When security stacks are removed from, 1 of your opponent's Digimon gets -4000 DP for the turn.";
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  175. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, _ => true);
  176. }
  177. bool CanActivateCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable hashtable)
  182. {
  183. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  184. {
  185. Permanent selectedPermanent = null;
  186. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  187. selectPermanentEffect.SetUp(
  188. selectPlayer: card.Owner,
  189. canTargetCondition: CanSelectPermanentCondition,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. maxCount: 1,
  193. canNoSelect: false,
  194. canEndNotMax: false,
  195. selectPermanentCoroutine: SelectPermanentCoroutine,
  196. afterSelectPermanentCoroutine: null,
  197. mode: SelectPermanentEffect.Mode.Custom,
  198. cardEffect: activateClass);
  199. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  200. "The opponent is selecting 1 Digimon that will get DP -4000.");
  201. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  202. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  203. {
  204. selectedPermanent = permanent;
  205. yield return null;
  206. }
  207. if (selectedPermanent != null)
  208. {
  209. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  210. targetPermanent: selectedPermanent,
  211. changeValue: -4000,
  212. effectDuration: EffectDuration.UntilEachTurnEnd,
  213. activateClass: activateClass));
  214. }
  215. }
  216. }
  217. }
  218. #endregion
  219. return cardEffects;
  220. }
  221. }
  222. }