EX9_021.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using TMPro;
  5. //Omnimon Alter-S
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_021 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. //Lv.6 w / [DM] trait: Cost 5
  15. if (timing == EffectTiming.None)
  16. {
  17. static bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasDMTraits && targetPermanent.TopCard.IsLevel6;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region DNA Digivolution
  25. //Blue Lv.6 + Red Lv.6 : Cost 0
  26. if (timing == EffectTiming.None)
  27. {
  28. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  29. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  30. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  31. addJogressConditionClass.SetNotShowUI(true);
  32. cardEffects.Add(addJogressConditionClass);
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return true;
  36. }
  37. JogressCondition GetJogress(CardSource cardSource)
  38. {
  39. if (cardSource == card)
  40. {
  41. bool PermanentCondition1(Permanent permanent)
  42. {
  43. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  44. {
  45. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  46. {
  47. if (permanent.Levels_ForJogress(card).Contains(6))
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. bool PermanentCondition2(Permanent permanent)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  58. {
  59. if (permanent.TopCard.CardColors.Contains(CardColor.Red))
  60. {
  61. if (permanent.Levels_ForJogress(card).Contains(6))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. JogressConditionElement[] elements = new JogressConditionElement[]
  70. {
  71. new JogressConditionElement(PermanentCondition1, "a level 6 blue Digimon"),
  72. new JogressConditionElement(PermanentCondition2, "a level 6 red Digimon"),
  73. };
  74. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  75. return jogressCondition;
  76. }
  77. return null;
  78. }
  79. }
  80. #endregion
  81. #region When Digivolving
  82. if (timing == EffectTiming.OnEnterFieldAnyone)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("If DNA, unaffected by opponents effect, Delete Digimon with highest level.", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  87. cardEffects.Add(activateClass);
  88. string EffectDiscription()
  89. {
  90. return "[When Digivolving] If DNA digivolving, your opponent's effects don't affect this Digimon for the turn. Then, delete all of their Digimon with the highest level.";
  91. }
  92. bool PermanentCondition(Permanent permanent)
  93. {
  94. return CardEffectCommons.IsMaxLevel(permanent, card.Owner.Enemy);
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  99. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  100. }
  101. bool CanActivateCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  104. }
  105. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  106. {
  107. if (CardEffectCommons.IsJogress(_hashtable))
  108. {
  109. Permanent selectedPermanent = card.PermanentOfThisCard();
  110. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  111. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's effect", CanUseCondition1, card);
  112. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  113. selectedPermanent.UntilEachTurnEndEffects.Add((_timing) => canNotAffectedClass);
  114. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  115. bool CanUseCondition1(Hashtable hashtable)
  116. {
  117. if (selectedPermanent.TopCard != null)
  118. {
  119. return true;
  120. }
  121. return false;
  122. }
  123. bool CardCondition(CardSource cardSource)
  124. {
  125. if (selectedPermanent.TopCard != null)
  126. {
  127. if (selectedPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(selectedPermanent))
  128. {
  129. if (cardSource == selectedPermanent.TopCard)
  130. {
  131. return true;
  132. }
  133. }
  134. }
  135. return false;
  136. }
  137. bool SkillCondition(ICardEffect cardEffect)
  138. {
  139. if (cardEffect != null)
  140. {
  141. if (cardEffect.EffectSourceCard != null)
  142. {
  143. if (cardEffect.EffectSourceCard.Owner == card.Owner.Enemy)
  144. {
  145. return true;
  146. }
  147. }
  148. }
  149. return false;
  150. }
  151. }
  152. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  153. if (card.Owner.Enemy.GetBattleAreaDigimons().Count > 0)
  154. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  155. }
  156. }
  157. #endregion
  158. #region End of Attack
  159. if (timing == EffectTiming.OnEndAttack)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("Play 2 sources, place on top of security", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  164. cardEffects.Add(activateClass);
  165. string EffectDiscription()
  166. {
  167. return "[End of Attack] You may play 1 card with [Greymon] in its name or the [Ver.1] trait and 1 card with [Garurumon] in its name or the [Ver.2] trait from this Digimon's digivolution cards without paying the costs. If this effect played, place this Digimon as your top security card.";
  168. }
  169. bool CanSelectCardCondition(CardSource cardSource)
  170. {
  171. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  172. {
  173. if (cardSource.IsDigimon)
  174. {
  175. if (cardSource.HasGreymonName || cardSource.EqualsTraits("Ver.1"))
  176. {
  177. return true;
  178. }
  179. }
  180. }
  181. return false;
  182. }
  183. bool CanSelectCardCondition1(CardSource cardSource)
  184. {
  185. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  186. {
  187. if (cardSource.IsDigimon)
  188. {
  189. if (cardSource.HasGarurumonName || cardSource.EqualsTraits("Ver.2"))
  190. {
  191. return true;
  192. }
  193. }
  194. }
  195. return false;
  196. }
  197. bool CanUseCondition(Hashtable hashtable)
  198. {
  199. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  200. }
  201. bool CanActivateCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  204. }
  205. IEnumerator ActivateCoroutine(Hashtable hashtable)
  206. {
  207. List<CardSource> selectedCards = new List<CardSource>();
  208. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  209. {
  210. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  211. selectCardEffect.SetUp(
  212. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  213. canTargetCondition_ByPreSelecetedList: null,
  214. canEndSelectCondition: null,
  215. canNoSelect: () => false,
  216. selectCardCoroutine: SelectCardCoroutine,
  217. afterSelectCardCoroutine: null,
  218. message: "Select 1 Digimon to play.",
  219. maxCount: 1,
  220. canEndNotMax: false,
  221. isShowOpponent: true,
  222. mode: SelectCardEffect.Mode.Custom,
  223. root: SelectCardEffect.Root.Custom,
  224. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  225. canLookReverseCard: false,
  226. selectPlayer: card.Owner,
  227. cardEffect: activateClass);
  228. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  229. IEnumerator SelectCardCoroutine(CardSource cardSource)
  230. {
  231. selectedCards.Add(cardSource);
  232. yield return null;
  233. }
  234. }
  235. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition1(cardSource)) >= 1)
  236. {
  237. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  238. selectCardEffect.SetUp(
  239. canTargetCondition: (cardSource) => CanSelectCardCondition1(cardSource),
  240. canTargetCondition_ByPreSelecetedList: null,
  241. canEndSelectCondition: null,
  242. canNoSelect: () => false,
  243. selectCardCoroutine: SelectCardCoroutine,
  244. afterSelectCardCoroutine: null,
  245. message: "Select 1 Digimon to play.",
  246. maxCount: 1,
  247. canEndNotMax: false,
  248. isShowOpponent: true,
  249. mode: SelectCardEffect.Mode.Custom,
  250. root: SelectCardEffect.Root.Custom,
  251. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  252. canLookReverseCard: false,
  253. selectPlayer: card.Owner,
  254. cardEffect: activateClass);
  255. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  256. IEnumerator SelectCardCoroutine(CardSource cardSource)
  257. {
  258. selectedCards.Add(cardSource);
  259. yield return null;
  260. }
  261. }
  262. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  263. cardSources: selectedCards,
  264. activateClass: activateClass,
  265. payCost: false,
  266. isTapped: false,
  267. root: SelectCardEffect.Root.DigivolutionCards,
  268. activateETB: true));
  269. if(selectedCards.Count > 0 && selectedCards.Any(x => CardEffectCommons.IsExistOnBattleAreaDigimon(x)))
  270. {
  271. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  272. card.PermanentOfThisCard(),
  273. CardEffectCommons.CardEffectHashtable(activateClass),
  274. toTop: true).PutSecurity());
  275. }
  276. }
  277. }
  278. #endregion
  279. return cardEffects;
  280. }
  281. }
  282. }