BT25_028.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Dianamon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_028 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.HasTSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 5));
  21. }
  22. #endregion
  23. #region Reduce Play Cost
  24. if (timing == EffectTiming.None)
  25. {
  26. bool Condition()
  27. {
  28. return CardEffectCommons.HasMatchConditionPermanent(Level6EnemyDigimon);
  29. }
  30. bool Level6EnemyDigimon(Permanent permanent)
  31. {
  32. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  33. && permanent.TopCard.HasLevel
  34. && permanent.Level >= 6;
  35. }
  36. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  37. }
  38. #endregion
  39. #region Shared OP / WD
  40. string SharedEffectName = "None of your opponent's Digimon with 1 or less Digivolution cards can suspend until end of their turn. Delete 1 of their unsuspended Digimon";
  41. string SharedEffectDescription(string tag)
  42. => $"[{tag}] None of your opponent's Digimon with 1 or fewer digivolution cards can suspend until their turn ends. Then, delete 1 of your opponent's unsuspended Digimon.";
  43. bool CanDeleteCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  46. && !permanent.IsSuspended;
  47. }
  48. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  49. {
  50. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  51. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  52. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  53. card.Owner.UntilOpponentTurnEndEffects.Add((_timing) => canNotSuspendClass);
  54. bool CanUseCondition1(Hashtable hashtable)
  55. {
  56. return true;
  57. }
  58. bool PermanentCondition(Permanent permanent)
  59. {
  60. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  61. && permanent.DigivolutionCards.Count <= 1
  62. && !permanent.TopCard.CanNotBeAffected(activateClass);
  63. }
  64. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanDeleteCondition))
  65. {
  66. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanDeleteCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: 1,
  73. canNoSelect: false,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: null,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Destroy,
  78. cardEffect: activateClass);
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. }
  81. }
  82. CardEffectFactory.ActivateClassesForSharedEffects
  83. (ref cardEffects, timing, card,
  84. SharedEffectName,
  85. SharedActivateCoroutine,
  86. SharedEffectDescription,
  87. optional: false,
  88. onPlay: true,
  89. whenDigivolving: true);
  90. #endregion
  91. #region All Turns
  92. if (timing == EffectTiming.OnEnterFieldAnyone)
  93. {
  94. ActivateClass activateClass = new ActivateClass();
  95. activateClass.SetUpICardEffect("May trash 4 digivolution cards and then DNA into GraceNovamon", CanUseCondition, card);
  96. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  97. activateClass.SetIsSkippable(true);
  98. activateClass.SetHashString("BT25_028_AT");
  99. cardEffects.Add(activateClass);
  100. string EffectDescription()
  101. => "[All Turns] [Once Per Turn] When any Digimon are played or digivolve, you may trash any 4 digivolution cards from your opponent's Digimon, Then, 2 of your Digimon may DNA digivolve into [GraceNovamon] in the hand.";
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleArea(card)
  105. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsDigimonCondition)
  106. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, IsDigimonCondition));
  107. }
  108. bool IsDigimonCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  109. bool IsOpponentsDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  110. bool CanSelectDNACardCondition(CardSource cardSource)
  111. {
  112. return cardSource.IsDigimon
  113. && cardSource.CanPlayJogress(true)
  114. && cardSource.EqualsCardName("GraceNovamon");
  115. }
  116. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  117. IEnumerator ActivateCoroutine(Hashtable hashtable)
  118. {
  119. bool executed = false;
  120. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  123. permanentCondition: IsOpponentsDigimon,
  124. cardCondition: _ => true,
  125. maxCount: 4,
  126. canNoTrash: true,
  127. isFromOnly1Permanent: false,
  128. activateClass: activateClass,
  129. afterSelectionCoroutine: AfterSelectCoroutine
  130. ));
  131. IEnumerator AfterSelectCoroutine(Permanent permanent, List<CardSource> cardSources)
  132. {
  133. if (cardSources.Count > 0)
  134. executed = true;
  135. yield return null;
  136. }
  137. }
  138. yield return ContinuousController.instance.StartCoroutine(
  139. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  140. CanSelectDNACardCondition,
  141. payCost: true,
  142. isHand: true,
  143. activateClass,
  144. successProcess: SuccessProcess
  145. ));
  146. IEnumerator SuccessProcess(CardSource cardSource)
  147. {
  148. executed = true;
  149. yield return null;
  150. }
  151. if (!executed) activateClass.RemoveUse();
  152. }
  153. }
  154. #endregion
  155. #region When Attacking ESS
  156. if (timing == EffectTiming.OnAllyAttack)
  157. {
  158. ActivateClass activateClass = new ActivateClass();
  159. activateClass.SetUpICardEffect("1 of your opponent's Digimon or Tamers can't suspend", CanUseCondition, card);
  160. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  161. activateClass.SetIsInheritedEffect(true);
  162. activateClass.SetHashString("BT25_028_WA_ESS");
  163. cardEffects.Add(activateClass);
  164. string EffectDescription()
  165. => "[When Attacking] [Once Per Turn] 1 of your opponent's Digimon or Tamers can't suspend until their turn ends.";
  166. bool CanUseCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.IsExistOnBattleArea(card)
  169. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  170. }
  171. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  172. {
  173. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  174. && (permanent.IsDigimon || permanent.IsTamer);
  175. }
  176. bool CanActivateCondition(Hashtable hashtable)
  177. {
  178. return CardEffectCommons.IsExistOnBattleArea(card);
  179. }
  180. IEnumerator ActivateCoroutine(Hashtable hashtable)
  181. {
  182. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentPermanentCondition))
  183. {
  184. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  185. selectPermanentEffect.SetUp(
  186. selectPlayer: card.Owner,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canTargetCondition: CanSelectOpponentPermanentCondition,
  189. canEndSelectCondition: null,
  190. maxCount: 1,
  191. canNoSelect: false,
  192. canEndNotMax: false,
  193. selectPermanentCoroutine: SelectPermanentCoroutine,
  194. afterSelectPermanentCoroutine: null,
  195. mode: SelectPermanentEffect.Mode.Custom,
  196. cardEffect: activateClass);
  197. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer that will be unable to suspend.",
  198. "The opponent is selecting 1 Digimon/Tamer that will be unable to suspend.");
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. }
  201. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  202. {
  203. Permanent selectedPermanent = permanent;
  204. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  205. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCanNotSuspendCondition, card);
  206. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCanNotSuspendCondition);
  207. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => canNotSuspendClass);
  208. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  209. {
  210. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  211. .GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  212. }
  213. bool CanUseCanNotSuspendCondition(Hashtable hashtableCanNotSuspend)
  214. {
  215. return selectedPermanent.TopCard != null
  216. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  217. }
  218. bool PermanentCanNotSuspendCondition(Permanent permanentCanNotSuspend)
  219. {
  220. return permanentCanNotSuspend == selectedPermanent;
  221. }
  222. }
  223. }
  224. }
  225. #endregion
  226. return cardEffects;
  227. }
  228. }
  229. }