BT20_102.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Omnimon (X Antibody)
  5. namespace DCGO.CardEffects.BT20
  6. {
  7. public class BT20_102 : 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 Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Omnimon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 2,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null));
  25. }
  26. #endregion
  27. #region Raid/Piercing/Blocker
  28. if (timing == EffectTiming.OnAllyAttack)
  29. {
  30. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  31. }
  32. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  33. {
  34. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. if (timing == EffectTiming.None)
  37. {
  38. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  39. }
  40. #endregion
  41. #region On Play
  42. if (timing == EffectTiming.OnEnterFieldAnyone)
  43. {
  44. ActivateClass activateClass = new ActivateClass();
  45. activateClass.SetUpICardEffect("Choose 1 of both players' Digimon, delete the rest, then bottom deck 1 opponents Digimon", CanUseCondition, card);
  46. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  47. cardEffects.Add(activateClass);
  48. string EffectDiscription()
  49. {
  50. return "[On Play] If [Omnimon] or [X Antibody] is in this Digimon's digivolution cards, choose 1 of both players' Digimon and delete all other Digimon. Then, return 1 of your opponent's Digimon to the bottom of the deck.";
  51. }
  52. bool IsOmniOrXAntiSource()
  53. {
  54. return card.PermanentOfThisCard().DigivolutionCards.Count(source => source.EqualsCardName("Omnimon") || source.EqualsCardName("X Antibody")) > 0;
  55. }
  56. bool OpponentsDigimon(Permanent permanent)
  57. {
  58. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  59. }
  60. bool OwnersDigimon(Permanent permanent)
  61. {
  62. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  63. }
  64. bool CanUseCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  67. }
  68. bool CanActivateCondition(Hashtable hashtable)
  69. {
  70. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable hashtable)
  73. {
  74. if (IsOmniOrXAntiSource())
  75. {
  76. List<Permanent> savedDigimon = new List<Permanent>();
  77. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  78. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  79. {
  80. selectPermanentEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: OpponentsDigimon,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: 1,
  86. canNoSelect: false,
  87. canEndNotMax: false,
  88. selectPermanentCoroutine: SelectPermanentCoroutine,
  89. afterSelectPermanentCoroutine: null,
  90. mode: SelectPermanentEffect.Mode.Custom,
  91. cardEffect: activateClass);
  92. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will not be destroyed.",
  93. "The opponent is selecting 1 Digimon that will not be destroyed.");
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. }
  96. if (CardEffectCommons.HasMatchConditionPermanent(OwnersDigimon))
  97. {
  98. selectPermanentEffect.SetUp(
  99. selectPlayer: card.Owner,
  100. canTargetCondition: OwnersDigimon,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. maxCount: 1,
  104. canNoSelect: false,
  105. canEndNotMax: false,
  106. selectPermanentCoroutine: SelectPermanentCoroutine,
  107. afterSelectPermanentCoroutine: null,
  108. mode: SelectPermanentEffect.Mode.Custom,
  109. cardEffect: activateClass);
  110. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will not be destroyed.",
  111. "The opponent is selecting 1 Digimon that will not be destroyed.");
  112. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  113. }
  114. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  115. {
  116. savedDigimon.Add(permanent);
  117. yield return null;
  118. }
  119. if (savedDigimon.Count > 0)
  120. {
  121. List<Permanent> destroyTargetPermanents = GManager.instance.turnStateMachine.gameContext.Players
  122. .Map(player => player.GetBattleAreaDigimons())
  123. .Flat()
  124. .Filter(permanent => !savedDigimon.Contains(permanent));
  125. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  126. }
  127. }
  128. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  129. {
  130. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  131. selectPermanentEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: OpponentsDigimon,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: 1,
  137. canNoSelect: false,
  138. canEndNotMax: false,
  139. selectPermanentCoroutine: null,
  140. afterSelectPermanentCoroutine: null,
  141. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  142. cardEffect: activateClass);
  143. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will be bottom decked.",
  144. "The opponent is selecting 1 Digimon that will be bottom decked.");
  145. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  146. }
  147. yield return null;
  148. }
  149. }
  150. #endregion
  151. #region When Digivolving
  152. if (timing == EffectTiming.OnEnterFieldAnyone)
  153. {
  154. ActivateClass activateClass = new ActivateClass();
  155. activateClass.SetUpICardEffect("Choose 1 of both players' Digimon, delete the rest, then bottom deck 1 opponents Digimon", CanUseCondition, card);
  156. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. {
  160. return "[When Digivolving] If [Omnimon] or [X Antibody] is in this Digimon's digivolution cards, choose 1 of both players' Digimon and delete all other Digimon. Then, return 1 of your opponent's Digimon to the bottom of the deck.";
  161. }
  162. bool IsOmniOrXAntiSource()
  163. {
  164. return card.PermanentOfThisCard().DigivolutionCards.Count(source => source.EqualsCardName("Omnimon") || source.EqualsCardName("X Antibody")) > 0;
  165. }
  166. bool OpponentsDigimon(Permanent permanent)
  167. {
  168. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  169. }
  170. bool OwnersDigimon(Permanent permanent)
  171. {
  172. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  173. }
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  177. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  178. }
  179. bool CanActivateCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable hashtable)
  184. {
  185. if (IsOmniOrXAntiSource())
  186. {
  187. List<Permanent> savedDigimon = new List<Permanent>();
  188. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  189. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  190. {
  191. selectPermanentEffect.SetUp(
  192. selectPlayer: card.Owner,
  193. canTargetCondition: OpponentsDigimon,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. maxCount: 1,
  197. canNoSelect: false,
  198. canEndNotMax: false,
  199. selectPermanentCoroutine: SelectPermanentCoroutine,
  200. afterSelectPermanentCoroutine: null,
  201. mode: SelectPermanentEffect.Mode.Custom,
  202. cardEffect: activateClass);
  203. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will not be destroyed.",
  204. "The opponent is selecting 1 Digimon that will not be destroyed.");
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  206. }
  207. if (CardEffectCommons.HasMatchConditionPermanent(OwnersDigimon))
  208. {
  209. selectPermanentEffect.SetUp(
  210. selectPlayer: card.Owner,
  211. canTargetCondition: OwnersDigimon,
  212. canTargetCondition_ByPreSelecetedList: null,
  213. canEndSelectCondition: null,
  214. maxCount: 1,
  215. canNoSelect: false,
  216. canEndNotMax: false,
  217. selectPermanentCoroutine: SelectPermanentCoroutine,
  218. afterSelectPermanentCoroutine: null,
  219. mode: SelectPermanentEffect.Mode.Custom,
  220. cardEffect: activateClass);
  221. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will not be destroyed.",
  222. "The opponent is selecting 1 Digimon that will not be destroyed.");
  223. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  224. }
  225. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  226. {
  227. savedDigimon.Add(permanent);
  228. yield return null;
  229. }
  230. if (savedDigimon.Count > 0)
  231. {
  232. List<Permanent> destroyTargetPermanents = GManager.instance.turnStateMachine.gameContext.Players
  233. .Map(player => player.GetBattleAreaDigimons())
  234. .Flat()
  235. .Filter(permanent => !savedDigimon.Contains(permanent));
  236. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  237. }
  238. }
  239. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  240. {
  241. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  242. selectPermanentEffect.SetUp(
  243. selectPlayer: card.Owner,
  244. canTargetCondition: OpponentsDigimon,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. maxCount: 1,
  248. canNoSelect: false,
  249. canEndNotMax: false,
  250. selectPermanentCoroutine: null,
  251. afterSelectPermanentCoroutine: null,
  252. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  253. cardEffect: activateClass);
  254. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will be bottom decked.",
  255. "The opponent is selecting 1 Digimon that will be bottom decked.");
  256. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  257. }
  258. yield return null;
  259. }
  260. }
  261. #endregion
  262. #region End of Your Turn
  263. if (timing == EffectTiming.OnEndTurn)
  264. {
  265. ActivateClass activateClass = new ActivateClass();
  266. activateClass.SetUpICardEffect("Gain Rush and attack without suspending", CanUseCondition, card);
  267. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  268. activateClass.SetHashString("Rush_BT20_102");
  269. cardEffects.Add(activateClass);
  270. string EffectDiscription()
  271. {
  272. return "[End of Your Turn] [Once Per Turn] 1 of your Digimon may gain <Rush> for the turn and attack without suspending.";
  273. }
  274. bool CanSelectPermanentCondition(Permanent permanent)
  275. {
  276. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  277. }
  278. bool CanUseCondition(Hashtable hashtable)
  279. {
  280. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  281. CardEffectCommons.IsOwnerTurn(card);
  282. }
  283. bool CanActivateCondition(Hashtable hashtable)
  284. {
  285. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  286. }
  287. IEnumerator ActivateCoroutine(Hashtable hashtable)
  288. {
  289. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  290. {
  291. Permanent selectedPermanent = null;
  292. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  293. selectPermanentEffect.SetUp(
  294. selectPlayer: card.Owner,
  295. canTargetCondition: CanSelectPermanentCondition,
  296. canTargetCondition_ByPreSelecetedList: null,
  297. canEndSelectCondition: null,
  298. maxCount: 1,
  299. canNoSelect: false,
  300. canEndNotMax: false,
  301. selectPermanentCoroutine: SelectPermanentCoroutine,
  302. afterSelectPermanentCoroutine: null,
  303. mode: SelectPermanentEffect.Mode.Custom,
  304. cardEffect: activateClass);
  305. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain Rush and attack.",
  306. "The opponent is selecting 1 Digimon that will gain Rush and attack.");
  307. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  308. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  309. {
  310. selectedPermanent = permanent;
  311. yield return null;
  312. }
  313. if (selectedPermanent != null)
  314. {
  315. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  316. targetPermanent: selectedPermanent,
  317. effectDuration: EffectDuration.UntilEachTurnEnd,
  318. activateClass: activateClass));
  319. if (selectedPermanent.CanAttack(activateClass, true))
  320. {
  321. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  322. selectAttackEffect.SetUp(
  323. attacker: selectedPermanent,
  324. canAttackPlayerCondition: () => true,
  325. defenderCondition: (permanent) => true,
  326. cardEffect: activateClass);
  327. selectAttackEffect.SetCanNotSelectNotAttack();
  328. selectAttackEffect.SetWithoutTap();
  329. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  330. }
  331. }
  332. }
  333. }
  334. }
  335. #endregion
  336. return cardEffects;
  337. }
  338. }
  339. }