BT17_078.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_078 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region DNA Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  15. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  16. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  17. addJogressConditionClass.SetNotShowUI(true);
  18. cardEffects.Add(addJogressConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return true;
  22. }
  23. JogressCondition GetJogress(CardSource cardSource)
  24. {
  25. if (cardSource == card)
  26. {
  27. bool PermanentCondition1(Permanent permanent)
  28. {
  29. if (permanent != null)
  30. {
  31. if (permanent.TopCard != null)
  32. {
  33. if (permanent.TopCard.Owner == card.Owner)
  34. {
  35. if (permanent.IsDigimon)
  36. {
  37. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  38. {
  39. if (permanent.TopCard.ContainsCardName("Greymon"))
  40. {
  41. if (permanent.Levels_ForJogress(card).Contains(6))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool PermanentCondition2(Permanent permanent)
  54. {
  55. if (permanent != null)
  56. {
  57. if (permanent.TopCard != null)
  58. {
  59. if (permanent.TopCard.Owner == card.Owner)
  60. {
  61. if (permanent.IsDigimon)
  62. {
  63. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  64. {
  65. if (permanent.TopCard.ContainsCardName("Garurumon"))
  66. {
  67. if (permanent.Levels_ForJogress(card).Contains(6))
  68. {
  69. return true;
  70. }
  71. }
  72. }
  73. }
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79. JogressConditionElement[] elements = new JogressConditionElement[]
  80. {
  81. new JogressConditionElement(PermanentCondition1, "Lv.6 w/[Greymon] in name"),
  82. new JogressConditionElement(PermanentCondition2, "Lv.6 w/[Garurumon] in name"),
  83. };
  84. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  85. return jogressCondition;
  86. }
  87. return null;
  88. }
  89. }
  90. #endregion
  91. #region Blast DNA
  92. if (timing == EffectTiming.OnCounterTiming)
  93. {
  94. List<BlastDNACondition> blastDNAConditions = new List<BlastDNACondition>
  95. {
  96. new("WarGreymon"),
  97. new("MetalGarurumon")
  98. };
  99. cardEffects.Add(CardEffectFactory.BlastDNADigivolveEffect(card: card,
  100. blastDNAConditions: blastDNAConditions, condition: null));
  101. }
  102. #endregion
  103. #region Raid/Blocker
  104. if (timing == EffectTiming.OnAllyAttack)
  105. {
  106. cardEffects.Add(CardEffectFactory.RaidSelfEffect(
  107. isInheritedEffect: false,
  108. card: card,
  109. condition: null));
  110. }
  111. if (timing == EffectTiming.None)
  112. {
  113. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  114. isInheritedEffect: false,
  115. card: card,
  116. condition: null));
  117. }
  118. #endregion
  119. #region On Play Shared
  120. bool IsOpponentsDigimon(Permanent permanent)
  121. {
  122. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  123. }
  124. #endregion
  125. #region On Play
  126. if (timing == EffectTiming.OnEnterFieldAnyone)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("Return all digimon of a selected level, Then delete 1 Digimon", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  131. cardEffects.Add(activateClass);
  132. string EffectDiscription()
  133. {
  134. return "[On Play] If DNA Digivolving, choose 1 opponent's Digimon and return that Digimon and all of their Digimon with the same level to the bottom of the deck. Then, delete 1 of their Digimon.";
  135. }
  136. bool CanUseCondition(Hashtable hashtable)
  137. {
  138. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  139. {
  140. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  141. }
  142. return false;
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. if (CardEffectCommons.IsJogress(hashtable))
  151. {
  152. Permanent selectedPermanent = null;
  153. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  154. {
  155. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  156. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  157. selectPermanentEffect.SetUp(
  158. selectPlayer: card.Owner,
  159. canTargetCondition: IsOpponentsDigimon,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. maxCount: maxCount,
  163. canNoSelect: false,
  164. canEndNotMax: false,
  165. selectPermanentCoroutine: SelectPermanentLevelCoroutine,
  166. afterSelectPermanentCoroutine: null,
  167. mode: SelectPermanentEffect.Mode.Custom,
  168. cardEffect: activateClass);
  169. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to bottom deck all of same level.", "The opponent is selecting 1 Digimon to bottom deck all of same level.");
  170. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  171. }
  172. IEnumerator SelectPermanentLevelCoroutine(Permanent permanent)
  173. {
  174. if (permanent != null)
  175. selectedPermanent = permanent;
  176. yield return null;
  177. }
  178. if (selectedPermanent.TopCard.HasLevel)
  179. {
  180. List<Permanent> returnedPermanents = card.Owner.Enemy.GetBattleAreaDigimons()
  181. .Filter(permanent =>
  182. permanent.Level == selectedPermanent.Level &&
  183. !permanent.TopCard.CanNotBeAffected(activateClass));
  184. Hashtable _hashtable = new Hashtable();
  185. _hashtable.Add("CardEffect", activateClass);
  186. if (returnedPermanents.Count == 1)
  187. {
  188. yield return ContinuousController.instance.StartCoroutine(new DeckBottomBounceClass(returnedPermanents, _hashtable).DeckBounce());
  189. }
  190. else
  191. {
  192. List<CardSource> cardSources = returnedPermanents.Map(permanent => permanent.TopCard);
  193. List<SkillInfo> skillInfos = cardSources.Map(cardSource =>
  194. {
  195. ChangeBaseDPClass cardEffect = new ChangeBaseDPClass();
  196. cardEffect.SetUpICardEffect(" ", null, cardSource);
  197. return new SkillInfo(cardEffect, null, EffectTiming.None);
  198. });
  199. List<CardSource> selectedCards = new List<CardSource>();
  200. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  201. selectCardEffect.SetUp(
  202. canTargetCondition: (cardSource) => true,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. canNoSelect: () => false,
  206. selectCardCoroutine: null,
  207. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  208. message: "Specify the order to place the card 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).",
  209. maxCount: cardSources.Count,
  210. canEndNotMax: false,
  211. isShowOpponent: false,
  212. mode: SelectCardEffect.Mode.Custom,
  213. root: SelectCardEffect.Root.Custom,
  214. customRootCardList: cardSources,
  215. canLookReverseCard: true,
  216. selectPlayer: card.Owner,
  217. cardEffect: activateClass);
  218. selectCardEffect.SetNotShowCard();
  219. selectCardEffect.SetNotAddLog();
  220. selectCardEffect.SetUpSkillInfos(skillInfos);
  221. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  222. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  223. {
  224. if (cardSources.Count >= 1)
  225. {
  226. selectedCards = cardSources.Clone();
  227. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  228. }
  229. }
  230. if (selectedCards.Count >= 1)
  231. {
  232. List<Permanent> libraryPermanets = selectedCards.Map(cardSource => cardSource.PermanentOfThisCard());
  233. if (libraryPermanets.Count >= 1)
  234. {
  235. DeckBottomBounceClass putLibraryBottomPermanent = new DeckBottomBounceClass(libraryPermanets, _hashtable);
  236. putLibraryBottomPermanent.SetNotShowCards();
  237. yield return ContinuousController.instance.StartCoroutine(putLibraryBottomPermanent.DeckBounce());
  238. }
  239. }
  240. }
  241. }
  242. }
  243. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  244. {
  245. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  246. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  247. selectPermanentEffect.SetUp(
  248. selectPlayer: card.Owner,
  249. canTargetCondition: IsOpponentsDigimon,
  250. canTargetCondition_ByPreSelecetedList: null,
  251. canEndSelectCondition: null,
  252. maxCount: maxCount,
  253. canNoSelect: false,
  254. canEndNotMax: false,
  255. selectPermanentCoroutine: null,
  256. afterSelectPermanentCoroutine: null,
  257. mode: SelectPermanentEffect.Mode.Destroy,
  258. cardEffect: activateClass);
  259. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  260. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  261. }
  262. }
  263. }
  264. #endregion
  265. #region When Digivolving
  266. if (timing == EffectTiming.OnEnterFieldAnyone)
  267. {
  268. ActivateClass activateClass = new ActivateClass();
  269. activateClass.SetUpICardEffect("Return all digimon of a selected level, Then delete 1 Digimon", CanUseCondition, card);
  270. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  271. cardEffects.Add(activateClass);
  272. string EffectDiscription()
  273. {
  274. return "[When Digivolving] If DNA Digivolving, choose 1 opponent's Digimon and return that Digimon and all of their Digimon with the same level to the bottom of the deck. Then, delete 1 of their Digimon.";
  275. }
  276. bool CanUseCondition(Hashtable hashtable)
  277. {
  278. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  279. {
  280. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  281. }
  282. return false;
  283. }
  284. bool CanActivateCondition(Hashtable hashtable)
  285. {
  286. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  287. }
  288. IEnumerator ActivateCoroutine(Hashtable hashtable)
  289. {
  290. if (CardEffectCommons.IsJogress(hashtable))
  291. {
  292. Permanent selectedPermanent = null;
  293. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  294. {
  295. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  296. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  297. selectPermanentEffect.SetUp(
  298. selectPlayer: card.Owner,
  299. canTargetCondition: IsOpponentsDigimon,
  300. canTargetCondition_ByPreSelecetedList: null,
  301. canEndSelectCondition: null,
  302. maxCount: maxCount,
  303. canNoSelect: false,
  304. canEndNotMax: false,
  305. selectPermanentCoroutine: SelectPermanentLevelCoroutine,
  306. afterSelectPermanentCoroutine: null,
  307. mode: SelectPermanentEffect.Mode.Custom,
  308. cardEffect: activateClass);
  309. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to bottom deck all of same level.", "The opponent is selecting 1 Digimon to bottom deck all of same level.");
  310. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  311. }
  312. IEnumerator SelectPermanentLevelCoroutine(Permanent permanent)
  313. {
  314. if (permanent != null)
  315. selectedPermanent = permanent;
  316. yield return null;
  317. }
  318. if (selectedPermanent.TopCard.HasLevel)
  319. {
  320. List<Permanent> returnedPermanents = card.Owner.Enemy.GetBattleAreaDigimons()
  321. .Filter(permanent =>
  322. permanent.Level == selectedPermanent.Level &&
  323. !permanent.TopCard.CanNotBeAffected(activateClass));
  324. Hashtable _hashtable = new Hashtable();
  325. _hashtable.Add("CardEffect", activateClass);
  326. if (returnedPermanents.Count == 1)
  327. {
  328. yield return ContinuousController.instance.StartCoroutine(new DeckBottomBounceClass(returnedPermanents, _hashtable).DeckBounce());
  329. }
  330. else
  331. {
  332. List<CardSource> cardSources = returnedPermanents.Map(permanent => permanent.TopCard);
  333. List<SkillInfo> skillInfos = cardSources.Map(cardSource =>
  334. {
  335. ChangeBaseDPClass cardEffect = new ChangeBaseDPClass();
  336. cardEffect.SetUpICardEffect(" ", null, cardSource);
  337. return new SkillInfo(cardEffect, null, EffectTiming.None);
  338. });
  339. List<CardSource> selectedCards = new List<CardSource>();
  340. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  341. selectCardEffect.SetUp(
  342. canTargetCondition: (cardSource) => true,
  343. canTargetCondition_ByPreSelecetedList: null,
  344. canEndSelectCondition: null,
  345. canNoSelect: () => false,
  346. selectCardCoroutine: null,
  347. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  348. message: "Specify the order to place the card 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).",
  349. maxCount: cardSources.Count,
  350. canEndNotMax: false,
  351. isShowOpponent: false,
  352. mode: SelectCardEffect.Mode.Custom,
  353. root: SelectCardEffect.Root.Custom,
  354. customRootCardList: cardSources,
  355. canLookReverseCard: true,
  356. selectPlayer: card.Owner,
  357. cardEffect: activateClass);
  358. selectCardEffect.SetNotShowCard();
  359. selectCardEffect.SetNotAddLog();
  360. selectCardEffect.SetUpSkillInfos(skillInfos);
  361. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  362. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  363. {
  364. if (cardSources.Count >= 1)
  365. {
  366. selectedCards = cardSources.Clone();
  367. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  368. }
  369. }
  370. if (selectedCards.Count >= 1)
  371. {
  372. List<Permanent> libraryPermanets = selectedCards.Map(cardSource => cardSource.PermanentOfThisCard());
  373. if (libraryPermanets.Count >= 1)
  374. {
  375. DeckBottomBounceClass putLibraryBottomPermanent = new DeckBottomBounceClass(libraryPermanets, _hashtable);
  376. putLibraryBottomPermanent.SetNotShowCards();
  377. yield return ContinuousController.instance.StartCoroutine(putLibraryBottomPermanent.DeckBounce());
  378. }
  379. }
  380. }
  381. }
  382. }
  383. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  384. {
  385. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  386. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  387. selectPermanentEffect.SetUp(
  388. selectPlayer: card.Owner,
  389. canTargetCondition: IsOpponentsDigimon,
  390. canTargetCondition_ByPreSelecetedList: null,
  391. canEndSelectCondition: null,
  392. maxCount: maxCount,
  393. canNoSelect: false,
  394. canEndNotMax: false,
  395. selectPermanentCoroutine: null,
  396. afterSelectPermanentCoroutine: null,
  397. mode: SelectPermanentEffect.Mode.Destroy,
  398. cardEffect: activateClass);
  399. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  400. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  401. }
  402. }
  403. }
  404. #endregion
  405. return cardEffects;
  406. }
  407. }
  408. }