EX8_029.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class 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.EqualsCardName("Plesiomon");
  28. bool PermanentCondition2(Permanent permanent) => permanent.TopCard.ContainsCardName("Seadramon") &&
  29. permanent.Levels_ForJogress(card).Any(value => value == 5);
  30. JogressConditionElement[] elements = new JogressConditionElement[]
  31. {
  32. new JogressConditionElement(PermanentCondition1, "Plesiomon"),
  33. new JogressConditionElement(PermanentCondition2, "a level 5 w/[Seadramon] in name"),
  34. };
  35. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  36. return jogressCondition;
  37. }
  38. return null;
  39. }
  40. }
  41. #endregion
  42. #region DNA Digivolve
  43. if (timing == EffectTiming.None)
  44. {
  45. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  46. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  47. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  48. addJogressConditionClass.SetNotShowUI(true);
  49. cardEffects.Add(addJogressConditionClass);
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return true;
  53. }
  54. JogressCondition GetJogress(CardSource cardSource)
  55. {
  56. if (cardSource == card)
  57. {
  58. bool PermanentCondition1(Permanent permanent) => (permanent.TopCard.CardColors.Contains(CardColor.Blue) || permanent.TopCard.CardColors.Contains(CardColor.Purple)) &&
  59. permanent.Levels_ForJogress(card).Contains(6);
  60. bool PermanentCondition2(Permanent permanent) => (permanent.TopCard.CardColors.Contains(CardColor.Black) || permanent.TopCard.CardColors.Contains(CardColor.Yellow)) &&
  61. permanent.Levels_ForJogress(card).Contains(6);
  62. JogressConditionElement[] elements = new JogressConditionElement[]
  63. {
  64. new JogressConditionElement(PermanentCondition1, "a level 6 blue/purple Digimon"),
  65. new JogressConditionElement(PermanentCondition2, "a level 6 black/yellow Digimon"),
  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 (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(cardSource.PermanentOfThisCard(), card))
  269. {
  270. return cardSource.EqualsTraits("DS");
  271. }
  272. return false;
  273. }
  274. bool SkillCondition(ICardEffect cardEffect)
  275. {
  276. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  277. {
  278. if (cardEffect.IsDigimonEffect)
  279. {
  280. return true;
  281. }
  282. if (cardEffect.IsDigimonEffect && cardEffect.IsSecurityEffect)
  283. {
  284. return true;
  285. }
  286. }
  287. return false;
  288. }
  289. }
  290. #endregion
  291. #region All Turns - Ignore On Play
  292. if (timing == EffectTiming.None)
  293. {
  294. DisableEffectClass invalidationClass = new DisableEffectClass();
  295. invalidationClass.SetUpICardEffect("[On Plays] can't activate", CanUseCondition, card);
  296. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  297. cardEffects.Add(invalidationClass);
  298. bool CanUseCondition(Hashtable hashtable)
  299. {
  300. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  301. {
  302. return card.Owner.MemoryForPlayer <= 1;
  303. }
  304. return false;
  305. }
  306. bool InvalidateCondition(ICardEffect cardEffect)
  307. {
  308. if (cardEffect != null)
  309. {
  310. if (cardEffect is ActivateICardEffect)
  311. {
  312. if (cardEffect.EffectSourceCard != null)
  313. {
  314. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(cardEffect.EffectSourceCard.PermanentOfThisCard(), card))
  315. {
  316. if (!cardEffect.EffectSourceCard.PermanentOfThisCard().TopCard.CanNotBeAffected(invalidationClass))
  317. {
  318. if (cardEffect.IsOnPlay)
  319. {
  320. return card.Owner.MemoryForPlayer <= 1;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. }
  327. return false;
  328. }
  329. }
  330. #endregion
  331. return cardEffects;
  332. }
  333. }
  334. }