BT25_055.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  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. List<CardSource> selectedCards = new List<CardSource>();
  130. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  131. selectHandEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: CanSelectCardCondition,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: 1,
  137. canNoSelect: true,
  138. canEndNotMax: false,
  139. isShowOpponent: true,
  140. selectCardCoroutine: null,
  141. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  142. mode: SelectHandEffect.Mode.PlayForFree,
  143. cardEffect: activateClass);
  144. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  145. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  146. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  147. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  148. {
  149. if (cardSources.Count > 0)
  150. {
  151. Used = true;
  152. }
  153. return null;
  154. }
  155. }
  156. if (!Used)
  157. {
  158. activateClass.RemoveUse();
  159. }
  160. }
  161. }
  162. #endregion
  163. #region Inherited
  164. if (timing == EffectTiming.OnAllyAttack)
  165. {
  166. ActivateClass activateClass = new ActivateClass();
  167. activateClass.SetUpICardEffect("Change attack target", CanUseCondition, card);
  168. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  169. activateClass.SetHashString("BT25_055_Inherited");
  170. activateClass.SetIsSkippable(true);
  171. activateClass.SetIsInheritedEffect(true);
  172. cardEffects.Add(activateClass);
  173. string EffectDescription()
  174. {
  175. 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.";
  176. }
  177. bool CanSelectRedirectCondition(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  180. && permanent.IsSuspended;
  181. }
  182. bool PermanentCondition(Permanent permanent)
  183. {
  184. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  185. }
  186. bool CanUseCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  189. && CardEffectCommons.IsOpponentTurn(card)
  190. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  191. }
  192. bool CanActivateCondition(Hashtable hashtable)
  193. {
  194. return CardEffectCommons.IsExistOnBattleArea(card)
  195. && CardEffectCommons.HasMatchConditionPermanent(CanSelectRedirectCondition)
  196. && GManager.instance.attackProcess.AttackingPermanent != null
  197. && GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  198. }
  199. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  200. {
  201. bool Used = false;
  202. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  203. selectPermanentEffect.SetUp(
  204. selectPlayer: card.Owner,
  205. canTargetCondition: CanSelectRedirectCondition,
  206. canTargetCondition_ByPreSelecetedList: null,
  207. canEndSelectCondition: null,
  208. maxCount: 1,
  209. canNoSelect: true,
  210. canEndNotMax: false,
  211. selectPermanentCoroutine: SelectPermanentCoroutine,
  212. afterSelectPermanentCoroutine: null,
  213. mode: SelectPermanentEffect.Mode.Custom,
  214. cardEffect: activateClass);
  215. selectPermanentEffect.SetUpCustomMessage(
  216. "Select 1 Digimon to switch the attack to.",
  217. "The opponent is selecting 1 Digimon to switch the attack to.");
  218. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  219. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  220. {
  221. Used = true;
  222. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  223. activateClass,
  224. false,
  225. permanent));
  226. }
  227. if (!Used)
  228. {
  229. activateClass.RemoveUse();
  230. }
  231. }
  232. }
  233. #endregion
  234. return cardEffects;
  235. }
  236. }
  237. }