P_220.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Millenniummon
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_220 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Kimeramon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 6,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region DNA Digivolution
  30. if (timing == EffectTiming.None)
  31. {
  32. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  33. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  34. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  35. addJogressConditionClass.SetNotShowUI(true);
  36. cardEffects.Add(addJogressConditionClass);
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return true;
  40. }
  41. JogressCondition GetJogress(CardSource cardSource)
  42. {
  43. if (cardSource == card)
  44. {
  45. bool PermanentCondition1(Permanent permanent)
  46. {
  47. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  48. {
  49. if (permanent.TopCard.EqualsCardName("Kimeramon"))
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. bool PermanentCondition2(Permanent permanent)
  57. {
  58. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  59. {
  60. if (permanent.TopCard.EqualsCardName("Machinedramon"))
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. JogressConditionElement[] elements = new JogressConditionElement[]
  68. {
  69. new JogressConditionElement(PermanentCondition1, "Kimeramon"),
  70. new JogressConditionElement(PermanentCondition2, "Machinedramon"),
  71. };
  72. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  73. return jogressCondition;
  74. }
  75. return null;
  76. }
  77. }
  78. #endregion
  79. #region Assembly
  80. if (timing == EffectTiming.None)
  81. {
  82. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  83. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  84. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  85. addAssemblyConditionClass.SetNotShowUI(true);
  86. cardEffects.Add(addAssemblyConditionClass);
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return true;
  90. }
  91. AssemblyCondition GetAssembly(CardSource cardSource)
  92. {
  93. if (cardSource == card)
  94. {
  95. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition);
  96. bool CanSelectCardCondition(CardSource cardSource)
  97. {
  98. return cardSource != null &&
  99. cardSource.Owner == card.Owner &&
  100. cardSource.IsDigimon &&
  101. cardSource.HasLevel &&
  102. (cardSource.EqualsTraits("Composite") ||
  103. cardSource.EqualsTraits("Ver.3") ||
  104. cardSource.EqualsTraits("Ver.5"));
  105. }
  106. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  107. {
  108. List<int> cardLevels = new List<int>();
  109. foreach (CardSource cardSource1 in cardSources)
  110. {
  111. if (!cardLevels.Contains(cardSource1.Level))
  112. {
  113. cardLevels.Add(cardSource1.Level);
  114. }
  115. foreach (int level in cardSource1.Level_Assembly)
  116. {
  117. if (!cardLevels.Contains(level))
  118. {
  119. cardLevels.Add(level);
  120. }
  121. }
  122. }
  123. if (cardSource.Level_Assembly.Count((level) => cardLevels.Contains(level)) >= 1 || cardLevels.Contains(cardSource.Level))
  124. {
  125. return false;
  126. }
  127. return true;
  128. }
  129. AssemblyCondition assemblyCondition = new AssemblyCondition(
  130. element:element,
  131. CanTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  132. selectMessage: "3 [Composite]/[Ver.3]/[Ver.5] Trait Digimon cards w/different levels",
  133. elementCount: 3,
  134. reduceCost: 6);
  135. return assemblyCondition;
  136. }
  137. return null;
  138. }
  139. }
  140. #endregion
  141. #region Reboot
  142. if (timing == EffectTiming.None)
  143. {
  144. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  145. }
  146. #endregion
  147. #region Blocker
  148. if (timing == EffectTiming.None)
  149. {
  150. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  151. }
  152. #endregion
  153. #region Shared OP / WD
  154. string SharedEffectName()
  155. => "<De-Digivolve 2>. Then Delete 1 Digimon";
  156. string SharedEffectDescription(string tag)
  157. {
  158. return $"[{tag}] <De-Digivolve 2> 1 of your opponent's Digimon. Then, you may delete 1 Digimon.";
  159. }
  160. bool SharedCanActivateCondition(Hashtable hashtable)
  161. {
  162. return CardEffectCommons.IsExistOnBattleArea(card);
  163. }
  164. bool PermanentSelectCondition(Permanent permanent)
  165. {
  166. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  167. }
  168. bool PermanentSelectCondition1(Permanent permanent)
  169. {
  170. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  171. }
  172. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  173. {
  174. #region De-digivolve 2
  175. if (CardEffectCommons.HasMatchConditionPermanent(PermanentSelectCondition))
  176. {
  177. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentSelectCondition));
  178. var selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  179. selectPermanentEffect.SetUp(
  180. selectPlayer: card.Owner,
  181. canTargetCondition: PermanentSelectCondition,
  182. canTargetCondition_ByPreSelecetedList: null,
  183. canEndSelectCondition: null,
  184. maxCount: maxCount,
  185. canNoSelect: false,
  186. canEndNotMax: false,
  187. selectPermanentCoroutine: SelectPermanentCoroutine,
  188. afterSelectPermanentCoroutine: null,
  189. mode: SelectPermanentEffect.Mode.Custom,
  190. cardEffect: activateClass);
  191. selectPermanentEffect.SetUpCustomMessage(
  192. "Select 1 Digimon to De-Digivolve.",
  193. "The opponent is selecting 1 Digimon to De-Digivolve.");
  194. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  195. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  196. {
  197. if (!permanent.TopCard.CanNotBeAffected(activateClass) && !permanent.ImmuneFromDeDigivolve()) {
  198. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 2, activateClass).Degeneration());
  199. }
  200. }
  201. }
  202. #endregion
  203. #region Delete 1
  204. if (CardEffectCommons.HasMatchConditionPermanent(PermanentSelectCondition1))
  205. {
  206. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentSelectCondition1));
  207. var selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  208. selectPermanentEffect.SetUp(
  209. selectPlayer: card.Owner,
  210. canTargetCondition: PermanentSelectCondition1,
  211. canTargetCondition_ByPreSelecetedList: null,
  212. canEndSelectCondition: null,
  213. maxCount: maxCount,
  214. canNoSelect: true,
  215. canEndNotMax: false,
  216. selectPermanentCoroutine: null,
  217. afterSelectPermanentCoroutine: null,
  218. mode: SelectPermanentEffect.Mode.Destroy,
  219. cardEffect: activateClass);
  220. selectPermanentEffect.SetUpCustomMessage(
  221. "Select 1 Digimon to Delete.",
  222. "The opponent is selecting 1 Digimon to Delete.");
  223. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  224. }
  225. #endregion
  226. }
  227. #endregion
  228. #region On Play
  229. if (timing == EffectTiming.OnEnterFieldAnyone)
  230. {
  231. ActivateClass activateClass = new ActivateClass();
  232. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  233. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("On Play"));
  234. cardEffects.Add(activateClass);
  235. bool CanUseCondition(Hashtable hashtable)
  236. {
  237. return CardEffectCommons.IsExistOnBattleArea(card) &&
  238. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  239. }
  240. }
  241. #endregion
  242. #region When Digivolving
  243. if (timing == EffectTiming.OnEnterFieldAnyone)
  244. {
  245. ActivateClass activateClass = new ActivateClass();
  246. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  247. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  248. cardEffects.Add(activateClass);
  249. bool CanUseCondition(Hashtable hashtable)
  250. {
  251. return CardEffectCommons.IsExistOnBattleArea(card) &&
  252. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  253. }
  254. }
  255. #endregion
  256. #region On Deletion
  257. if (timing == EffectTiming.OnDestroyedAnyone)
  258. {
  259. ActivateClass activateClass = new ActivateClass();
  260. activateClass.SetUpICardEffect("Return 3 cards to play 2 digimon from Trash", CanUseCondition, card);
  261. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  262. cardEffects.Add(activateClass);
  263. string EffectDiscription()
  264. {
  265. return "[On Deletion] By returning 3 [Composite], [Wicked God] or [DM] trait cards from your trash to the bottom of the deck, you may play 2 level 6 or lower [Composite], [Ver.3] or [Ver.5] trait Digimon cards from your trash without paying the costs. This effect can't play cards of the same level.";
  266. }
  267. bool CanUseCondition(Hashtable hashtable)
  268. {
  269. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  270. }
  271. bool CanActivateCondition(Hashtable hashtable)
  272. {
  273. return CardEffectCommons.CanActivateOnDeletion(card) &&
  274. card.Owner.TrashCards.Count(CardSelectCondition) >= 3;
  275. }
  276. bool CardSelectCondition(CardSource cardSource)
  277. {
  278. return cardSource.EqualsTraits("Composite") ||
  279. cardSource.EqualsTraits("Wicked God") ||
  280. cardSource.HasDMTraits;
  281. }
  282. bool CardSelectCondition1(CardSource cardSource)
  283. {
  284. return cardSource.IsDigimon &&
  285. cardSource.HasLevel &&
  286. cardSource.Level <= 6 &&
  287. (cardSource.EqualsTraits("Composite") ||
  288. cardSource.EqualsTraits("Ver.3") ||
  289. cardSource.EqualsTraits("Ver.5"));
  290. }
  291. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  292. {
  293. List<int> cardLevels = new List<int>();
  294. foreach (CardSource cardSource1 in cardSources)
  295. {
  296. if (!cardLevels.Contains(cardSource1.Level))
  297. {
  298. cardLevels.Add(cardSource1.Level);
  299. }
  300. }
  301. if (cardSource.Level_Assembly.Count((level) => cardLevels.Contains(level)) >= 1 || cardLevels.Contains(cardSource.Level))
  302. {
  303. return false;
  304. }
  305. return true;
  306. }
  307. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  308. {
  309. if (card.Owner.TrashCards.Count(CardSelectCondition) >= 3)
  310. {
  311. List<CardSource> selectedCards = new List<CardSource>();
  312. int maxCount = Math.Min(3, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CardSelectCondition));
  313. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  314. selectCardEffect.SetUp(
  315. canTargetCondition: CardSelectCondition,
  316. canTargetCondition_ByPreSelecetedList: null,
  317. canEndSelectCondition: null,
  318. canNoSelect: () => true,
  319. selectCardCoroutine: SelectCardCoroutine,
  320. afterSelectCardCoroutine: null,
  321. message: "3 [Composite]/[Wicked God]/[DM] Trait Digimon cards",
  322. maxCount: maxCount,
  323. canEndNotMax: false,
  324. isShowOpponent: true,
  325. mode: SelectCardEffect.Mode.Custom,
  326. root: SelectCardEffect.Root.Trash,
  327. customRootCardList: null,
  328. canLookReverseCard: true,
  329. selectPlayer: card.Owner,
  330. cardEffect: activateClass);
  331. IEnumerator SelectCardCoroutine(CardSource cardSource)
  332. {
  333. selectedCards.Add(cardSource);
  334. yield return null;
  335. }
  336. selectCardEffect.SetUpCustomMessage("Select 3 [Composite]/[Wicked God]/[DM] Trait Digimon cards to bottom deck", "Your opponent is selecting 3 Digimon cards to bottom deck");
  337. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Cards");
  338. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  339. if (selectedCards.Count == 3)
  340. {
  341. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ReturnRevealedCardsToLibraryBottom(
  342. remainingCards: selectedCards,
  343. activateClass: activateClass));
  344. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CardSelectCondition1)){
  345. List<CardSource> selectedCards1 = new List<CardSource>();
  346. int maxCount1 = Math.Min(2, card.Owner.TrashCards.Filter(CardSelectCondition1).Map(cardSource => cardSource.Level).Distinct().Count());
  347. SelectCardEffect selectCardEffect1 = GManager.instance.GetComponent<SelectCardEffect>();
  348. selectCardEffect1.SetUp(
  349. canTargetCondition: CardSelectCondition1,
  350. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  351. canEndSelectCondition: null,
  352. canNoSelect: () => true,
  353. selectCardCoroutine: SelectCardCoroutine1,
  354. afterSelectCardCoroutine: null,
  355. message: "2 [Composite]/[Ver.3]/[Ver.5] Trait Digimon cards with different levels",
  356. maxCount: maxCount1,
  357. canEndNotMax: false,
  358. isShowOpponent: true,
  359. mode: SelectCardEffect.Mode.Custom,
  360. root: SelectCardEffect.Root.Trash,
  361. customRootCardList: null,
  362. canLookReverseCard: true,
  363. selectPlayer: card.Owner,
  364. cardEffect: activateClass);
  365. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  366. {
  367. selectedCards1.Add(cardSource);
  368. yield return null;
  369. }
  370. selectCardEffect1.SetUpCustomMessage("Select 2 [Composite]/[Ver.3]/[Ver.5] Trait Digimon cards to play", "Your opponent is selecting 2 Digimon cards to play");
  371. selectCardEffect1.SetUpCustomMessage_ShowCard("Selected Cards");
  372. yield return ContinuousController.instance.StartCoroutine(selectCardEffect1.Activate());
  373. if (selectedCards1.Count() > 0)
  374. {
  375. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  376. cardSources: selectedCards1,
  377. activateClass: activateClass,
  378. payCost: false,
  379. isTapped: false,
  380. root: SelectCardEffect.Root.Trash,
  381. activateETB: true));
  382. }
  383. }
  384. }
  385. }
  386. }
  387. }
  388. #endregion
  389. return cardEffects;
  390. }
  391. }
  392. }