BT19_070.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_070 : 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.IsLevel4 && targetPermanent.TopCard.ContainsTraits("Composite");
  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 [DigiXros -1] 3 Lv.4 [Composite] trait Digimon cards w/different card numbers
  28. if (timing == EffectTiming.None)
  29. {
  30. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  31. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  32. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  33. addDigiXrosConditionClass.SetNotShowUI(true);
  34. cardEffects.Add(addDigiXrosConditionClass);
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return true;
  38. }
  39. DigiXrosCondition GetDigiXros(CardSource cardSource)
  40. {
  41. if (cardSource == card)
  42. {
  43. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition,
  44. "1 Lv.4 Digimon card with [Composite] trait");
  45. bool CanSelectCardCondition(CardSource source)
  46. {
  47. return source && source.Owner == card.Owner &&
  48. source.IsDigimon && source.HasLevel && source.IsLevel4 &&
  49. source.CardTraits.Contains("Composite");
  50. }
  51. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>();
  52. for (int i = 0; i < 3; i++)
  53. {
  54. elements.Add(element);
  55. }
  56. bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources, CardSource source)
  57. {
  58. List<string> cardIDs = new List<string>();
  59. foreach (var cs in cardSources.Where(cs => !cardIDs.Contains(cs.CardID)))
  60. {
  61. cardIDs.Add(cs.CardID);
  62. }
  63. return !cardIDs.Contains(source.CardID);
  64. }
  65. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, CanTargetConditionByPreSelectedList, 1);
  66. return digiXrosCondition;
  67. }
  68. return null;
  69. }
  70. }
  71. #endregion
  72. #region On Play/ When Digivolving Shared
  73. bool CanSelectOwnerPermanentConditionShared(Permanent permanent)
  74. {
  75. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  76. }
  77. bool CanSelectLevelOpponentPermanentConditionShared(Permanent permanent, int level)
  78. {
  79. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  80. permanent.IsDigimon &&
  81. permanent.TopCard.HasLevel &&
  82. permanent.Level == level;
  83. }
  84. bool CanActivateConditionShared(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  87. CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnerPermanentConditionShared);
  88. }
  89. #endregion
  90. #region On Play
  91. if (timing == EffectTiming.OnEnterFieldAnyone)
  92. {
  93. ActivateClass activateClass = new ActivateClass();
  94. activateClass.SetUpICardEffect("Delete 1 of your Digimon to delete your opponent's Digimon", CanUseCondition, card);
  95. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  96. cardEffects.Add(activateClass);
  97. string EffectDescription()
  98. {
  99. return
  100. "[On Play] By deleting 1 of your Digimon, delete 1 of your opponent's level 3 Digimon, 1 of their level 4 Digimon, and 1 of their level 5 Digimon.";
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable hashtable)
  107. {
  108. Permanent selectedPermanent = null;
  109. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  110. selectPermanentEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectOwnerPermanentConditionShared,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. maxCount: 1,
  116. canNoSelect: true,
  117. canEndNotMax: false,
  118. selectPermanentCoroutine: SelectPermanentCoroutine,
  119. afterSelectPermanentCoroutine: null,
  120. mode: SelectPermanentEffect.Mode.Custom,
  121. cardEffect: activateClass);
  122. selectPermanentEffect.SetUpCustomMessage("Select 1 of your Digimon to delete.",
  123. "The opponent is selecting 1 of their Digimon to delete.");
  124. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  125. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  126. {
  127. selectedPermanent = permanent;
  128. yield return null;
  129. }
  130. if (selectedPermanent != null)
  131. {
  132. yield return ContinuousController.instance.StartCoroutine(
  133. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  134. targetPermanents: new List<Permanent>() { selectedPermanent }, activateClass: activateClass,
  135. successProcess: _ => SuccessProcess(), failureProcess: null));
  136. }
  137. IEnumerator SuccessProcess()
  138. {
  139. List<Permanent> selectedPermanents = new List<Permanent>();
  140. IEnumerator SelectTargetCoroutine(Permanent permanent)
  141. {
  142. selectedPermanents.Add(permanent);
  143. yield return null;
  144. }
  145. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  146. CanSelectLevelOpponentPermanentConditionShared(permanent, 3)))
  147. {
  148. selectPermanentEffect.SetUp(
  149. selectPlayer: card.Owner,
  150. canTargetCondition: permanent => CanSelectLevelOpponentPermanentConditionShared(permanent, 3),
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. maxCount: 1,
  154. canNoSelect: false,
  155. canEndNotMax: false,
  156. selectPermanentCoroutine: SelectTargetCoroutine,
  157. afterSelectPermanentCoroutine: null,
  158. mode: SelectPermanentEffect.Mode.Custom,
  159. cardEffect: activateClass);
  160. selectPermanentEffect.SetUpCustomMessage("Select a level 3 Digimon to delete.", "Opponent is selecting Digimon to delete.");
  161. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  162. }
  163. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  164. CanSelectLevelOpponentPermanentConditionShared(permanent, 4)))
  165. {
  166. selectPermanentEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: permanent => CanSelectLevelOpponentPermanentConditionShared(permanent, 4),
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: 1,
  172. canNoSelect: false,
  173. canEndNotMax: false,
  174. selectPermanentCoroutine: SelectTargetCoroutine,
  175. afterSelectPermanentCoroutine: null,
  176. mode: SelectPermanentEffect.Mode.Custom,
  177. cardEffect: activateClass);
  178. selectPermanentEffect.SetUpCustomMessage("Select a level 4 Digimon to delete.", "Opponent is selecting Digimon to delete.");
  179. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  180. }
  181. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  182. CanSelectLevelOpponentPermanentConditionShared(permanent, 5)))
  183. {
  184. selectPermanentEffect.SetUp(
  185. selectPlayer: card.Owner,
  186. canTargetCondition: permanent => CanSelectLevelOpponentPermanentConditionShared(permanent, 5),
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. maxCount: 1,
  190. canNoSelect: false,
  191. canEndNotMax: false,
  192. selectPermanentCoroutine: SelectTargetCoroutine,
  193. afterSelectPermanentCoroutine: null,
  194. mode: SelectPermanentEffect.Mode.Custom,
  195. cardEffect: activateClass);
  196. selectPermanentEffect.SetUpCustomMessage("Select a level 5 Digimon to delete.", "Opponent is selecting Digimon to delete.");
  197. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  198. }
  199. if(selectedPermanents.Count > 0)
  200. {
  201. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  202. selectedPermanents,
  203. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  204. }
  205. }
  206. }
  207. }
  208. #endregion
  209. #region When Digivolving
  210. if (timing == EffectTiming.OnEnterFieldAnyone)
  211. {
  212. ActivateClass activateClass = new ActivateClass();
  213. activateClass.SetUpICardEffect("Delete 1 of your Digimon to delete your opponent's Digimon", CanUseCondition, card);
  214. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  215. cardEffects.Add(activateClass);
  216. string EffectDescription()
  217. {
  218. return
  219. "[When Digivolving] By deleting 1 of your Digimon, delete 1 of your opponent's level 3 Digimon, 1 of their level 4 Digimon, and 1 of their level 5 Digimon.";
  220. }
  221. bool CanUseCondition(Hashtable hashtable)
  222. {
  223. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  224. }
  225. IEnumerator ActivateCoroutine(Hashtable hashtable)
  226. {
  227. Permanent selectedPermanent = null;
  228. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  229. selectPermanentEffect.SetUp(
  230. selectPlayer: card.Owner,
  231. canTargetCondition: CanSelectOwnerPermanentConditionShared,
  232. canTargetCondition_ByPreSelecetedList: null,
  233. canEndSelectCondition: null,
  234. maxCount: 1,
  235. canNoSelect: true,
  236. canEndNotMax: false,
  237. selectPermanentCoroutine: SelectPermanentCoroutine,
  238. afterSelectPermanentCoroutine: null,
  239. mode: SelectPermanentEffect.Mode.Custom,
  240. cardEffect: activateClass);
  241. selectPermanentEffect.SetUpCustomMessage("Select 1 of your Digimon to delete.",
  242. "The opponent is selecting 1 of their Digimon to delete.");
  243. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  244. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  245. {
  246. selectedPermanent = permanent;
  247. yield return null;
  248. }
  249. if (selectedPermanent != null)
  250. {
  251. yield return ContinuousController.instance.StartCoroutine(
  252. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  253. targetPermanents: new List<Permanent>() { selectedPermanent }, activateClass: activateClass,
  254. successProcess: _ => SuccessProcess(), failureProcess: null));
  255. }
  256. IEnumerator SuccessProcess()
  257. {
  258. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  259. CanSelectLevelOpponentPermanentConditionShared(permanent, 3)))
  260. {
  261. selectPermanentEffect.SetUp(
  262. selectPlayer: card.Owner,
  263. canTargetCondition: permanent => CanSelectLevelOpponentPermanentConditionShared(permanent, 3),
  264. canTargetCondition_ByPreSelecetedList: null,
  265. canEndSelectCondition: null,
  266. maxCount: 1,
  267. canNoSelect: false,
  268. canEndNotMax: false,
  269. selectPermanentCoroutine: null,
  270. afterSelectPermanentCoroutine: null,
  271. mode: SelectPermanentEffect.Mode.Destroy,
  272. cardEffect: activateClass);
  273. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  274. }
  275. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  276. CanSelectLevelOpponentPermanentConditionShared(permanent, 4)))
  277. {
  278. selectPermanentEffect.SetUp(
  279. selectPlayer: card.Owner,
  280. canTargetCondition: permanent => CanSelectLevelOpponentPermanentConditionShared(permanent, 4),
  281. canTargetCondition_ByPreSelecetedList: null,
  282. canEndSelectCondition: null,
  283. maxCount: 1,
  284. canNoSelect: false,
  285. canEndNotMax: false,
  286. selectPermanentCoroutine: null,
  287. afterSelectPermanentCoroutine: null,
  288. mode: SelectPermanentEffect.Mode.Destroy,
  289. cardEffect: activateClass);
  290. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  291. }
  292. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  293. CanSelectLevelOpponentPermanentConditionShared(permanent, 5)))
  294. {
  295. selectPermanentEffect.SetUp(
  296. selectPlayer: card.Owner,
  297. canTargetCondition: permanent => CanSelectLevelOpponentPermanentConditionShared(permanent, 5),
  298. canTargetCondition_ByPreSelecetedList: null,
  299. canEndSelectCondition: null,
  300. maxCount: 1,
  301. canNoSelect: false,
  302. canEndNotMax: false,
  303. selectPermanentCoroutine: null,
  304. afterSelectPermanentCoroutine: null,
  305. mode: SelectPermanentEffect.Mode.Destroy,
  306. cardEffect: activateClass);
  307. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  308. }
  309. }
  310. }
  311. }
  312. #endregion
  313. #region On Deletion
  314. if (timing == EffectTiming.OnDestroyedAnyone)
  315. {
  316. ActivateClass activateClass = new ActivateClass();
  317. activateClass.SetUpICardEffect("Delete 1 of your Digimon to play [Machinedramon] from your trash", CanUseCondition, card);
  318. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  319. cardEffects.Add(activateClass);
  320. string EffectDescription()
  321. {
  322. return
  323. "[On Deletion] By deleting 1 of your level 4 or lower purple or red Digimon, you may play 1 [Machinedramon] from your trash without paying the cost.";
  324. }
  325. bool CanUseCondition(Hashtable hashtable)
  326. {
  327. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  328. }
  329. bool CanSelectOwnerPermanentCondition(Permanent permanent)
  330. {
  331. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  332. permanent.TopCard.HasLevel && permanent.Level <= 4 &&
  333. (permanent.TopCard.CardColors.Contains(CardColor.Purple) ||
  334. permanent.TopCard.CardColors.Contains(CardColor.Red));
  335. }
  336. bool CanSelectCardCondition(CardSource cardSource)
  337. {
  338. return cardSource.IsDigimon && cardSource.EqualsCardName("Machinedramon") &&
  339. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  340. }
  341. bool CanActivateCondition(Hashtable hashtable)
  342. {
  343. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  344. CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnerPermanentCondition);
  345. }
  346. IEnumerator ActivateCoroutine(Hashtable hashtable)
  347. {
  348. Permanent selectedPermanent = null;
  349. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  350. selectPermanentEffect.SetUp(
  351. selectPlayer: card.Owner,
  352. canTargetCondition: CanSelectOwnerPermanentCondition,
  353. canTargetCondition_ByPreSelecetedList: null,
  354. canEndSelectCondition: null,
  355. maxCount: 1,
  356. canNoSelect: true,
  357. canEndNotMax: false,
  358. selectPermanentCoroutine: SelectPermanentCoroutine,
  359. afterSelectPermanentCoroutine: null,
  360. mode: SelectPermanentEffect.Mode.Custom,
  361. cardEffect: activateClass);
  362. selectPermanentEffect.SetUpCustomMessage("Select 1 of your Digimon to delete.",
  363. "The opponent is selecting 1 of their Digimon to delete.");
  364. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  365. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  366. {
  367. selectedPermanent = permanent;
  368. yield return null;
  369. }
  370. if (selectedPermanent != null)
  371. {
  372. yield return ContinuousController.instance.StartCoroutine(
  373. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  374. targetPermanents: new List<Permanent>() { selectedPermanent }, activateClass: activateClass,
  375. successProcess: _ => SuccessProcess(), failureProcess: null));
  376. }
  377. IEnumerator SuccessProcess()
  378. {
  379. List<CardSource> selectedCards = new List<CardSource>();
  380. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  381. selectCardEffect.SetUp(
  382. canTargetCondition: CanSelectCardCondition,
  383. canTargetCondition_ByPreSelecetedList: null,
  384. canEndSelectCondition: null,
  385. canNoSelect: () => true,
  386. selectCardCoroutine: SelectCardCoroutine,
  387. afterSelectCardCoroutine: null,
  388. message: "Select 1 card to play.",
  389. maxCount: 1,
  390. canEndNotMax: false,
  391. isShowOpponent: true,
  392. mode: SelectCardEffect.Mode.Custom,
  393. root: SelectCardEffect.Root.Trash,
  394. customRootCardList: null,
  395. canLookReverseCard: true,
  396. selectPlayer: card.Owner,
  397. cardEffect: activateClass);
  398. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  399. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  400. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  401. IEnumerator SelectCardCoroutine(CardSource cardSource)
  402. {
  403. selectedCards.Add(cardSource);
  404. yield return null;
  405. }
  406. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  407. cardSources: selectedCards,
  408. activateClass: activateClass,
  409. payCost: false,
  410. isTapped: false,
  411. root: SelectCardEffect.Root.Trash,
  412. activateETB: true));
  413. }
  414. }
  415. }
  416. #endregion
  417. #region Security Attack - ESS
  418. if (timing == EffectTiming.None)
  419. {
  420. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card,
  421. condition: null));
  422. }
  423. #endregion
  424. return cardEffects;
  425. }
  426. }
  427. }