EX8_025.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.EX8
  6. {
  7. public class EX8_025 : 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 Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsTraits("DS") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion Alternate Digivolution Requirement
  22. #region DNA Digivolve
  23. if (timing == EffectTiming.None)
  24. {
  25. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  26. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  27. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  28. addJogressConditionClass.SetNotShowUI(true);
  29. cardEffects.Add(addJogressConditionClass);
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return true;
  33. }
  34. JogressCondition GetJogress(CardSource cardSource)
  35. {
  36. if (cardSource == card)
  37. {
  38. bool PermanentCondition1(Permanent permanent) =>
  39. permanent.TopCard.CardColors.Contains(CardColor.Blue) && permanent.Levels_ForJogress(card).Contains(4);
  40. bool PermanentCondition2(Permanent permanent) =>
  41. (permanent.TopCard.CardColors.Contains(CardColor.Black) && permanent.Levels_ForJogress(card).Contains(4)) ||
  42. (permanent.TopCard.CardColors.Contains(CardColor.Purple) && permanent.Levels_ForJogress(card).Contains(4));
  43. JogressConditionElement[] elements = new JogressConditionElement[]
  44. {
  45. new JogressConditionElement(PermanentCondition1, "a level 4 blue Digimon"),
  46. new JogressConditionElement(PermanentCondition2, "a level 4 black/purple Digimon"),
  47. };
  48. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  49. return jogressCondition;
  50. }
  51. return null;
  52. }
  53. }
  54. #endregion DNA Digivolve
  55. #region On Play
  56. if (timing == EffectTiming.OnEnterFieldAnyone)
  57. {
  58. ActivateClass activateClass = new ActivateClass();
  59. activateClass.SetUpICardEffect("Place 1 Digimon with [DS] trait from trash as this Digimon's bottom digivolution card", CanUseCondition, card);
  60. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  61. cardEffects.Add(activateClass);
  62. string EffectDescription()
  63. {
  64. return "[On Play] You may place 1 Digimon card with the [DS] trait from your trash as this Digimon's bottom digivolution card.";
  65. }
  66. bool CanSelectCardCondition(CardSource source)
  67. {
  68. if (source.IsDigimon)
  69. {
  70. if (source.EqualsTraits("DS"))
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  80. }
  81. bool CanActivateCondition(Hashtable hashtable)
  82. {
  83. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  84. {
  85. if (!card.PermanentOfThisCard().IsToken)
  86. {
  87. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  88. {
  89. return true;
  90. }
  91. }
  92. }
  93. return false;
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable hashtable)
  96. {
  97. List<CardSource> selectedCards = new List<CardSource>();
  98. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  99. selectCardEffect.SetUp(
  100. canTargetCondition: CanSelectCardCondition,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. canNoSelect: () => true,
  104. selectCardCoroutine: AfterSelectCardCoroutine,
  105. afterSelectCardCoroutine: null,
  106. message: "Select 1 card to place on bottom of digivolution cards.",
  107. maxCount: 1,
  108. canEndNotMax: false,
  109. isShowOpponent: false,
  110. mode: SelectCardEffect.Mode.Custom,
  111. root: SelectCardEffect.Root.Trash,
  112. customRootCardList: null,
  113. canLookReverseCard: true,
  114. selectPlayer: card.Owner,
  115. cardEffect: activateClass);
  116. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  117. IEnumerator AfterSelectCardCoroutine(CardSource source)
  118. {
  119. selectedCards.Add(source);
  120. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  121. }
  122. }
  123. }
  124. #endregion On Play
  125. #region When Digivolving
  126. if (timing == EffectTiming.OnEnterFieldAnyone)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("Place 1 Digimon with [DS] trait from trash as this Digimon's bottom digivolution card", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  131. cardEffects.Add(activateClass);
  132. string EffectDescription()
  133. {
  134. return "[When Digivolving] You may place 1 Digimon card with the [DS] trait from your trash as this Digimon's bottom digivolution card.";
  135. }
  136. bool CanSelectCardCondition(CardSource source)
  137. {
  138. if (source.IsDigimon)
  139. {
  140. if (source.EqualsTraits("DS"))
  141. {
  142. return true;
  143. }
  144. }
  145. return false;
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  150. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  151. }
  152. bool CanActivateCondition(Hashtable hashtable)
  153. {
  154. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  155. {
  156. if (!card.PermanentOfThisCard().IsToken)
  157. {
  158. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  159. {
  160. return true;
  161. }
  162. }
  163. }
  164. return false;
  165. }
  166. IEnumerator ActivateCoroutine(Hashtable hashtable)
  167. {
  168. List<CardSource> selectedCards = new List<CardSource>();
  169. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  170. selectCardEffect.SetUp(
  171. canTargetCondition: CanSelectCardCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. canNoSelect: () => true,
  175. selectCardCoroutine: AfterSelectCardCoroutine,
  176. afterSelectCardCoroutine: null,
  177. message: "Select 1 card to place at bottom of digivolution cards.",
  178. maxCount: 1,
  179. canEndNotMax: false,
  180. isShowOpponent: false,
  181. mode: SelectCardEffect.Mode.Custom,
  182. root: SelectCardEffect.Root.Trash,
  183. customRootCardList: null,
  184. canLookReverseCard: true,
  185. selectPlayer: card.Owner,
  186. cardEffect: activateClass);
  187. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  188. IEnumerator AfterSelectCardCoroutine(CardSource source)
  189. {
  190. selectedCards.Add(source);
  191. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  192. }
  193. }
  194. }
  195. #endregion When Digivolving
  196. #region End of Attack
  197. if (timing == EffectTiming.OnEndAttack)
  198. {
  199. ActivateClass activateClass = new ActivateClass();
  200. activateClass.SetUpICardEffect("Play 1 digivolution card", CanUseCondition, card);
  201. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  202. activateClass.SetHashString("EndofAttack_EX8_025");
  203. cardEffects.Add(activateClass);
  204. string EffectDiscription()
  205. {
  206. return "[End of Attack] [Once Per Turn] You may play 1 [DS] trait Digimon card with a play cost of 5 or less from this Digimon's digivolution cards without paying the cost.";
  207. }
  208. bool CanSelectCardCondition(CardSource cardSource)
  209. {
  210. if (cardSource.IsDigimon)
  211. {
  212. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  213. {
  214. if (cardSource.EqualsTraits("DS"))
  215. {
  216. if (cardSource.HasPlayCost && cardSource.GetCostItself <= 5)
  217. {
  218. return true;
  219. }
  220. }
  221. }
  222. }
  223. return false;
  224. }
  225. bool CanUseCondition(Hashtable hashtable)
  226. {
  227. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  228. }
  229. bool CanActivateCondition(Hashtable hashtable)
  230. {
  231. if (CardEffectCommons.IsExistOnBattleArea(card))
  232. {
  233. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  234. {
  235. return true;
  236. }
  237. }
  238. return false;
  239. }
  240. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  241. {
  242. if (CardEffectCommons.IsExistOnBattleArea(card))
  243. {
  244. Permanent selectedPermanent = card.PermanentOfThisCard();
  245. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  246. {
  247. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  248. List<CardSource> selectedCards = new List<CardSource>();
  249. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  250. selectCardEffect.SetUp(
  251. canTargetCondition: CanSelectCardCondition,
  252. canTargetCondition_ByPreSelecetedList: null,
  253. canEndSelectCondition: null,
  254. canNoSelect: () => true,
  255. selectCardCoroutine: SelectCardCoroutine,
  256. afterSelectCardCoroutine: null,
  257. message: "Select 1 digivolution card to play.",
  258. maxCount: maxCount,
  259. canEndNotMax: false,
  260. isShowOpponent: true,
  261. mode: SelectCardEffect.Mode.Custom,
  262. root: SelectCardEffect.Root.Custom,
  263. customRootCardList: selectedPermanent.DigivolutionCards,
  264. canLookReverseCard: true,
  265. selectPlayer: card.Owner,
  266. cardEffect: activateClass);
  267. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  268. yield return StartCoroutine(selectCardEffect.Activate());
  269. IEnumerator SelectCardCoroutine(CardSource cardSource)
  270. {
  271. selectedCards.Add(cardSource);
  272. yield return null;
  273. }
  274. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  275. cardSources: selectedCards,
  276. activateClass: activateClass,
  277. payCost: false,
  278. isTapped: false,
  279. root: SelectCardEffect.Root.DigivolutionCards,
  280. activateETB: true));
  281. }
  282. }
  283. }
  284. }
  285. #endregion End of Attack
  286. #region Your Turn - ESS
  287. if (timing == EffectTiming.None)
  288. {
  289. CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass = new CanNotSwitchAttackTargetClass();
  290. canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't be switched.", CanUseCondition, card);
  291. canNotSwitchAttackTargetClass.SetUpCanNotSwitchAttackTargetClass(PermanentCondition: PermanentCondition);
  292. canNotSwitchAttackTargetClass.SetIsInheritedEffect(true);
  293. cardEffects.Add(canNotSwitchAttackTargetClass);
  294. bool CanUseCondition(Hashtable hashtable)
  295. {
  296. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  297. CardEffectCommons.IsOwnerTurn(card);
  298. }
  299. bool PermanentCondition(Permanent permanent)
  300. {
  301. return permanent != null && permanent.TopCard && permanent == card.PermanentOfThisCard();
  302. }
  303. }
  304. #endregion Your Turn - ESS
  305. return cardEffects;
  306. }
  307. }
  308. }