EX7_037.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX7
  6. {
  7. public class EX7_037 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region DNA Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  16. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  17. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  18. addJogressConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addJogressConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. JogressCondition GetJogress(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. bool PermanentCondition1(Permanent permanent)
  29. {
  30. if (permanent != null)
  31. {
  32. if (permanent.TopCard != null)
  33. {
  34. if (permanent.TopCard.Owner == card.Owner)
  35. {
  36. if (permanent.IsDigimon)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent,
  39. card))
  40. {
  41. if (permanent.TopCard.CardColors.Contains(CardColor.Green) ||
  42. permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  43. {
  44. if (permanent.Levels_ForJogress(card).Contains(6))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. bool PermanentCondition2(Permanent permanent)
  57. {
  58. if (permanent != null)
  59. {
  60. if (permanent.TopCard != null)
  61. {
  62. if (permanent.TopCard.Owner == card.Owner)
  63. {
  64. if (permanent.IsDigimon)
  65. {
  66. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent,
  67. card))
  68. {
  69. if (permanent.TopCard.CardColors.Contains(CardColor.Black) ||
  70. permanent.TopCard.CardColors.Contains(CardColor.Blue))
  71. {
  72. if (permanent.Levels_ForJogress(card).Contains(6))
  73. {
  74. return true;
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
  81. }
  82. return false;
  83. }
  84. JogressConditionElement[] elements =
  85. {
  86. new(PermanentCondition1, "a level 6 Green or Yellow Digimon"),
  87. new(PermanentCondition2, "a level 6 Black or Blue Digimon")
  88. };
  89. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  90. return jogressCondition;
  91. }
  92. return null;
  93. }
  94. }
  95. #endregion
  96. #region When Digivolving
  97. if (timing == EffectTiming.OnEnterFieldAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("Play Digimon", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  102. activateClass.SetHashString("PlayDigimon_EX7_037");
  103. cardEffects.Add(activateClass);
  104. string EffectDescription()
  105. {
  106. return
  107. "[When Digivolving] You may play 1 Digimon card with the [NSp] trait and a play cost of 7 or less from your hand without paying the cost. If DNA digivolving, you may play 2 Digimon cards with different colors and the [NSp] trait and a play cost of 7 or less from your hand without paying the cost instead.";
  108. }
  109. bool CanSelectCardCondition(CardSource cardSource)
  110. {
  111. return cardSource.IsDigimon &&
  112. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass) &&
  113. cardSource.ContainsTraits("NSp") &&
  114. cardSource.HasPlayCost &&
  115. cardSource.GetCostItself <= 7 &&
  116. cardSource.CardColors.Count >= 1;
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  125. CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  126. }
  127. IEnumerator ActivateCoroutine(Hashtable hashtable)
  128. {
  129. List<CardSource> selectedCards = new List<CardSource>();
  130. int maxCount = Math.Min(CardEffectCommons.IsJogress(hashtable) ? 2 : 1,
  131. card.Owner.HandCards.Count(CanSelectCardCondition));
  132. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  133. selectHandEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: CanSelectCardCondition,
  136. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  137. canEndSelectCondition: CanEndSelectCondition,
  138. maxCount: maxCount,
  139. canNoSelect: true,
  140. canEndNotMax: true,
  141. isShowOpponent: true,
  142. selectCardCoroutine: SelectCardCoroutine,
  143. afterSelectCardCoroutine: null,
  144. mode: SelectHandEffect.Mode.Custom,
  145. cardEffect: activateClass);
  146. selectHandEffect.SetUpCustomMessage("Select cards to play.",
  147. "The opponent is selecting cards to play.");
  148. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  149. yield return StartCoroutine(selectHandEffect.Activate());
  150. bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources, CardSource cardSource)
  151. {
  152. if (cardSources.Count == 0) return true;
  153. return cardSource.CardColors.Any(color1 => cardSources[0].CardColors.Any(color2 => color2 != color1));
  154. }
  155. bool CanEndSelectCondition(List<CardSource> cardSources)
  156. {
  157. return cardSources.Count > 0 && Combinations.GetDifferenetColorCardCount(cardSources) >= cardSources.Count;
  158. }
  159. IEnumerator SelectCardCoroutine(CardSource cardSource)
  160. {
  161. selectedCards.Add(cardSource);
  162. yield return null;
  163. }
  164. yield return ContinuousController.instance.StartCoroutine(
  165. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  166. payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  167. }
  168. }
  169. #endregion
  170. #region When Digivolving/ When Attacking Shared
  171. bool CanSelectPermanentSharedCondition(Permanent permanent)
  172. {
  173. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  174. }
  175. bool CanActivateSharedCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  178. }
  179. #endregion
  180. #region When Digivolving
  181. if (timing == EffectTiming.OnEnterFieldAnyone)
  182. {
  183. ActivateClass activateClass = new ActivateClass();
  184. activateClass.SetUpICardEffect("Give opponent's Digimon -7000 DP for each Digimon", CanUseCondition, card);
  185. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, 1, false, EffectDescription());
  186. activateClass.SetHashString("MinusDP_EX7_037");
  187. cardEffects.Add(activateClass);
  188. string EffectDescription()
  189. {
  190. return
  191. "[When Digivolving] (Once per turn) For each of your Digimon, 1 of your opponent's Digimon gets -7000 DP for the turn.";
  192. }
  193. bool CanUseCondition(Hashtable hashtable)
  194. {
  195. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  196. }
  197. IEnumerator ActivateCoroutine(Hashtable hashtable)
  198. {
  199. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition))
  200. {
  201. int maxDP = 0;
  202. maxDP += 7000 * card.Owner.GetBattleAreaDigimons().Count;
  203. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  204. selectPermanentEffect.SetUp(
  205. selectPlayer: card.Owner,
  206. canTargetCondition: CanSelectPermanentSharedCondition,
  207. canTargetCondition_ByPreSelecetedList: null,
  208. canEndSelectCondition: null,
  209. maxCount: 1,
  210. canNoSelect: false,
  211. canEndNotMax: false,
  212. selectPermanentCoroutine: SelectPermanentCoroutine,
  213. afterSelectPermanentCoroutine: null,
  214. mode: SelectPermanentEffect.Mode.Custom,
  215. cardEffect: activateClass);
  216. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP " + maxDP + ".",
  217. "The opponent is selecting 1 Digimon that will get DP " + maxDP + ".");
  218. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  219. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  220. {
  221. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  222. targetPermanent: permanent, changeValue: -maxDP, effectDuration: EffectDuration.UntilEachTurnEnd,
  223. activateClass: activateClass));
  224. }
  225. }
  226. }
  227. }
  228. #endregion
  229. #region When Attacking
  230. if (timing == EffectTiming.OnAllyAttack)
  231. {
  232. ActivateClass activateClass = new ActivateClass();
  233. activateClass.SetUpICardEffect("Give opponent's Digimon -7000 DP for each Digimon", CanUseCondition, card);
  234. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, 1, false, EffectDescription());
  235. activateClass.SetHashString("MinusDP_EX7_037");
  236. cardEffects.Add(activateClass);
  237. string EffectDescription()
  238. {
  239. return
  240. "[When Attacking] (Once per turn) For each of your Digimon, 1 of your opponent's Digimon gets -7000 DP for the turn.";
  241. }
  242. bool CanUseCondition(Hashtable hashtable)
  243. {
  244. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  245. }
  246. IEnumerator ActivateCoroutine(Hashtable hashtable)
  247. {
  248. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition))
  249. {
  250. int maxDP = 0;
  251. maxDP += 7000 * card.Owner.GetBattleAreaDigimons().Count;
  252. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  253. selectPermanentEffect.SetUp(
  254. selectPlayer: card.Owner,
  255. canTargetCondition: CanSelectPermanentSharedCondition,
  256. canTargetCondition_ByPreSelecetedList: null,
  257. canEndSelectCondition: null,
  258. maxCount: 1,
  259. canNoSelect: false,
  260. canEndNotMax: false,
  261. selectPermanentCoroutine: SelectPermanentCoroutine,
  262. afterSelectPermanentCoroutine: null,
  263. mode: SelectPermanentEffect.Mode.Custom,
  264. cardEffect: activateClass);
  265. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP " + maxDP + ".",
  266. "The opponent is selecting 1 Digimon that will get DP " + maxDP + ".");
  267. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  268. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  269. {
  270. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  271. targetPermanent: permanent, changeValue: -maxDP, effectDuration: EffectDuration.UntilEachTurnEnd,
  272. activateClass: activateClass));
  273. }
  274. }
  275. }
  276. }
  277. #endregion
  278. return cardEffects;
  279. }
  280. }
  281. }