BT25_055.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Deramon
  4. namespace DCGO.CardEffects.BT25
  5. {
  6. public class BT25_055 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Digivolve Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasTSTraits;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 4));
  19. }
  20. #endregion
  21. #region Shared OP / WD
  22. string SharedEffectName = "May suspend 1 Digimon, then if 2 or more suspended, 1 of your Digimon may unsuspend";
  23. CardEffectFactory.ActivateClassesForSharedEffects
  24. (ref cardEffects, timing, card,
  25. SharedEffectName,
  26. SharedActivateCoroutine,
  27. SharedEffectDescription,
  28. optional: false,
  29. isSkippable: true,
  30. onPlay: true,
  31. whenDigivolving: true);
  32. string SharedEffectDescription(string tag) => $"[{tag}] You may suspend 1 Digimon. Then, if there are 2 or more suspended Digimon, 1 of your Digimon may unsuspend.";
  33. bool CanSuspendPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  36. && !permanent.IsSuspended
  37. && permanent.CanSuspend;
  38. }
  39. bool SuspendedDigimon(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  42. && permanent.IsSuspended;
  43. }
  44. bool CanUnsuspendDigimon(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  47. && permanent.IsSuspended
  48. && permanent.CanUnsuspend;
  49. }
  50. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  51. {
  52. if (CardEffectCommons.HasMatchConditionPermanent(CanSuspendPermanentCondition))
  53. {
  54. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  55. selectPermanentEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: CanSuspendPermanentCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: 1,
  61. canNoSelect: true,
  62. canEndNotMax: false,
  63. selectPermanentCoroutine: null,
  64. afterSelectPermanentCoroutine: null,
  65. mode: SelectPermanentEffect.Mode.Tap,
  66. cardEffect: activateClass);
  67. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to Suspend.", "The opponent is selecting 1 Digimon to Suspend.");
  68. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  69. }
  70. if (CardEffectCommons.MatchConditionPermanentCount(SuspendedDigimon) >= 2 && CardEffectCommons.HasMatchConditionPermanent(CanUnsuspendDigimon))
  71. {
  72. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  73. selectPermanentEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: CanUnsuspendDigimon,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: 1,
  79. canNoSelect: true,
  80. canEndNotMax: false,
  81. selectPermanentCoroutine: null,
  82. afterSelectPermanentCoroutine: null,
  83. mode: SelectPermanentEffect.Mode.UnTap,
  84. cardEffect: activateClass);
  85. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to unsuspend", "Opponent is selecting 1 Digimon to unsuspend");
  86. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  87. }
  88. }
  89. #endregion
  90. #region All turns - OPT
  91. if (timing == EffectTiming.OnTappedAnyone)
  92. {
  93. ActivateClass activateClass = new ActivateClass();
  94. activateClass.SetUpICardEffect("May play 1 4K DP or lower traited Digimon", CanUseCondition, card);
  95. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  96. activateClass.SetIsSkippable(true);
  97. activateClass.SetHashString("BT25_055_AT");
  98. cardEffects.Add(activateClass);
  99. string EffectDescription()
  100. {
  101. return "[All Turns] [Once Per Turn] When this Digimon suspends, you may play 1 4000 DP or lower Digimon card with [Vegetation], [Plant], [Avian] or [Bird] in any of its traits or the [TS] trait from your hand without paying the cost.";
  102. }
  103. bool CanUseCondition(Hashtable hashtable)
  104. {
  105. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  106. && CardEffectCommons.CanTriggerWhenSelfPermanentSuspends(hashtable, card);
  107. }
  108. bool CanActivateCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  111. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  112. }
  113. bool CanSelectCardCondition(CardSource cardSource)
  114. {
  115. return cardSource.IsDigimon
  116. && cardSource.HasDP
  117. && cardSource.CardDP <= 4000
  118. && (cardSource.ContainsTraits("Vegetation")
  119. || cardSource.ContainsTraits("Plant")
  120. || cardSource.ContainsTraits("Avian")
  121. || cardSource.ContainsTraits("Bird")
  122. || cardSource.HasTSTraits);
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable hashtable)
  125. {
  126. bool Used = false;
  127. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  128. {
  129. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  130. {
  131. if (cardSources.Count > 0)
  132. {
  133. Used = true;
  134. }
  135. yield return null;
  136. }
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  138. canTargetCondition: CanSelectCardCondition,
  139. SelectCardEffect.Root.Hand,
  140. activateClass,
  141. payCost: false,
  142. afterSelectCardCoroutine: AfterSelectCardCoroutine
  143. ));
  144. }
  145. if (!Used)
  146. {
  147. activateClass.RemoveUse();
  148. }
  149. }
  150. }
  151. #endregion
  152. #region Inherited
  153. if (timing == EffectTiming.OnAllyAttack)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect("Change attack target", CanUseCondition, card);
  157. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  158. activateClass.SetHashString("BT25_055_Inherited");
  159. activateClass.SetIsSkippable(true);
  160. activateClass.SetIsInheritedEffect(true);
  161. cardEffects.Add(activateClass);
  162. string EffectDescription()
  163. {
  164. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you can change the attack target to 1 of your suspended Digimon.";
  165. }
  166. bool CanSelectRedirectCondition(Permanent permanent)
  167. {
  168. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  169. && permanent.IsSuspended;
  170. }
  171. bool PermanentCondition(Permanent permanent)
  172. {
  173. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  174. }
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  178. && CardEffectCommons.IsOpponentTurn(card)
  179. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  180. }
  181. bool CanActivateCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleArea(card)
  184. && CardEffectCommons.HasMatchConditionPermanent(CanSelectRedirectCondition)
  185. && GManager.instance.attackProcess.AttackingPermanent != null
  186. && GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  189. {
  190. bool Used = false;
  191. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  192. selectPermanentEffect.SetUp(
  193. selectPlayer: card.Owner,
  194. canTargetCondition: CanSelectRedirectCondition,
  195. canTargetCondition_ByPreSelecetedList: null,
  196. canEndSelectCondition: null,
  197. maxCount: 1,
  198. canNoSelect: true,
  199. canEndNotMax: false,
  200. selectPermanentCoroutine: SelectPermanentCoroutine,
  201. afterSelectPermanentCoroutine: null,
  202. mode: SelectPermanentEffect.Mode.Custom,
  203. cardEffect: activateClass);
  204. selectPermanentEffect.SetUpCustomMessage(
  205. "Select 1 Digimon to switch the attack to.",
  206. "The opponent is selecting 1 Digimon to switch the attack to.");
  207. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  208. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  209. {
  210. Used = true;
  211. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  212. activateClass,
  213. false,
  214. permanent));
  215. }
  216. if (!Used)
  217. {
  218. activateClass.RemoveUse();
  219. }
  220. }
  221. }
  222. #endregion
  223. return cardEffects;
  224. }
  225. }
  226. }