BT16_028.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_028 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardNames.Contains("Paildramon") || targetPermanent.TopCard.CardNames.Contains("Dinobeemon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 3,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null)
  24. );
  25. }
  26. #endregion
  27. #region When Digivolving
  28. if (timing == EffectTiming.OnEnterFieldAnyone)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect("1 of your opponent's Digimon/Tamer can't unsuspend.", CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "[When Digivolving] 1 of your opponent's Digimon or Tamer can't unsuspend until the end of their turn. Then, by suspending 1 of their Digimon or Tamers, unsuspend 1 of your Digimon.";
  37. }
  38. bool CanSelectOpponentsDigimon(Permanent permanent)
  39. {
  40. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  41. {
  42. return permanent.IsDigimon || permanent.IsTamer;
  43. }
  44. return false;
  45. }
  46. bool CanSelectOpponentsDigimonToSuspend(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  49. {
  50. if (permanent.IsDigimon || permanent.IsTamer)
  51. {
  52. if (!permanent.IsSuspended)
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanSelectYourSuspendedDigimon(Permanent permanent)
  61. {
  62. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  63. {
  64. if (permanent.IsDigimon && permanent.IsSuspended)
  65. {
  66. return true;
  67. }
  68. }
  69. return false;
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  74. && CardEffectCommons.IsExistOnBattleArea(card);
  75. }
  76. bool CanActivateCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleArea(card);
  79. }
  80. IEnumerator ActivateCoroutine(Hashtable hashtable)
  81. {
  82. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentsDigimon))
  83. {
  84. Permanent selectedPermanent = null;
  85. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  86. selectPermanentEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canTargetCondition: CanSelectOpponentsDigimon,
  90. canEndSelectCondition: null,
  91. maxCount: 1,
  92. canNoSelect: false,
  93. canEndNotMax: false,
  94. selectPermanentCoroutine: SelectPermanentCoroutine,
  95. afterSelectPermanentCoroutine: null,
  96. mode: SelectPermanentEffect.Mode.Custom,
  97. cardEffect: activateClass);
  98. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer to not unsuspend.", "The opponent is selecting 1 Digimon/Tamer to not unsuspend.");
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  101. {
  102. selectedPermanent = permanent;
  103. yield return null;
  104. }
  105. if (selectedPermanent != null)
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  108. targetPermanent: selectedPermanent,
  109. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  110. activateClass: activateClass,
  111. condition: null,
  112. effectName: "Your Digimon can't unsuspend"));
  113. }
  114. }
  115. if (CardEffectCommons.IsExistOnBattleArea(card))
  116. {
  117. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentsDigimonToSuspend))
  118. {
  119. Permanent suspendedPermanent = null;
  120. SelectPermanentEffect selectSuspendEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  121. selectSuspendEffect.SetUp(
  122. selectPlayer: card.Owner,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canTargetCondition: CanSelectOpponentsDigimonToSuspend,
  125. canEndSelectCondition: null,
  126. maxCount: 1,
  127. canNoSelect: true,
  128. canEndNotMax: false,
  129. selectPermanentCoroutine: SelectSuspendCoroutine,
  130. afterSelectPermanentCoroutine: null,
  131. mode: SelectPermanentEffect.Mode.Tap,
  132. cardEffect: activateClass);
  133. selectSuspendEffect.SetUpCustomMessage("Select 1 Digimon/Tamer to suspend.", "The opponent is selecting 1 Digimon/Tamer to suspend.");
  134. yield return ContinuousController.instance.StartCoroutine(selectSuspendEffect.Activate());
  135. IEnumerator SelectSuspendCoroutine(Permanent permanent)
  136. {
  137. suspendedPermanent = permanent;
  138. yield return null;
  139. }
  140. if (suspendedPermanent != null)
  141. {
  142. SelectPermanentEffect selectUnsuspendEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  143. selectSuspendEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canTargetCondition: CanSelectYourSuspendedDigimon,
  147. canEndSelectCondition: null,
  148. maxCount: 1,
  149. canNoSelect: false,
  150. canEndNotMax: false,
  151. selectPermanentCoroutine: SelectSuspendCoroutine,
  152. afterSelectPermanentCoroutine: null,
  153. mode: SelectPermanentEffect.Mode.UnTap,
  154. cardEffect: activateClass);
  155. selectSuspendEffect.SetUpCustomMessage("Select 1 Digimon to unsuspend.", "The opponent is selecting 1 Digimon to unsuspend.");
  156. yield return ContinuousController.instance.StartCoroutine(selectSuspendEffect.Activate());
  157. }
  158. }
  159. }
  160. }
  161. }
  162. #endregion
  163. #region All Turns - When an effect plays/digivolves
  164. if (timing == EffectTiming.OnEnterFieldAnyone)
  165. {
  166. ActivateClass activateClass = new ActivateClass();
  167. activateClass.SetUpICardEffect("Digivolve into [Imperialdramon: Fighter Mode]", CanUseCondition, card);
  168. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  169. cardEffects.Add(activateClass);
  170. string EffectDiscription()
  171. {
  172. return "[All Turns] When an effect plays or digivolves an opponent's Digimon, if you have a Tamer, this Digimon may digivolve into [Imperialdramon: Fighter Mode] in your hand without paying the cost.";
  173. }
  174. bool IsOpponentDigimon(Permanent permanent)
  175. {
  176. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  177. }
  178. bool HasTamer(Permanent permanent)
  179. {
  180. if (permanent.IsTamer)
  181. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  182. return false;
  183. }
  184. bool HasFighterMode(CardSource cardSource)
  185. {
  186. return cardSource.CardNames.Contains("Imperialdramon: Fighter Mode") || cardSource.CardNames.Contains("Imperialdramon:FighterMode");
  187. }
  188. bool CanUseCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  191. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsOpponentDigimon)
  192. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, IsOpponentDigimon))
  193. && CardEffectCommons.IsByEffect(hashtable, null)
  194. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasTamer)
  195. && card.Owner.HandCards.Count(HasFighterMode) >= 1;
  196. }
  197. bool CanActivateCondition(Hashtable hashtable)
  198. {
  199. return CardEffectCommons.IsExistOnBattleArea(card);
  200. }
  201. IEnumerator ActivateCoroutine(Hashtable hashtable)
  202. {
  203. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  204. targetPermanent: card.PermanentOfThisCard(),
  205. cardCondition: HasFighterMode,
  206. payCost: false,
  207. reduceCostTuple: null,
  208. fixedCostTuple: null,
  209. ignoreDigivolutionRequirementFixedCost: -1,
  210. isHand: true,
  211. activateClass: activateClass,
  212. successProcess: null,
  213. ignoreSelection: true));
  214. }
  215. }
  216. #endregion
  217. return cardEffects;
  218. }
  219. }
  220. }