EX6_018.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_018 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Cupimon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 5,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Play Cost Reduction
  29. if (timing == EffectTiming.None)
  30. {
  31. ChangeCostClass changeCostClass = new ChangeCostClass();
  32. changeCostClass.SetUpICardEffect($"Play Cost -5", CanUseCondition, card);
  33. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost,
  34. cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: IsUpDown,
  35. isCheckAvailability: () => false, isChangePayingCost: () => true);
  36. cardEffects.Add(changeCostClass);
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. if (card.Owner.HandCards.Contains(card))
  40. {
  41. if (!CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsPermanentLevel5OrLower))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool IsPermanentLevel5OrLower(Permanent permanent)
  49. {
  50. return permanent.IsDigimon && permanent.Level <= 5;
  51. }
  52. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  53. List<Permanent> targetPermanents)
  54. {
  55. if (CardSourceCondition(cardSource))
  56. {
  57. if (RootCondition(root))
  58. {
  59. if (PermanentsCondition(targetPermanents))
  60. {
  61. cost -= 5;
  62. }
  63. }
  64. }
  65. return cost;
  66. }
  67. bool PermanentsCondition(List<Permanent> targetPermanents)
  68. {
  69. if (targetPermanents == null)
  70. {
  71. return true;
  72. }
  73. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  74. {
  75. return true;
  76. }
  77. return false;
  78. }
  79. bool CardSourceCondition(CardSource cardSource)
  80. {
  81. return cardSource == card;
  82. }
  83. bool RootCondition(SelectCardEffect.Root root)
  84. {
  85. return true;
  86. }
  87. bool IsUpDown()
  88. {
  89. return true;
  90. }
  91. }
  92. #endregion
  93. #region On Play/ Start of Your Main Phase Shared
  94. bool CanSelectCardSharedCondition(CardSource cardSource)
  95. {
  96. if (cardSource.CardTraits.Contains("Angel") ||
  97. cardSource.CardTraits.Contains("Archangel") ||
  98. cardSource.CardTraits.Contains("Three Great Angels") ||
  99. cardSource.CardTraits.Contains("ThreeGreatAngels") ||
  100. cardSource.CardTraits.Contains("Seven Great Demon Lords") ||
  101. cardSource.CardTraits.Contains("SevenGreatDemonLords"))
  102. {
  103. return true;
  104. }
  105. return false;
  106. }
  107. bool CanActivateSharedCondition(Hashtable hashtable)
  108. {
  109. if (CardEffectCommons.IsExistOnBattleArea(card))
  110. {
  111. if (card.Owner.LibraryCards.Count >= 1)
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. #endregion
  119. #region On Play
  120. if (timing == EffectTiming.OnEnterFieldAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false,
  125. EffectDescription());
  126. cardEffects.Add(activateClass);
  127. string EffectDescription()
  128. {
  129. return
  130. "[On Play] Reveal the top 3 cards of your deck. Add 1 card with the [Angel]/[Archangel]/[Three Great Angels]/[Seven Great Demon Lords] trait among them to your hand. Trash the rest.";
  131. }
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable hashtable)
  137. {
  138. yield return ContinuousController.instance.StartCoroutine(
  139. CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  140. revealCount: 3,
  141. simplifiedSelectCardConditions:
  142. new[]
  143. {
  144. new SimplifiedSelectCardConditionClass(
  145. canTargetCondition: CanSelectCardSharedCondition,
  146. message:
  147. "Select 1 Digimon card with the [Angel]/[Archangel]/[Three Great Angels]/[Seven Great Demon Lords] trait.",
  148. mode: SelectCardEffect.Mode.AddHand,
  149. maxCount: 1,
  150. selectCardCoroutine: null),
  151. },
  152. remainingCardsPlace: RemainingCardsPlace.Trash,
  153. activateClass: activateClass
  154. ));
  155. }
  156. }
  157. #endregion
  158. #region Start of Your Main Phase
  159. if (timing == EffectTiming.OnStartMainPhase)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false,
  164. EffectDescription());
  165. cardEffects.Add(activateClass);
  166. string EffectDescription()
  167. {
  168. return
  169. "[Start of Your Main Phase] Reveal the top 3 cards of your deck. Add 1 card with the [Angel]/[Archangel]/[Three Great Angels]/[Seven Great Demon Lords] trait among them to your hand. Trash the rest.";
  170. }
  171. bool CanUseCondition(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.IsExistOnBattleArea(card))
  174. {
  175. if (CardEffectCommons.IsOwnerTurn(card))
  176. {
  177. return true;
  178. }
  179. }
  180. return false;
  181. }
  182. IEnumerator ActivateCoroutine(Hashtable hashtable)
  183. {
  184. yield return ContinuousController.instance.StartCoroutine(
  185. CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  186. revealCount: 3,
  187. simplifiedSelectCardConditions:
  188. new[]
  189. {
  190. new SimplifiedSelectCardConditionClass(
  191. canTargetCondition: CanSelectCardSharedCondition,
  192. message:
  193. "Select 1 Digimon card with the [Angel]/[Archangel]/[Three Great Angels]/[Seven Great Demon Lords] trait.",
  194. mode: SelectCardEffect.Mode.AddHand,
  195. maxCount: 1,
  196. selectCardCoroutine: null),
  197. },
  198. remainingCardsPlace: RemainingCardsPlace.Trash,
  199. activateClass: activateClass
  200. ));
  201. }
  202. }
  203. #endregion
  204. #region End of Your Turn
  205. if (timing == EffectTiming.OnEndTurn)
  206. {
  207. ActivateClass activateClass = new ActivateClass();
  208. activateClass.SetUpICardEffect(
  209. "Place one of your level 6 Digimon on top of your security stack to digivolve into [Lucemon: Chaos Mode] in the trash without paying the cost.",
  210. CanUseCondition, card);
  211. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  212. activateClass.SetHashString("EOT_EX6-018");
  213. cardEffects.Add(activateClass);
  214. string EffectDescription()
  215. {
  216. return
  217. "[End of Your Turn] [Once Per Turn] By placing one of your level 6 Digimon on top of your security stack, this Digimon may digivolve into [Lucemon: Chaos Mode] in the trash without paying the cost.";
  218. }
  219. bool IsPermanentLevel6Condition(Permanent permanent)
  220. {
  221. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  222. {
  223. if (permanent.TopCard.IsLevel6)
  224. {
  225. return true;
  226. }
  227. }
  228. return false;
  229. }
  230. bool IsCardLucemonChaosModeCondition(CardSource cardSource)
  231. {
  232. if (cardSource.IsDigimon)
  233. {
  234. if (cardSource.ContainsCardName("Lucemon: Chaos Mode") ||
  235. cardSource.ContainsCardName("Lucemon:ChaosMode") ||
  236. cardSource.ContainsCardName("Lucemon Chaos Mode") ||
  237. cardSource.ContainsCardName("LucemonChaosMode"))
  238. {
  239. if (cardSource.CanEvolve(card.PermanentOfThisCard(), true))
  240. {
  241. return true;
  242. }
  243. }
  244. }
  245. return false;
  246. }
  247. bool CanUseCondition(Hashtable hashtable)
  248. {
  249. if (CardEffectCommons.IsExistOnBattleArea(card))
  250. {
  251. if (CardEffectCommons.IsOwnerTurn(card))
  252. {
  253. return true;
  254. }
  255. }
  256. return false;
  257. }
  258. bool CanActivateCondition(Hashtable hashtable)
  259. {
  260. if (CardEffectCommons.IsExistOnBattleArea(card))
  261. {
  262. if (CardEffectCommons.HasMatchConditionPermanent(IsPermanentLevel6Condition))
  263. {
  264. return true;
  265. }
  266. }
  267. return false;
  268. }
  269. IEnumerator ActivateCoroutine(Hashtable hashtable)
  270. {
  271. if (CardEffectCommons.HasMatchConditionPermanent(IsPermanentLevel6Condition))
  272. {
  273. Permanent selectedPermanent = null;
  274. int maxCount = Math.Min(1,
  275. CardEffectCommons.MatchConditionPermanentCount(IsPermanentLevel6Condition));
  276. SelectPermanentEffect selectPermanentEffect =
  277. GManager.instance.GetComponent<SelectPermanentEffect>();
  278. selectPermanentEffect.SetUp(
  279. selectPlayer: card.Owner,
  280. canTargetCondition: IsPermanentLevel6Condition,
  281. canTargetCondition_ByPreSelecetedList: null,
  282. canEndSelectCondition: null,
  283. maxCount: maxCount,
  284. canNoSelect: true,
  285. canEndNotMax: false,
  286. selectPermanentCoroutine: SelectPermanentCoroutine,
  287. afterSelectPermanentCoroutine: null,
  288. mode: SelectPermanentEffect.Mode.Custom,
  289. cardEffect: activateClass);
  290. selectPermanentEffect.SetUpCustomMessage(
  291. "Select 1 Digimon to place on top of your security stack.",
  292. "The opponent is selecting 1 Digimon to place on top of their security stack.");
  293. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  294. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  295. {
  296. selectedPermanent = permanent;
  297. yield return null;
  298. }
  299. if (selectedPermanent != null)
  300. {
  301. if (selectedPermanent.TopCard != null)
  302. {
  303. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  304. {
  305. CardSource securityCard = selectedPermanent.TopCard;
  306. yield return ContinuousController.instance.StartCoroutine(
  307. new IPutSecurityPermanent(selectedPermanent,
  308. CardEffectCommons.CardEffectHashtable(activateClass),
  309. toTop: true).PutSecurity());
  310. if (selectedPermanent.TopCard == null)
  311. {
  312. if (!CardEffectCommons.IsExistOnBattleArea(securityCard))
  313. {
  314. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsCardLucemonChaosModeCondition))
  315. {
  316. yield return ContinuousController.instance.StartCoroutine(
  317. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  318. targetPermanent: card.PermanentOfThisCard(),
  319. cardCondition: IsCardLucemonChaosModeCondition,
  320. payCost: false,
  321. reduceCostTuple: null,
  322. fixedCostTuple: null,
  323. ignoreDigivolutionRequirementFixedCost: -1,
  324. isHand: false,
  325. activateClass: activateClass,
  326. successProcess: null));
  327. }
  328. }
  329. }
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. #endregion
  337. return cardEffects;
  338. }
  339. }
  340. }