BT18_019.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class BT18_019 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region DNA Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  16. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  17. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  18. addJogressConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addJogressConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. JogressCondition GetJogress(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. bool PermanentCondition1(Permanent permanent)
  29. {
  30. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  31. && permanent.TopCard.CardNames.Contains("Kimeramon");
  32. }
  33. bool PermanentCondition2(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  36. && permanent.TopCard.CardNames.Contains("Machinedramon");
  37. }
  38. JogressConditionElement[] elements = new JogressConditionElement[]
  39. {
  40. new JogressConditionElement(PermanentCondition1, "Kimeramon"),
  41. new JogressConditionElement(PermanentCondition2, "Machinedramon"),
  42. };
  43. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  44. return jogressCondition;
  45. }
  46. return null;
  47. }
  48. }
  49. #endregion
  50. #region OP/WD Shared
  51. #region Different Levels Shared
  52. List<Func<CardSource, bool>> Levels = new List<Func<CardSource, bool>> { Level3Selection, Level4Selection, Level5Selection, Level6Selection, Level7Selection };
  53. bool Level3Selection(CardSource cardSource)
  54. {
  55. return cardSource.IsDigimon
  56. && cardSource.IsLevel3;
  57. }
  58. bool Level4Selection(CardSource cardSource)
  59. {
  60. return cardSource.IsDigimon
  61. && cardSource.IsLevel4;
  62. }
  63. bool Level5Selection(CardSource cardSource)
  64. {
  65. return cardSource.IsDigimon
  66. && cardSource.IsLevel5;
  67. }
  68. bool Level6Selection(CardSource cardSource)
  69. {
  70. return cardSource.IsDigimon
  71. && cardSource.IsLevel6;
  72. }
  73. bool Level7Selection(CardSource cardSource)
  74. {
  75. return cardSource.IsDigimon
  76. && cardSource.HasLevel
  77. && cardSource.Level == 7;
  78. }
  79. #endregion
  80. string SharedEffectName = "Delete 1 enemy Digimon, then if DNA top deck 1 of all trash levels to gain 1 mem per.";
  81. CardEffectFactory.ActivateClassesForSharedEffects
  82. (ref cardEffects, timing, card,
  83. SharedEffectName,
  84. SharedActivateCoroutine,
  85. SharedEffectDescription,
  86. optional: false,
  87. onPlay: true,
  88. whenDigivolving: true);
  89. string SharedEffectDescription(string tag) => $"[{tag}] Delete 1 of your opponent's Digimon. Then, if DNA digivolving, by returning 1 of each Digimon card with different levels from your opponent's trash to the top of the deck, for each card returned, gain 1 memory.";
  90. bool CanSelectPermanentCondition(Permanent permanent)
  91. {
  92. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  93. }
  94. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  95. {
  96. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  97. {
  98. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  99. selectPermanentEffect.SetUp(
  100. selectPlayer: card.Owner,
  101. canTargetCondition: CanSelectPermanentCondition,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. maxCount: 1,
  105. canNoSelect: false,
  106. canEndNotMax: false,
  107. selectPermanentCoroutine: null,
  108. afterSelectPermanentCoroutine: null,
  109. mode: SelectPermanentEffect.Mode.Destroy,
  110. cardEffect: activateClass);
  111. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  112. }
  113. if (CardEffectCommons.IsJogress(_hashtable))
  114. {
  115. List<CardSource> selectedCards = new List<CardSource>();
  116. foreach (Func<CardSource, bool> level in Levels)
  117. {
  118. bool exitLoop = false;
  119. if (CardEffectCommons.HasMatchConditionOpponentsCardInTrash(card, level))
  120. {
  121. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  122. selectCardEffect.SetUp(
  123. canTargetCondition: level,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. canNoSelect: () => canSelectNo(),
  127. selectCardCoroutine: LevelSelected,
  128. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  129. message: $"Select level {Levels.IndexOf(level) + 3} Digimon card to add to the top of opponent's deck",
  130. maxCount: 1,
  131. canEndNotMax: false,
  132. isShowOpponent: true,
  133. mode: SelectCardEffect.Mode.Custom,
  134. root: SelectCardEffect.Root.Trash,
  135. customRootCardList: card.Owner.Enemy.TrashCards.Filter(level),
  136. canLookReverseCard: true,
  137. selectPlayer: card.Owner,
  138. cardEffect: activateClass);
  139. yield return StartCoroutine(selectCardEffect.Activate());
  140. }
  141. bool canSelectNo() => selectedCards.Count == 0;
  142. IEnumerator LevelSelected(CardSource cardSource)
  143. {
  144. if (cardSource != null)
  145. selectedCards.Add(cardSource);
  146. yield return null;
  147. }
  148. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  149. {
  150. if (cardSources.Count == 0)
  151. {
  152. exitLoop = true;
  153. }
  154. yield return null;
  155. }
  156. if (exitLoop)
  157. break;
  158. }
  159. if (selectedCards.Count >= 1)
  160. {
  161. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  162. selectCardEffect.SetUp(
  163. canTargetCondition: (CardSource) => true,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. canNoSelect: () => true,
  167. selectCardCoroutine: null,
  168. afterSelectCardCoroutine: AfterSelection,
  169. message: "Select order of cards to add to the top your deck\n(cards will be placed back to the top of the deck so that cards with lower numbers are on top).",
  170. maxCount: selectedCards.Count,
  171. canEndNotMax: false,
  172. isShowOpponent: true,
  173. mode: SelectCardEffect.Mode.Custom,
  174. root: SelectCardEffect.Root.Custom,
  175. customRootCardList: selectedCards,
  176. canLookReverseCard: true,
  177. selectPlayer: card.Owner,
  178. cardEffect: activateClass);
  179. yield return StartCoroutine(selectCardEffect.Activate());
  180. IEnumerator AfterSelection(List<CardSource> sources)
  181. {
  182. sources.Reverse();
  183. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(sources));
  184. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1 * sources.Count, activateClass));
  185. }
  186. }
  187. }
  188. }
  189. #endregion
  190. #region On Deletion
  191. if (timing == EffectTiming.OnDestroyedAnyone)
  192. {
  193. ActivateClass activateClass = new ActivateClass();
  194. activateClass.SetUpICardEffect("Play a [Millenniummon] from the trash", CanUseCondition, card);
  195. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  196. cardEffects.Add(activateClass);
  197. string EffectDescription()
  198. {
  199. return "[On Deletion] By returning 1 [Kimeramon] and 1 [Machinedramon] from your trash to the bottom of the deck, you may play 1 [Millenniummon] from your trash without paying the cost.";
  200. }
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  204. }
  205. bool CanActivateCondition(Hashtable hashtable)
  206. {
  207. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  208. && (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardConditionKimeramon)
  209. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardConditionMachinedramon));
  210. }
  211. bool CanSelectCardConditionKimeramon(CardSource cardSource)
  212. {
  213. return cardSource != null
  214. && cardSource.Owner == card.Owner
  215. && cardSource.EqualsCardName("Kimeramon");
  216. }
  217. bool CanSelectCardConditionMachinedramon(CardSource cardSource)
  218. {
  219. return cardSource != null
  220. && cardSource.Owner == card.Owner
  221. && cardSource.EqualsCardName("Machinedramon");
  222. }
  223. bool CanSelectCardConditionMilleniummon(CardSource cardSource)
  224. {
  225. return cardSource.EqualsCardName("Millenniummon")
  226. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Trash);
  227. }
  228. IEnumerator ActivateCoroutine(Hashtable hashtable)
  229. {
  230. bool returned = false;
  231. int maxCount = 2;
  232. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  233. selectCardEffect.SetUp(
  234. canTargetCondition: (cardSource) => CanSelectCardConditionKimeramon(cardSource) || CanSelectCardConditionMachinedramon(cardSource),
  235. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  236. canEndSelectCondition: CanEndSelectCondition,
  237. canNoSelect: () => true,
  238. selectCardCoroutine: null,
  239. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  240. message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  241. maxCount: maxCount,
  242. canEndNotMax: false,
  243. isShowOpponent: false,
  244. mode: SelectCardEffect.Mode.Custom,
  245. root: SelectCardEffect.Root.Trash,
  246. customRootCardList: null,
  247. canLookReverseCard: true,
  248. selectPlayer: card.Owner,
  249. cardEffect: activateClass);
  250. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  251. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  252. {
  253. if (cardSources.Count(CanSelectCardConditionKimeramon) >= 1
  254. && CanSelectCardConditionKimeramon(cardSource)
  255. && !CanSelectCardConditionMachinedramon(cardSource))
  256. {
  257. return false;
  258. }
  259. if (cardSources.Count(CanSelectCardConditionMachinedramon) >= 1
  260. && CanSelectCardConditionMachinedramon(cardSource)
  261. && !CanSelectCardConditionKimeramon(cardSource))
  262. {
  263. return false;
  264. }
  265. return true;
  266. }
  267. bool CanEndSelectCondition(List<CardSource> cardSources)
  268. {
  269. if (cardSources.Count(CanSelectCardConditionKimeramon) == 0)
  270. {
  271. return false;
  272. }
  273. if (cardSources.Count(CanSelectCardConditionMachinedramon) == 0)
  274. {
  275. return false;
  276. }
  277. return true;
  278. }
  279. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  280. {
  281. if (cardSources.Count == 2)
  282. {
  283. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  284. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  285. returned = true;
  286. }
  287. }
  288. if (returned)
  289. {
  290. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardConditionMilleniummon))
  291. {
  292. List<CardSource> selectedCards = new List<CardSource>();
  293. SelectCardEffect selectPlayEffect = GManager.instance.GetComponent<SelectCardEffect>();
  294. selectPlayEffect.SetUp(
  295. canTargetCondition: CanSelectCardConditionMilleniummon,
  296. canTargetCondition_ByPreSelecetedList: null,
  297. canEndSelectCondition: null,
  298. canNoSelect: () => true,
  299. selectCardCoroutine: SelectCardCoroutine,
  300. afterSelectCardCoroutine: null,
  301. message: "Select 1 card to play.",
  302. maxCount: 1,
  303. canEndNotMax: false,
  304. isShowOpponent: true,
  305. mode: SelectCardEffect.Mode.Custom,
  306. root: SelectCardEffect.Root.Trash,
  307. customRootCardList: null,
  308. canLookReverseCard: true,
  309. selectPlayer: card.Owner,
  310. cardEffect: activateClass);
  311. selectPlayEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  312. selectPlayEffect.SetUpCustomMessage_ShowCard("Played Card");
  313. yield return StartCoroutine(selectPlayEffect.Activate());
  314. IEnumerator SelectCardCoroutine(CardSource cardSource)
  315. {
  316. selectedCards.Add(cardSource);
  317. yield return null;
  318. }
  319. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  320. }
  321. }
  322. }
  323. }
  324. #endregion
  325. #region DigiXros
  326. if (timing == EffectTiming.None)
  327. {
  328. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  329. addDigiXrosConditionClass.SetUpICardEffect("DigiXros -2", CanUseCondition, card);
  330. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  331. addDigiXrosConditionClass.SetNotShowUI(true);
  332. cardEffects.Add(addDigiXrosConditionClass);
  333. bool CanUseCondition(Hashtable hashtable)
  334. {
  335. return true;
  336. }
  337. DigiXrosCondition GetDigiXros(CardSource cardSource)
  338. {
  339. if (cardSource == card)
  340. {
  341. DigiXrosConditionElement elementKimeramon =
  342. new DigiXrosConditionElement(CanSelectCardCondition, "Kimeramon");
  343. bool CanSelectCardCondition(CardSource conditionCardSource)
  344. {
  345. return conditionCardSource != null
  346. && conditionCardSource.Owner == card.Owner
  347. && conditionCardSource.IsDigimon
  348. && conditionCardSource.CardNames_DigiXros.Contains("Kimeramon");
  349. }
  350. DigiXrosConditionElement elementMachinedramon =
  351. new DigiXrosConditionElement(CanSelectCardCondition1, "Machinedramon");
  352. bool CanSelectCardCondition1(CardSource conditionCardSource)
  353. {
  354. return conditionCardSource != null
  355. && conditionCardSource.Owner == card.Owner
  356. && conditionCardSource.IsDigimon
  357. && conditionCardSource.CardNames_DigiXros.Contains("Machinedramon");
  358. }
  359. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  360. { elementKimeramon, elementMachinedramon };
  361. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  362. return digiXrosCondition;
  363. }
  364. return null;
  365. }
  366. }
  367. #endregion
  368. return cardEffects;
  369. }
  370. }
  371. }