BT23_046.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //Rosemon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_046 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 &&
  18. targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  22. card: card, condition: null));
  23. }
  24. #endregion
  25. #region Fortitude
  26. if (timing == EffectTiming.OnDestroyedAnyone)
  27. {
  28. cardEffects.Add(CardEffectFactory.FortitudeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  29. }
  30. #endregion
  31. #region OP/WD Shared
  32. string SharedEffectDiscription(string tag)
  33. {
  34. return $"[{tag}] By suspending 1 Digimon or Tamer, until your opponent's turn ends, 1 of their Digimon or Tamers can't unsuspend.";
  35. }
  36. bool SharedCanSelectDigimonOrTamer(Permanent permanent)
  37. {
  38. return !permanent.IsSuspended
  39. && (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) || CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  40. && (permanent.IsDigimon || permanent.IsTamer);
  41. }
  42. bool SharedCanSelectOpponentsDigimonOrTamer(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  45. (permanent.IsDigimon || permanent.IsTamer);
  46. }
  47. bool SharedCanActivateCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  50. CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectDigimonOrTamer);
  51. }
  52. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  53. {
  54. Permanent suspendedPermanent = null;
  55. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  56. selectPermanentEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: SharedCanSelectDigimonOrTamer,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: 1,
  62. canNoSelect: false,
  63. canEndNotMax: false,
  64. selectPermanentCoroutine: SelectPermanentCoroutine,
  65. afterSelectPermanentCoroutine: null,
  66. mode: SelectPermanentEffect.Mode.Tap,
  67. cardEffect: activateClass);
  68. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer to suspend.", "The opponent is selecting 1 Digimon/Tamer to suspend.");
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  71. {
  72. suspendedPermanent = permanent;
  73. yield return null;
  74. }
  75. if (suspendedPermanent.IsSuspended)
  76. {
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: SharedCanSelectOpponentsDigimonOrTamer,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: 1,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: SelectCantUnsuspendPermanentCoroutine,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer that can't unsuspend.", "The opponent is selecting 1 Digimon/Tamer that can't unsuspend.");
  90. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  91. IEnumerator SelectCantUnsuspendPermanentCoroutine(Permanent permanent)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendUntilOpponentTurnEnd(
  94. targetPermanent: permanent,
  95. activateClass: activateClass
  96. ));
  97. }
  98. }
  99. }
  100. #endregion
  101. #region On Play
  102. if (timing == EffectTiming.OnEnterFieldAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("By suspending 1 digimon/tamer, 1 can't unsuspend", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDiscription("On Play"));
  107. cardEffects.Add(activateClass);
  108. bool CanUseCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  111. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  112. }
  113. }
  114. #endregion
  115. #region When Digivolving
  116. if (timing == EffectTiming.OnEnterFieldAnyone)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect("By suspending 1 digimon/tamer, 1 can't unsuspend", CanUseCondition, card);
  120. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDiscription("When Digivolving"));
  121. cardEffects.Add(activateClass);
  122. bool CanUseCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  125. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  126. }
  127. }
  128. #endregion
  129. #region Opponents Turn - OPT
  130. if (timing == EffectTiming.OnAllyAttack)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Switch attack target", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  135. activateClass.SetHashString("SwitchTarget_BT23-046");
  136. cardEffects.Add(activateClass);
  137. string EffectDiscription()
  138. {
  139. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to 1 of your suspended Digimon with [Vegetation], [Plant] or [Fairy] in any of its traits or the [CS] trait.";
  140. }
  141. bool CanSelectPermanentCondition(Permanent permanent)
  142. {
  143. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  144. permanent.IsSuspended &&
  145. (permanent.TopCard.HasCSTraits ||
  146. permanent.TopCard.ContainsTraits("Vegetation") ||
  147. permanent.TopCard.ContainsTraits("Plant") ||
  148. permanent.TopCard.ContainsTraits("Fairy"));
  149. }
  150. bool PermanentCondition(Permanent permanent)
  151. {
  152. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  153. }
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  157. {
  158. if (CardEffectCommons.IsOpponentTurn(card))
  159. {
  160. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  161. {
  162. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  163. {
  164. return true;
  165. }
  166. }
  167. }
  168. }
  169. return false;
  170. }
  171. bool CanActivateCondition(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.IsExistOnBattleArea(card))
  174. {
  175. if (GManager.instance.attackProcess.IsAttacking)
  176. {
  177. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  178. {
  179. return true;
  180. }
  181. }
  182. }
  183. return false;
  184. }
  185. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  186. {
  187. if (CardEffectCommons.IsExistOnBattleArea(card))
  188. {
  189. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(GManager.instance.attackProcess.AttackingPermanent, card))
  190. {
  191. if (GManager.instance.attackProcess.IsAttacking)
  192. {
  193. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  194. {
  195. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  196. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  197. selectPermanentEffect.SetUp(
  198. selectPlayer: card.Owner,
  199. canTargetCondition: CanSelectPermanentCondition,
  200. canTargetCondition_ByPreSelecetedList: null,
  201. canEndSelectCondition: null,
  202. maxCount: maxCount,
  203. canNoSelect: false,
  204. canEndNotMax: false,
  205. selectPermanentCoroutine: SelectPermanentCoroutine,
  206. afterSelectPermanentCoroutine: null,
  207. mode: SelectPermanentEffect.Mode.Custom,
  208. cardEffect: activateClass);
  209. selectPermanentEffect.SetUpCustomMessage(
  210. "Select 1 Digimon to switch the attack to.",
  211. "The opponent is selecting 1 Digimon to switch the attack to.");
  212. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  213. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  214. {
  215. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  216. activateClass,
  217. false,
  218. permanent));
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. }
  226. #endregion
  227. return cardEffects;
  228. }
  229. }
  230. }