EX9_013.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.EX9
  8. {
  9. public class EX9_013 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternate Digivolution Requirement
  15. //Lv.5 w/[Greymon] in name or w/[DM] trait: Cost 3
  16. if (timing == EffectTiming.None)
  17. {
  18. static bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return (targetPermanent.TopCard.HasGreymonName || targetPermanent.TopCard.HasDMTraits) && targetPermanent.TopCard.IsLevel5;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Blast Digivolve
  26. if (timing == EffectTiming.OnCounterTiming)
  27. {
  28. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  29. }
  30. #endregion
  31. #region Alliance/Blocker
  32. if (timing == EffectTiming.OnAllyAttack)
  33. {
  34. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. if (timing == EffectTiming.None)
  37. {
  38. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  39. isInheritedEffect: false,
  40. card: card,
  41. condition: null));
  42. }
  43. #endregion
  44. #region On Play
  45. if (timing == EffectTiming.OnEnterFieldAnyone)
  46. {
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect("De-Digivolve 3 to 1 Digimon", CanUseCondition, card);
  49. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  50. cardEffects.Add(activateClass);
  51. string EffectDiscription()
  52. {
  53. return "[On Play] Trigger <De-Digivolve 3> on 1 of your opponent's Digimon. (Trash up to 3 cards from the top of one of your opponent's Digimon. If it has no digivolution cards, or becomes a level 3 Digimon, you can't trash any more cards.)";
  54. }
  55. bool CanSelectPermanentCondition(Permanent permanent)
  56. {
  57. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  62. }
  63. bool CanActivateCondition(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  66. {
  67. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. if (isExistOnField(card))
  77. {
  78. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  79. {
  80. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  81. {
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: CanEndSelectCondition,
  88. maxCount: 1,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. bool CanEndSelectCondition(List<Permanent> permanents)
  98. {
  99. if (permanents.Count <= 0)
  100. {
  101. return false;
  102. }
  103. return true;
  104. }
  105. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  106. {
  107. Permanent selectedPermanent = permanent;
  108. if (selectedPermanent != null)
  109. {
  110. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 3, activateClass).Degeneration());
  111. }
  112. yield return null;
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. #endregion
  120. #region When Digivolving
  121. if (timing == EffectTiming.OnEnterFieldAnyone)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect("De-Digivolve 3 to 1 Digimon", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  126. cardEffects.Add(activateClass);
  127. string EffectDiscription()
  128. {
  129. return "[When Digivolving] Trigger <De-Digivolve 3> on 1 of your opponent's Digimon. (Trash up to 3 cards from the top of one of your opponent's Digimon. If it has no digivolution cards, or becomes a level 3 Digimon, you can't trash any more cards.)";
  130. }
  131. bool CanSelectPermanentCondition(Permanent permanent)
  132. {
  133. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  138. }
  139. bool CanActivateCondition(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  142. {
  143. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  151. {
  152. if (isExistOnField(card))
  153. {
  154. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  155. {
  156. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  157. {
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectPermanentCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: CanEndSelectCondition,
  164. maxCount: 1,
  165. canNoSelect: false,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: SelectPermanentCoroutine,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  172. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  173. bool CanEndSelectCondition(List<Permanent> permanents)
  174. {
  175. if (permanents.Count <= 0)
  176. {
  177. return false;
  178. }
  179. return true;
  180. }
  181. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  182. {
  183. Permanent selectedPermanent = permanent;
  184. if (selectedPermanent != null)
  185. {
  186. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 3, activateClass).Degeneration());
  187. }
  188. yield return null;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. #endregion
  196. #region End of Your Turn
  197. if (timing == EffectTiming.OnEndTurn)
  198. {
  199. ActivateClass activateClass = new ActivateClass();
  200. activateClass.SetUpICardEffect("DNA into [Omnimon Alter-S]", CanUseCondition, card);
  201. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  202. cardEffects.Add(activateClass);
  203. string EffectDiscription()
  204. {
  205. return "[End of Your Turn] 2 of your Digimon may DNA digivolve into [Omnimon Alter-S] in the hand. Then, 1 of your Digimon may attack.";
  206. }
  207. bool CanSelectDNACardCondition(CardSource cardSource)
  208. {
  209. return cardSource.IsDigimon &&
  210. cardSource.EqualsCardName("Omnimon Alter-S") &&
  211. cardSource.CanPlayJogress(true);
  212. }
  213. bool IsYourAttackingDigimon(Permanent permanent)
  214. {
  215. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  216. permanent.CanAttack(activateClass);
  217. }
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  221. CardEffectCommons.IsOwnerTurn(card);
  222. }
  223. bool CanActivateCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable hashtable)
  228. {
  229. yield return ContinuousController.instance.StartCoroutine(
  230. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  231. CanSelectDNACardCondition,
  232. payCost: true,
  233. isHand: true,
  234. activateClass
  235. ));
  236. if (CardEffectCommons.HasMatchConditionPermanent(IsYourAttackingDigimon))
  237. {
  238. Permanent selectedPermanent = null;
  239. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  240. selectPermanentEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: IsYourAttackingDigimon,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: 1,
  246. canNoSelect: true,
  247. canEndNotMax: false,
  248. selectPermanentCoroutine: SelectPermanentCoroutine,
  249. afterSelectPermanentCoroutine: null,
  250. mode: SelectPermanentEffect.Mode.Custom,
  251. cardEffect: activateClass);
  252. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  253. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  254. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  255. {
  256. selectedPermanent = permanent;
  257. yield return null;
  258. }
  259. if (selectedPermanent != null)
  260. {
  261. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  262. selectAttackEffect.SetUp(
  263. attacker: selectedPermanent,
  264. canAttackPlayerCondition: () => true,
  265. defenderCondition: _ => true,
  266. cardEffect: activateClass);
  267. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  268. }
  269. }
  270. }
  271. }
  272. #endregion
  273. #region Sec +1 - ESS
  274. if (timing == EffectTiming.None)
  275. {
  276. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  277. changeValue: 1,
  278. isInheritedEffect: true,
  279. card: card,
  280. condition: null));
  281. }
  282. #endregion
  283. return cardEffects;
  284. }
  285. }
  286. }