Aegisdramon_EX8_029.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class Aegisdramon_EX8_029 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region DNA Digivolve
  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) => (permanent.TopCard.CardColors.Contains(CardColor.Blue) || permanent.TopCard.CardColors.Contains(CardColor.Purple)) &&
  28. permanent.Levels_ForJogress(card).Contains(6);
  29. bool PermanentCondition2(Permanent permanent) => (permanent.TopCard.CardColors.Contains(CardColor.Black) || permanent.TopCard.CardColors.Contains(CardColor.Yellow)) &&
  30. permanent.Levels_ForJogress(card).Contains(6);
  31. JogressConditionElement[] elements = new JogressConditionElement[]
  32. {
  33. new JogressConditionElement(PermanentCondition1, "a level 6 blue/purple Digimon"),
  34. new JogressConditionElement(PermanentCondition2, "a level 6 black/yellow Digimon"),
  35. };
  36. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  37. return jogressCondition;
  38. }
  39. return null;
  40. }
  41. }
  42. #endregion
  43. #region DNA Digivolve
  44. if (timing == EffectTiming.None)
  45. {
  46. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  47. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  48. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  49. addJogressConditionClass.SetNotShowUI(true);
  50. cardEffects.Add(addJogressConditionClass);
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return true;
  54. }
  55. JogressCondition GetJogress(CardSource cardSource)
  56. {
  57. if (cardSource == card)
  58. {
  59. bool PermanentCondition1(Permanent permanent) => permanent.TopCard.EqualsCardName("Plesiomon");
  60. bool PermanentCondition2(Permanent permanent) => permanent.TopCard.ContainsCardName("Seadramon") &&
  61. permanent.Levels_ForJogress(card).Any(value => value >= 5);
  62. JogressConditionElement[] elements = new JogressConditionElement[]
  63. {
  64. new JogressConditionElement(PermanentCondition1, "Plesiomon"),
  65. new JogressConditionElement(PermanentCondition2, "a level 5 or higher w/[Seadramon] in name"),
  66. };
  67. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  68. return jogressCondition;
  69. }
  70. return null;
  71. }
  72. }
  73. #endregion
  74. #region When Digivolving
  75. if (timing == EffectTiming.OnEnterFieldAnyone)
  76. {
  77. int maxCost = 14;
  78. int maxPlay = 12;
  79. ActivateClass activateClass = new ActivateClass();
  80. activateClass.SetUpICardEffect("Return 14 play cost of Digimon", CanUseCondition, card);
  81. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  82. cardEffects.Add(activateClass);
  83. string EffectDiscription()
  84. {
  85. return "[When Digivolving] Return 14 play cost's total worth of your opponent's Digimon to the bottom of the deck. If DNA digivolving, you may play 12 play cost's total worth of [DS] trait Digimon from this Digimon's digivolution cards without paying the cost.";
  86. }
  87. bool CanSelectPermanentCondition(Permanent permanent)
  88. {
  89. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  90. {
  91. if (permanent.TopCard.GetCostItself <= maxCost)
  92. {
  93. if (permanent.TopCard.HasPlayCost)
  94. {
  95. return true;
  96. }
  97. }
  98. }
  99. return false;
  100. }
  101. bool CanSelectCardCondition(CardSource source)
  102. {
  103. if (CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.DigivolutionCards))
  104. {
  105. if (source.EqualsTraits("DS"))
  106. {
  107. if (source.GetCostItself <= maxCost)
  108. {
  109. if (source.HasPlayCost)
  110. {
  111. return true;
  112. }
  113. }
  114. }
  115. }
  116. return false;
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  121. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleArea(card);
  126. }
  127. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  128. {
  129. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  130. {
  131. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition);
  132. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: CanSelectPermanentCondition,
  136. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  137. canEndSelectCondition: CanEndSelectCondition,
  138. maxCount: maxCount,
  139. canNoSelect: false,
  140. canEndNotMax: true,
  141. selectPermanentCoroutine: null,
  142. afterSelectPermanentCoroutine: null,
  143. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  144. cardEffect: activateClass);
  145. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  146. bool CanEndSelectCondition(List<Permanent> permanents)
  147. {
  148. if (permanents.Count <= 0)
  149. {
  150. return false;
  151. }
  152. int sumCost = 0;
  153. foreach (Permanent permanent1 in permanents)
  154. {
  155. sumCost += permanent1.TopCard.GetCostItself;
  156. }
  157. if (sumCost > maxCost)
  158. {
  159. return false;
  160. }
  161. return true;
  162. }
  163. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  164. {
  165. int sumCost = 0;
  166. foreach (Permanent permanent1 in permanents)
  167. {
  168. sumCost += permanent1.TopCard.GetCostItself;
  169. }
  170. sumCost += permanent.TopCard.GetCostItself;
  171. if (sumCost > maxCost)
  172. {
  173. return false;
  174. }
  175. return true;
  176. }
  177. }
  178. if (CardEffectCommons.IsJogress(_hashtable))
  179. {
  180. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) > 0)
  181. {
  182. List<CardSource> selectedCards = new List<CardSource>();
  183. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  184. selectCardEffect.SetUp(
  185. canTargetCondition: CanSelectCardCondition,
  186. canTargetCondition_ByPreSelecetedList: CanTargetCardCondition_ByPreSelecetedList,
  187. canEndSelectCondition: CanEndSelectCardCondition,
  188. canNoSelect: () => true,
  189. selectCardCoroutine: SelectCardCoroutine,
  190. afterSelectCardCoroutine: null,
  191. message: "Select up to 12 play cost to play.",
  192. maxCount: card.PermanentOfThisCard().DigivolutionCards.Count,
  193. canEndNotMax: true,
  194. isShowOpponent: true,
  195. mode: SelectCardEffect.Mode.Custom,
  196. root: SelectCardEffect.Root.Custom,
  197. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  198. canLookReverseCard: true,
  199. selectPlayer: card.Owner,
  200. cardEffect: activateClass);
  201. selectCardEffect.SetUpCustomMessage("Select up to 12 play cost to play.", "The opponent is selecting up to 12 play cost to play.");
  202. yield return StartCoroutine(selectCardEffect.Activate());
  203. bool CanEndSelectCardCondition(List<CardSource> cards)
  204. {
  205. if (cards.Count <= 0)
  206. {
  207. return false;
  208. }
  209. int sumCost = 0;
  210. foreach (CardSource source in cards)
  211. {
  212. sumCost += source.GetCostItself;
  213. }
  214. if (sumCost > maxPlay)
  215. {
  216. return false;
  217. }
  218. return true;
  219. }
  220. bool CanTargetCardCondition_ByPreSelecetedList(List<CardSource> cards, CardSource source)
  221. {
  222. int sumCost = 0;
  223. foreach (CardSource source1 in cards)
  224. {
  225. sumCost += source1.GetCostItself;
  226. }
  227. sumCost += source.GetCostItself;
  228. if (sumCost > maxPlay)
  229. {
  230. return false;
  231. }
  232. return true;
  233. }
  234. IEnumerator SelectCardCoroutine(CardSource cardSource)
  235. {
  236. selectedCards.Add(cardSource);
  237. yield return null;
  238. }
  239. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  240. cardSources: selectedCards,
  241. activateClass: activateClass,
  242. payCost: false,
  243. isTapped: false,
  244. root: SelectCardEffect.Root.DigivolutionCards,
  245. activateETB: true));
  246. }
  247. }
  248. }
  249. }
  250. #endregion
  251. #region All Turns - Immune
  252. if (timing == EffectTiming.None)
  253. {
  254. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  255. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseCondition, card);
  256. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  257. cardEffects.Add(canNotAffectedClass);
  258. bool CanUseCondition(Hashtable hashtable)
  259. {
  260. if (CardEffectCommons.IsExistOnBattleArea(card))
  261. {
  262. return card.Owner.MemoryForPlayer >= 1;
  263. }
  264. return false;
  265. }
  266. bool CardCondition(CardSource cardSource)
  267. {
  268. if (cardSource == card)
  269. {
  270. if (CardEffectCommons.IsExistOnBattleArea(card))
  271. {
  272. if (cardSource == card.PermanentOfThisCard().TopCard)
  273. {
  274. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(cardSource.PermanentOfThisCard(), card);
  275. }
  276. }
  277. }
  278. return false;
  279. }
  280. bool SkillCondition(ICardEffect cardEffect)
  281. {
  282. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  283. {
  284. if (cardEffect.IsDigimonEffect)
  285. {
  286. return true;
  287. }
  288. if (cardEffect.IsDigimonEffect && cardEffect.IsSecurityEffect)
  289. {
  290. return true;
  291. }
  292. }
  293. return false;
  294. }
  295. }
  296. #endregion
  297. #region All Turns - Ignore On Play
  298. if (timing == EffectTiming.None)
  299. {
  300. DisableEffectClass invalidationClass = new DisableEffectClass();
  301. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseCondition, card);
  302. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  303. cardEffects.Add(invalidationClass);
  304. bool CanUseCondition(Hashtable hashtable)
  305. {
  306. if (CardEffectCommons.IsExistOnBattleArea(card))
  307. {
  308. return card.Owner.MemoryForPlayer <= 1;
  309. }
  310. return false;
  311. }
  312. bool InvalidateCondition(ICardEffect cardEffect)
  313. {
  314. if (cardEffect != null)
  315. {
  316. if (cardEffect is ActivateICardEffect)
  317. {
  318. if (cardEffect.EffectSourceCard != null)
  319. {
  320. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(cardEffect.EffectSourceCard.PermanentOfThisCard(), card))
  321. {
  322. if (!cardEffect.EffectSourceCard.PermanentOfThisCard().TopCard.CanNotBeAffected(invalidationClass))
  323. {
  324. if (cardEffect.IsOnPlay)
  325. {
  326. return true;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. }
  333. return false;
  334. }
  335. }
  336. #endregion
  337. return cardEffects;
  338. }
  339. }
  340. }