BT20_033.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_033 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alternate Digivolution Requirement
  11. if (timing == EffectTiming.None)
  12. {
  13. static bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4 && targetPermanent.TopCard.EqualsTraits("ACCEL");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. #endregion
  20. #region On Play
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("1 Opponent's Digimon gets can't activate [When Digivolving] and -3000 DP", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[On Play] Until the end of your opponent's turn, 1 of their Digimon can't activate [When Digivolving] effects and gets -3000 DP.";
  30. }
  31. bool IsOpponentsDigimon(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  42. CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon);
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable hashtable)
  45. {
  46. Permanent selectedPermanent = null;
  47. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  48. selectPermanentEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: IsOpponentsDigimon,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. maxCount: 1,
  54. canNoSelect: false,
  55. canEndNotMax: false,
  56. selectPermanentCoroutine: SelectedPermanent,
  57. afterSelectPermanentCoroutine: null,
  58. mode: SelectPermanentEffect.Mode.Custom,
  59. cardEffect: activateClass);
  60. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effect and DP -3000.", "The opponent is selecting 1 Digimon that will gain effect and DP -3000.");
  61. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  62. IEnumerator SelectedPermanent(Permanent target)
  63. {
  64. selectedPermanent = target;
  65. yield return null;
  66. }
  67. if (selectedPermanent != null)
  68. {
  69. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: selectedPermanent, changeValue: -3000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  70. DisableEffectClass invalidationClass = new DisableEffectClass();
  71. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseConditionDebuff, card);
  72. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  73. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => invalidationClass);
  74. bool CanUseConditionDebuff(Hashtable hashtableDebuff)
  75. {
  76. return true;
  77. }
  78. bool InvalidateCondition(ICardEffect cardEffect)
  79. {
  80. if (selectedPermanent.TopCard != null)
  81. {
  82. if (cardEffect != null)
  83. {
  84. if (cardEffect.EffectSourceCard != null)
  85. {
  86. if (isExistOnField(cardEffect.EffectSourceCard))
  87. {
  88. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  89. {
  90. if (cardEffect.IsWhenDigivolving)
  91. {
  92. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  93. {
  94. return true;
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }
  101. }
  102. return false;
  103. }
  104. }
  105. }
  106. }
  107. #endregion
  108. #region When Digivolving
  109. if (timing == EffectTiming.OnEnterFieldAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("1 Opponent's Digimon gets can't activate [When Digivolving] and -3000 DP", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  114. cardEffects.Add(activateClass);
  115. string EffectDiscription()
  116. {
  117. return "[When Digivolving] Until the end of your opponent's turn, 1 of their Digimon can't activate [When Digivolving] effects and gets -3000 DP.";
  118. }
  119. bool IsOpponentsDigimon(Permanent permanent)
  120. {
  121. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  126. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  127. }
  128. bool CanActivateCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  131. CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon);
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable hashtable)
  134. {
  135. Permanent selectedPermanent = null;
  136. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  137. selectPermanentEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: IsOpponentsDigimon,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: 1,
  143. canNoSelect: false,
  144. canEndNotMax: false,
  145. selectPermanentCoroutine: SelectedPermanent,
  146. afterSelectPermanentCoroutine: null,
  147. mode: SelectPermanentEffect.Mode.Custom,
  148. cardEffect: activateClass);
  149. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effect and DP -3000.", "The opponent is selecting 1 Digimon that will gain effect and DP -3000.");
  150. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  151. IEnumerator SelectedPermanent(Permanent target)
  152. {
  153. selectedPermanent = target;
  154. yield return null;
  155. }
  156. if (selectedPermanent != null)
  157. {
  158. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: selectedPermanent, changeValue: -3000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  159. DisableEffectClass invalidationClass = new DisableEffectClass();
  160. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseConditionDebuff, card);
  161. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  162. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => invalidationClass);
  163. bool CanUseConditionDebuff(Hashtable hashtableDebuff)
  164. {
  165. return true;
  166. }
  167. bool InvalidateCondition(ICardEffect cardEffect)
  168. {
  169. if (selectedPermanent.TopCard != null)
  170. {
  171. if (cardEffect != null)
  172. {
  173. if (cardEffect.EffectSourceCard != null)
  174. {
  175. if (isExistOnField(cardEffect.EffectSourceCard))
  176. {
  177. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  178. {
  179. if (cardEffect.IsWhenDigivolving)
  180. {
  181. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  182. {
  183. return true;
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. return false;
  192. }
  193. }
  194. }
  195. }
  196. #endregion
  197. #region Redirect - ESS
  198. if (timing == EffectTiming.OnAllyAttack)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("You may change the attack target to this Digimon.", CanUseCondition, card);
  202. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  203. activateClass.SetHashString("Redirect_BT20-033");
  204. activateClass.SetIsInheritedEffect(true);
  205. cardEffects.Add(activateClass);
  206. string EffectDiscription()
  207. {
  208. return "[Opponent's Turn] [Once Per Turn] When any of your opponent's Digimon attack, you may change the attack target to this Digimon.";
  209. }
  210. bool IsOpponentDigimon(Permanent permanent)
  211. {
  212. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  213. }
  214. bool IsThisDigimon(Permanent permanent)
  215. {
  216. return permanent == card.PermanentOfThisCard();
  217. }
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.IsOpponentTurn(card) &&
  221. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  222. }
  223. bool CanActivateCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable hashtable)
  228. {
  229. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  230. selectPermanentEffect.SetUp(
  231. selectPlayer: card.Owner,
  232. canTargetCondition: IsThisDigimon,
  233. canTargetCondition_ByPreSelecetedList: null,
  234. canEndSelectCondition: null,
  235. maxCount: 1,
  236. canNoSelect: false,
  237. canEndNotMax: false,
  238. selectPermanentCoroutine: SelectPermanentCoroutine,
  239. afterSelectPermanentCoroutine: null,
  240. mode: SelectPermanentEffect.Mode.Custom,
  241. cardEffect: activateClass);
  242. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.",
  243. "The opponent is selecting 1 Digimon to attack.");
  244. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  245. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  246. {
  247. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  248. activateClass,
  249. false,
  250. permanent));
  251. }
  252. }
  253. }
  254. #endregion
  255. return cardEffects;
  256. }
  257. }
  258. }