BT19_063.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_063 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region DigiXros
  13. if (timing == EffectTiming.None)
  14. {
  15. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  16. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  17. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  18. addDigiXrosConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addDigiXrosConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. DigiXrosCondition GetDigiXros(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "SkullKnightmon");
  29. bool CanSelectCardCondition(CardSource cardSource)
  30. {
  31. if (cardSource != null)
  32. {
  33. if (cardSource.Owner == card.Owner)
  34. {
  35. if (cardSource.IsDigimon)
  36. {
  37. if (cardSource.CardNames_DigiXros.Contains("SkullKnightmon"))
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "DeadlyAxemon");
  47. bool CanSelectCardCondition1(CardSource cardSource)
  48. {
  49. if (cardSource != null)
  50. {
  51. if (cardSource.Owner == card.Owner)
  52. {
  53. if (cardSource.IsDigimon)
  54. {
  55. if (cardSource.CardNames_DigiXros.Contains("DeadlyAxemon"))
  56. {
  57. return true;
  58. }
  59. }
  60. }
  61. }
  62. return false;
  63. }
  64. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  65. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  66. return digiXrosCondition;
  67. }
  68. return null;
  69. }
  70. }
  71. #endregion
  72. #region Material Save
  73. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  74. {
  75. cardEffects.Add(CardEffectFactory.MaterialSaveEffect(card: card, materialSaveCount: 1));
  76. }
  77. #endregion
  78. #region On Play
  79. if (timing == EffectTiming.OnEnterFieldAnyone)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("De-Digivolve 1 to 1 Digimon and delete 1 Digimon or tamer with 3 or less Cost", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  84. cardEffects.Add(activateClass);
  85. string EffectDiscription()
  86. {
  87. return "[On Play] <De-Digivolve 1> 1 of your opponent's Digimon. Then, if DigiXrosing with 2 cards, you may delete 1 play cost 3 or lower Digimon or Tamer.";
  88. }
  89. bool CanSelectPermanentCondition(Permanent permanent)
  90. {
  91. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  92. }
  93. bool CanSelectPermanentCondition1(Permanent permanent)
  94. {
  95. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  96. {
  97. if(permanent.TopCard.IsDigimon || permanent.TopCard.IsTamer)
  98. {
  99. if (permanent.TopCard.GetCostItself <= 3)
  100. {
  101. if (permanent.TopCard.HasPlayCost)
  102. {
  103. return true;
  104. }
  105. }
  106. }
  107. }
  108. return false;
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  113. }
  114. bool CanActivateCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  117. }
  118. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  119. {
  120. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  121. {
  122. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  123. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  124. selectPermanentEffect.SetUp(
  125. selectPlayer: card.Owner,
  126. canTargetCondition: CanSelectPermanentCondition,
  127. canTargetCondition_ByPreSelecetedList: null,
  128. canEndSelectCondition: null,
  129. maxCount: maxCount,
  130. canNoSelect: false,
  131. canEndNotMax: false,
  132. selectPermanentCoroutine: SelectPermanentCoroutine,
  133. afterSelectPermanentCoroutine: null,
  134. mode: SelectPermanentEffect.Mode.Custom,
  135. cardEffect: activateClass);
  136. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  137. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  138. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  139. {
  140. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  141. }
  142. }
  143. if (CardEffectCommons.IsDijiXros(_hashtable, (count) => count == 2))
  144. {
  145. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  146. {
  147. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  148. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  149. selectPermanentEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectPermanentCondition1,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: maxCount,
  155. canNoSelect: true,
  156. canEndNotMax: false,
  157. selectPermanentCoroutine: null,
  158. afterSelectPermanentCoroutine: null,
  159. mode: SelectPermanentEffect.Mode.Destroy,
  160. cardEffect: activateClass);
  161. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  162. }
  163. }
  164. }
  165. }
  166. #endregion
  167. #region When Digivolving
  168. if (timing == EffectTiming.OnEnterFieldAnyone)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("De-Digivolve 1 to 1 Digimon and delete 1 Digimon or tamer with 3 or less Cost", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. {
  176. return "[When Digivolving] <De-Digivolve 1> 1 of your opponent's Digimon. Then, if DigiXrosing with 2 cards, you may delete 1 play cost 3 or lower Digimon or Tamer.";
  177. }
  178. bool CanSelectPermanentCondition(Permanent permanent)
  179. {
  180. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  181. }
  182. bool CanSelectPermanentCondition1(Permanent permanent)
  183. {
  184. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  185. {
  186. if (permanent.TopCard.IsDigimon || permanent.TopCard.IsTamer)
  187. {
  188. if (permanent.TopCard.GetCostItself <= 3)
  189. {
  190. if (permanent.TopCard.HasPlayCost)
  191. {
  192. return true;
  193. }
  194. }
  195. }
  196. }
  197. return false;
  198. }
  199. bool CanUseCondition(Hashtable hashtable)
  200. {
  201. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  202. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  203. }
  204. bool CanActivateCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  207. }
  208. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  209. {
  210. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  211. {
  212. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  213. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  214. selectPermanentEffect.SetUp(
  215. selectPlayer: card.Owner,
  216. canTargetCondition: CanSelectPermanentCondition,
  217. canTargetCondition_ByPreSelecetedList: null,
  218. canEndSelectCondition: null,
  219. maxCount: maxCount,
  220. canNoSelect: false,
  221. canEndNotMax: false,
  222. selectPermanentCoroutine: SelectPermanentCoroutine,
  223. afterSelectPermanentCoroutine: null,
  224. mode: SelectPermanentEffect.Mode.Custom,
  225. cardEffect: activateClass);
  226. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  227. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  228. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  229. {
  230. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  231. }
  232. }
  233. if (CardEffectCommons.IsDijiXros(_hashtable, (count) => count == 2))
  234. {
  235. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  236. {
  237. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  238. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  239. selectPermanentEffect.SetUp(
  240. selectPlayer: card.Owner,
  241. canTargetCondition: CanSelectPermanentCondition1,
  242. canTargetCondition_ByPreSelecetedList: null,
  243. canEndSelectCondition: null,
  244. maxCount: maxCount,
  245. canNoSelect: true,
  246. canEndNotMax: false,
  247. selectPermanentCoroutine: null,
  248. afterSelectPermanentCoroutine: null,
  249. mode: SelectPermanentEffect.Mode.Destroy,
  250. cardEffect: activateClass);
  251. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  252. }
  253. }
  254. }
  255. }
  256. #endregion
  257. #region On Deletion
  258. if (timing == EffectTiming.OnDestroyedAnyone)
  259. {
  260. ActivateClass activateClass = new ActivateClass();
  261. activateClass.SetUpICardEffect("Play 1 level 4 or lower Digimon", CanUseCondition, card);
  262. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  263. cardEffects.Add(activateClass);
  264. string EffectDiscription()
  265. {
  266. return "[On Deletion] You may play 1 level 4 or lower Digimon card with [Knightmon] in its text from under your Tamers without paying the cost.";
  267. }
  268. bool HasKnightmonInText(CardSource cardSource)
  269. {
  270. if (cardSource.HasText("Knightmon"))
  271. {
  272. if(cardSource.HasLevel && cardSource.Level <= 4)
  273. {
  274. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  275. {
  276. return true;
  277. }
  278. }
  279. }
  280. return false;
  281. }
  282. bool TamerHasDigimon(Permanent permanent)
  283. {
  284. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  285. {
  286. if (permanent.IsTamer)
  287. {
  288. if (permanent.DigivolutionCards.Count(HasKnightmonInText) >= 1)
  289. {
  290. return true;
  291. }
  292. }
  293. }
  294. return false;
  295. }
  296. bool CanUseCondition(Hashtable hashtable)
  297. {
  298. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  299. }
  300. bool CanActivateCondition(Hashtable hashtable)
  301. {
  302. return CardEffectCommons.CanActivateOnDeletion(card) &&
  303. CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimon);
  304. }
  305. IEnumerator ActivateCoroutine(Hashtable hashtable)
  306. {
  307. Permanent selectedPermanent = null;
  308. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  309. selectPermanentEffect.SetUp(
  310. selectPlayer: card.Owner,
  311. canTargetCondition: TamerHasDigimon,
  312. canTargetCondition_ByPreSelecetedList: null,
  313. canEndSelectCondition: null,
  314. maxCount: 1,
  315. canNoSelect: true,
  316. canEndNotMax: false,
  317. selectPermanentCoroutine: SelectPermanentCoroutine,
  318. afterSelectPermanentCoroutine: null,
  319. mode: SelectPermanentEffect.Mode.Custom,
  320. cardEffect: activateClass);
  321. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  322. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  323. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  324. {
  325. selectedPermanent = permanent;
  326. yield return null;
  327. }
  328. if (selectedPermanent != null)
  329. {
  330. List<CardSource> selectedCards = new List<CardSource>();
  331. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  332. selectCardEffect.SetUp(
  333. canTargetCondition: HasKnightmonInText,
  334. canTargetCondition_ByPreSelecetedList: null,
  335. canEndSelectCondition: null,
  336. canNoSelect: () => true,
  337. selectCardCoroutine: SelectCardCoroutine,
  338. afterSelectCardCoroutine: null,
  339. message: "Select 1 digivolution card to play.",
  340. maxCount: 1,
  341. canEndNotMax: false,
  342. isShowOpponent: true,
  343. mode: SelectCardEffect.Mode.Custom,
  344. root: SelectCardEffect.Root.Custom,
  345. customRootCardList: selectedPermanent.DigivolutionCards,
  346. canLookReverseCard: true,
  347. selectPlayer: card.Owner,
  348. cardEffect: activateClass);
  349. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  350. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  351. yield return StartCoroutine(selectCardEffect.Activate());
  352. IEnumerator SelectCardCoroutine(CardSource cardSource)
  353. {
  354. selectedCards.Add(cardSource);
  355. yield return null;
  356. }
  357. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  358. cardSources: selectedCards,
  359. activateClass: activateClass,
  360. payCost: false,
  361. isTapped: false,
  362. root: SelectCardEffect.Root.DigivolutionCards,
  363. activateETB: true));
  364. }
  365. }
  366. }
  367. #endregion
  368. #region On Deletion - ESS
  369. if (timing == EffectTiming.OnDestroyedAnyone)
  370. {
  371. ActivateClass activateClass = new ActivateClass();
  372. activateClass.SetUpICardEffect("Play 1 level 4 or lower Digimon", CanUseCondition, card);
  373. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  374. activateClass.SetIsInheritedEffect(true);
  375. cardEffects.Add(activateClass);
  376. string EffectDiscription()
  377. {
  378. return "[On Deletion] You may play 1 level 4 or lower Digimon card with [Knightmon] in its text from your trash without paying the cost.";
  379. }
  380. bool HasKnightmonInText(CardSource cardSource)
  381. {
  382. if (cardSource.HasText("Knightmon"))
  383. {
  384. if (cardSource.HasLevel && cardSource.Level <= 4)
  385. {
  386. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  387. {
  388. return true;
  389. }
  390. }
  391. }
  392. return false;
  393. }
  394. bool CanUseCondition(Hashtable hashtable)
  395. {
  396. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  397. }
  398. bool CanActivateCondition(Hashtable hashtable)
  399. {
  400. return CardEffectCommons.CanActivateOnDeletionInherited(hashtable, card) &&
  401. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasKnightmonInText);
  402. }
  403. IEnumerator ActivateCoroutine(Hashtable hashtable)
  404. {
  405. List<CardSource> selectedCards = new List<CardSource>();
  406. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  407. selectCardEffect.SetUp(
  408. canTargetCondition: HasKnightmonInText,
  409. canTargetCondition_ByPreSelecetedList: null,
  410. canEndSelectCondition: null,
  411. canNoSelect: () => true,
  412. selectCardCoroutine: SelectCardCoroutine,
  413. afterSelectCardCoroutine: null,
  414. message: "Select 1 digivolution card to play.",
  415. maxCount: 1,
  416. canEndNotMax: false,
  417. isShowOpponent: true,
  418. mode: SelectCardEffect.Mode.Custom,
  419. root: SelectCardEffect.Root.Trash,
  420. customRootCardList: null,
  421. canLookReverseCard: true,
  422. selectPlayer: card.Owner,
  423. cardEffect: activateClass);
  424. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  425. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  426. yield return StartCoroutine(selectCardEffect.Activate());
  427. IEnumerator SelectCardCoroutine(CardSource cardSource)
  428. {
  429. selectedCards.Add(cardSource);
  430. yield return null;
  431. }
  432. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  433. cardSources: selectedCards,
  434. activateClass: activateClass,
  435. payCost: false,
  436. isTapped: false,
  437. root: SelectCardEffect.Root.Trash,
  438. activateETB: true));
  439. }
  440. }
  441. #endregion
  442. return cardEffects;
  443. }
  444. }
  445. }