EX8_023.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_023 : 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 Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("Ice-Snow") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region Iceclad
  22. if (timing == EffectTiming.None)
  23. {
  24. cardEffects.Add(CardEffectFactory.IcecladSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  25. }
  26. #endregion
  27. #region On Play
  28. if (timing == EffectTiming.OnEnterFieldAnyone)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect("Trash any 2 sources of opponents digimon. Then, 1 of your opponent's sourceless Digimon can't suspend or activate [When Digivolving]", CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "[On Play] Trash any 2 digivolution cards from your opponent's Digimon. Then, 1 of your opponent's Digimon with no digivolution cards can't suspend or activate [When Digivolving] effects until the end of their turn.";
  37. }
  38. bool OpponentsDigimon(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  41. }
  42. bool CanSelectCardCondition(CardSource cardSource)
  43. {
  44. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  45. }
  46. bool OpponentsDigimonWithoutSources(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  49. permanent.DigivolutionCards.Count == 0;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  58. CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon);
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable hashtable)
  61. {
  62. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  63. permanentCondition: OpponentsDigimon,
  64. cardCondition: CanSelectCardCondition,
  65. maxCount: 2,
  66. canNoTrash: false,
  67. isFromOnly1Permanent: false,
  68. activateClass: activateClass
  69. ));
  70. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimonWithoutSources))
  71. {
  72. Permanent selectedPermanent = null;
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: OpponentsDigimonWithoutSources,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effects.", "The opponent is selecting 1 Digimon that will gain effects.");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  89. {
  90. if (permanent != null)
  91. selectedPermanent = permanent;
  92. yield return null;
  93. }
  94. if (selectedPermanent != null)
  95. {
  96. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  97. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  98. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  99. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  100. DisableEffectClass invalidationClass = new DisableEffectClass();
  101. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseCondition1, card);
  102. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  103. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => invalidationClass);
  104. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  105. {
  106. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  107. }
  108. bool CanUseCondition1(Hashtable hashtable)
  109. {
  110. if (selectedPermanent.TopCard != null)
  111. {
  112. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. bool PermanentCondition(Permanent permanent)
  120. {
  121. if (permanent == selectedPermanent)
  122. {
  123. return true;
  124. }
  125. return false;
  126. }
  127. bool InvalidateCondition(ICardEffect cardEffect)
  128. {
  129. if (cardEffect != null)
  130. {
  131. if (cardEffect is ActivateICardEffect)
  132. {
  133. if (cardEffect.EffectSourceCard != null)
  134. {
  135. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(cardEffect.EffectSourceCard.PermanentOfThisCard(), card))
  136. {
  137. if(cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  138. {
  139. if (!cardEffect.EffectSourceCard.PermanentOfThisCard().TopCard.CanNotBeAffected(invalidationClass))
  140. {
  141. if (cardEffect.IsWhenDigivolving)
  142. {
  143. return true;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. return false;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. #endregion
  158. #region When Digivolving
  159. if (timing == EffectTiming.OnEnterFieldAnyone)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("Trash bottom 2 sources of 1 opponents digimon. Then, 1 of your opponent's Digimon can't suspend or activate [When Digivolving]", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  164. cardEffects.Add(activateClass);
  165. string EffectDiscription()
  166. {
  167. return "[When Digivolving] Trash any 2 digivolution cards from your opponent's Digimon. Then, 1 of your opponent's Digimon with no digivolution cards can't suspend or activate [When Digivolving] effects until the end of their turn.";
  168. }
  169. bool OpponentsDigimon(Permanent permanent)
  170. {
  171. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  172. }
  173. bool CanSelectCardCondition(CardSource cardSource)
  174. {
  175. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  176. }
  177. bool OpponentsDigimonWithoutSources(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  180. permanent.DigivolutionCards.Count == 0;
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  185. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  190. CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon);
  191. }
  192. IEnumerator ActivateCoroutine(Hashtable hashtable)
  193. {
  194. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  195. permanentCondition: OpponentsDigimon,
  196. cardCondition: CanSelectCardCondition,
  197. maxCount: 2,
  198. canNoTrash: false,
  199. isFromOnly1Permanent: false,
  200. activateClass: activateClass
  201. ));
  202. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimonWithoutSources))
  203. {
  204. Permanent selectedPermanent = null;
  205. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  206. selectPermanentEffect.SetUp(
  207. selectPlayer: card.Owner,
  208. canTargetCondition: OpponentsDigimonWithoutSources,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. maxCount: 1,
  212. canNoSelect: false,
  213. canEndNotMax: false,
  214. selectPermanentCoroutine: SelectPermanentCoroutine,
  215. afterSelectPermanentCoroutine: null,
  216. mode: SelectPermanentEffect.Mode.Custom,
  217. cardEffect: activateClass);
  218. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effects.", "The opponent is selecting 1 Digimon that will gain effects.");
  219. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  220. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  221. {
  222. if (permanent != null)
  223. selectedPermanent = permanent;
  224. yield return null;
  225. }
  226. if(selectedPermanent != null)
  227. {
  228. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  229. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  230. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  231. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  232. DisableEffectClass invalidationClass = new DisableEffectClass();
  233. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseCondition, card);
  234. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  235. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => invalidationClass);
  236. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  237. {
  238. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  239. }
  240. bool CanUseCondition1(Hashtable hashtable)
  241. {
  242. if (selectedPermanent.TopCard != null)
  243. {
  244. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  245. {
  246. return true;
  247. }
  248. }
  249. return false;
  250. }
  251. bool PermanentCondition(Permanent permanent)
  252. {
  253. if (permanent == selectedPermanent)
  254. {
  255. return true;
  256. }
  257. return false;
  258. }
  259. bool InvalidateCondition(ICardEffect cardEffect)
  260. {
  261. if (cardEffect != null)
  262. {
  263. if (cardEffect is ActivateICardEffect)
  264. {
  265. if (cardEffect.EffectSourceCard != null)
  266. {
  267. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(cardEffect.EffectSourceCard.PermanentOfThisCard(), card))
  268. {
  269. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  270. {
  271. if (!cardEffect.EffectSourceCard.PermanentOfThisCard().TopCard.CanNotBeAffected(invalidationClass))
  272. {
  273. if (cardEffect.IsWhenDigivolving)
  274. {
  275. return true;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. }
  282. }
  283. return false;
  284. }
  285. }
  286. }
  287. }
  288. }
  289. #endregion
  290. #region Your Turn
  291. if (timing == EffectTiming.None)
  292. {
  293. bool Condition()
  294. {
  295. if (CardEffectCommons.IsExistOnBattleArea(card))
  296. {
  297. if (CardEffectCommons.IsOwnerTurn(card))
  298. {
  299. if (card.PermanentOfThisCard().TopCard.EqualsTraits("Ice-Snow"))
  300. {
  301. if (!CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) =>
  302. permanent.IsDigimon && !permanent.HasNoDigivolutionCards))
  303. {
  304. return true;
  305. }
  306. }
  307. }
  308. }
  309. return false;
  310. }
  311. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(1, true, card, Condition));
  312. }
  313. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  314. {
  315. bool Condition()
  316. {
  317. if (CardEffectCommons.IsExistOnBattleArea(card))
  318. {
  319. if (CardEffectCommons.IsOwnerTurn(card))
  320. {
  321. if (card.PermanentOfThisCard().TopCard.EqualsTraits("Ice-Snow"))
  322. {
  323. if (!CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) =>
  324. permanent.IsDigimon && !permanent.HasNoDigivolutionCards))
  325. {
  326. return true;
  327. }
  328. }
  329. }
  330. }
  331. return false;
  332. }
  333. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  334. }
  335. #endregion
  336. return cardEffects;
  337. }
  338. }
  339. }