EX10_055.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. // Tactimon
  7. namespace DCGO.CardEffects.EX10
  8. {
  9. public class EX10_055 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region DigiXros
  15. if (timing == EffectTiming.None)
  16. {
  17. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  18. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  19. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  20. addDigiXrosConditionClass.SetNotShowUI(true);
  21. cardEffects.Add(addDigiXrosConditionClass);
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return true;
  25. }
  26. DigiXrosCondition GetDigiXros(CardSource cardSource)
  27. {
  28. if (cardSource == card)
  29. {
  30. bool CanSelectCardCondition(CardSource cardSource)
  31. {
  32. if (cardSource != null)
  33. {
  34. if (cardSource.Owner == card.Owner)
  35. {
  36. if (cardSource.IsDigimon)
  37. {
  38. if (cardSource.EqualsTraits("BagraArmy"))
  39. {
  40. return true;
  41. }
  42. if (cardSource.EqualsTraits("Bagra Army"))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "[Bagra Army] Digimon");
  52. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>();
  53. for (int i = 0; i < 2; i++)
  54. {
  55. elements.Add(element);
  56. }
  57. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  58. return digiXrosCondition;
  59. }
  60. return null;
  61. }
  62. }
  63. #endregion
  64. #region On Play
  65. if (timing == EffectTiming.OnEnterFieldAnyone)
  66. {
  67. ActivateClass activateClass = new ActivateClass();
  68. activateClass.SetUpICardEffect("Choose 1 of your digimon, delete it and 1 opponent digimon with equal or less level", CanUseCondition, card);
  69. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  70. cardEffects.Add(activateClass);
  71. string EffectDiscription()
  72. {
  73. return "[On Play] You may choose 1 of your Digimon. Delete the chosen Digimon and 1 of your opponent's Digimon with as high or lower a level as it.";
  74. }
  75. bool CanUseCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  78. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  79. }
  80. bool CanActivateCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  83. }
  84. bool IsYourDigimon(Permanent permanent)
  85. {
  86. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  87. }
  88. IEnumerator ActivateCoroutine(Hashtable hashtable)
  89. {
  90. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYourDigimon))
  91. {
  92. List<Permanent> permanentList = new List<Permanent>();
  93. #region Select Your Digimon to Destroy
  94. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsYourDigimon));
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: IsYourDigimon,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: maxCount,
  102. canNoSelect: true,
  103. canEndNotMax: false,
  104. selectPermanentCoroutine: SelectPermanentCoroutine,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  109. {
  110. permanentList.Add(permanent);
  111. yield return null;
  112. }
  113. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to destroy", "The opponent is selecting 1 Digimon to destroy");
  114. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  115. #endregion
  116. if (permanentList.Any())
  117. {
  118. bool CanSelectOpponentDigimon(Permanent permanent)
  119. {
  120. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  121. && permanent.TopCard.HasLevel
  122. && permanent.TopCard.Level <= permanentList[0].Level;
  123. }
  124. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentDigimon))
  125. {
  126. #region Select Opponent Digimon to Destroy
  127. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  128. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectOpponentDigimon));
  129. selectPermanentEffect1.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: CanSelectOpponentDigimon,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount1,
  135. canNoSelect: false,
  136. canEndNotMax: false,
  137. selectPermanentCoroutine: SelectPermanentCoroutine1,
  138. afterSelectPermanentCoroutine: null,
  139. mode: SelectPermanentEffect.Mode.Custom,
  140. cardEffect: activateClass);
  141. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  142. {
  143. permanentList.Add(permanent);
  144. yield return null;
  145. }
  146. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon to destroy", "The opponent is selecting 1 Digimon to destroy");
  147. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  148. #endregion
  149. }
  150. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  151. destroyTargetPermanents: permanentList,
  152. hashtable: CardEffectCommons.OnDeletionHashtable(
  153. permanentList,
  154. activateClass,
  155. null,
  156. false
  157. )).Destroy()
  158. );
  159. }
  160. }
  161. }
  162. }
  163. #endregion
  164. #region When Digivolving
  165. if (timing == EffectTiming.OnEnterFieldAnyone)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("Choose 1 of your digimon, delete it and 1 opponent digimon with equal or less level", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  170. cardEffects.Add(activateClass);
  171. string EffectDiscription()
  172. {
  173. return "[When Digivolving] You may choose 1 of your Digimon. Delete the chosen Digimon and 1 of your opponent�s Digimon with as high or lower a level as it.";
  174. }
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  178. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  179. }
  180. bool CanActivateCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  183. }
  184. bool IsYourDigimon(Permanent permanent)
  185. {
  186. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable hashtable)
  189. {
  190. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYourDigimon))
  191. {
  192. List<Permanent> permanentList = new List<Permanent>();
  193. #region Select Your Digimon to Destroy
  194. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  195. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsYourDigimon));
  196. selectPermanentEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: IsYourDigimon,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: maxCount,
  202. canNoSelect: true,
  203. canEndNotMax: false,
  204. selectPermanentCoroutine: SelectPermanentCoroutine,
  205. afterSelectPermanentCoroutine: null,
  206. mode: SelectPermanentEffect.Mode.Custom,
  207. cardEffect: activateClass);
  208. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  209. {
  210. permanentList.Add(permanent);
  211. yield return null;
  212. }
  213. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to destroy", "The opponent is selecting 1 Digimon to destroy");
  214. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  215. #endregion
  216. if (permanentList.Any())
  217. {
  218. bool CanSelectOpponentDigimon(Permanent permanent)
  219. {
  220. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  221. && permanent.TopCard.HasLevel
  222. && permanent.TopCard.Level <= permanentList[0].Level;
  223. }
  224. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentDigimon))
  225. {
  226. #region Select Opponent Digimon to Destroy
  227. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  228. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectOpponentDigimon));
  229. selectPermanentEffect1.SetUp(
  230. selectPlayer: card.Owner,
  231. canTargetCondition: CanSelectOpponentDigimon,
  232. canTargetCondition_ByPreSelecetedList: null,
  233. canEndSelectCondition: null,
  234. maxCount: maxCount1,
  235. canNoSelect: false,
  236. canEndNotMax: false,
  237. selectPermanentCoroutine: SelectPermanentCoroutine1,
  238. afterSelectPermanentCoroutine: null,
  239. mode: SelectPermanentEffect.Mode.Custom,
  240. cardEffect: activateClass);
  241. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  242. {
  243. permanentList.Add(permanent);
  244. yield return null;
  245. }
  246. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon to destroy", "The opponent is selecting 1 Digimon to destroy");
  247. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  248. #endregion
  249. }
  250. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  251. destroyTargetPermanents: permanentList,
  252. hashtable: CardEffectCommons.OnDeletionHashtable(
  253. permanentList,
  254. activateClass,
  255. null,
  256. false
  257. )).Destroy()
  258. );
  259. }
  260. }
  261. }
  262. }
  263. #endregion
  264. #region All Turns - Once Per Turn
  265. if (timing == EffectTiming.WhenRemoveField)
  266. {
  267. List<Permanent> removedPermanents = new List<Permanent>();
  268. ActivateClass activateClass = new ActivateClass();
  269. activateClass.SetUpICardEffect("Trash 2 source cards, prevent deletion", CanUseCondition, card);
  270. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  271. activateClass.SetHashString("EX10_055_Subsitute");
  272. cardEffects.Add(activateClass);
  273. string EffectDiscription()
  274. {
  275. return "[All Turns] [Once Per Turn] When any of your [Bagra Army] trait Digimon would leave the battle area by effects, by trashing any 2 of this Digimon's digivolution cards, they don't leave.";
  276. }
  277. bool CanUseCondition(Hashtable hashtable)
  278. {
  279. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  280. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsBagraArmyDigimon)
  281. && CardEffectCommons.IsByEffect(hashtable, effect => effect != null);
  282. }
  283. bool CanActivateCondition(Hashtable hashtable)
  284. {
  285. removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(IsBagraArmyDigimon);
  286. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  287. && card.PermanentOfThisCard().DigivolutionCards.Count >= 2;
  288. }
  289. bool IsBagraArmyDigimon(Permanent permanent)
  290. {
  291. return permanent.IsDigimon && permanent.TopCard.HasBagraArmyTraits;
  292. }
  293. IEnumerator ActivateCoroutine(Hashtable hashtable)
  294. {
  295. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 2)
  296. {
  297. Permanent thisPermanent = card.PermanentOfThisCard();
  298. List<CardSource> selectedCards = new List<CardSource>();
  299. #region Trash Digivolution Cards
  300. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  301. selectCardEffect.SetUp(
  302. canTargetCondition: _ => true,
  303. canTargetCondition_ByPreSelecetedList: null,
  304. canEndSelectCondition: null,
  305. canNoSelect: () => true,
  306. selectCardCoroutine: SelectCardCoroutine,
  307. afterSelectCardCoroutine: null,
  308. message: "Select 2 digivolution cards to trash.",
  309. maxCount: 2,
  310. canEndNotMax: false,
  311. isShowOpponent: true,
  312. mode: SelectCardEffect.Mode.Custom,
  313. root: SelectCardEffect.Root.Custom,
  314. customRootCardList: thisPermanent.DigivolutionCards,
  315. canLookReverseCard: true,
  316. selectPlayer: card.Owner,
  317. cardEffect: activateClass);
  318. IEnumerator SelectCardCoroutine(CardSource cardSource)
  319. {
  320. selectedCards.Add(cardSource);
  321. yield return null;
  322. }
  323. selectCardEffect.SetUseFaceDown();
  324. selectCardEffect.SetUpCustomMessage("Select 2 digivolution cards to trash.", "The opponent is selecting 2 digivolution cards to trash.");
  325. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  326. #endregion
  327. if (selectedCards.Count == 2)
  328. {
  329. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  330. targetPermanent: thisPermanent,
  331. targetDigivolutionCards: selectedCards,
  332. activateClass: activateClass,
  333. successProcess: SuccessProcess,
  334. failureProcess: null));
  335. IEnumerator SuccessProcess(List<CardSource> trashedSources)
  336. {
  337. foreach (Permanent permanent in removedPermanents)
  338. {
  339. #region Remove Events from Permanent
  340. permanent.HideDeleteEffect();
  341. permanent.HideHandBounceEffect();
  342. permanent.HideDeckBounceEffect();
  343. permanent.HideWillRemoveFieldEffect();
  344. permanent.DestroyingEffect = null;
  345. permanent.IsDestroyedByBattle = false;
  346. permanent.HandBounceEffect = null;
  347. permanent.LibraryBounceEffect = null;
  348. permanent.willBeRemoveField = false;
  349. #endregion
  350. }
  351. yield return null;
  352. }
  353. }
  354. }
  355. }
  356. }
  357. #endregion
  358. return cardEffects;
  359. }
  360. }
  361. }