EX9_013.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. using Photon.Pun;
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_013 : 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.5 w/[Greymon] in name or w/[DM] trait: Cost 3
  15. if (timing == EffectTiming.None)
  16. {
  17. static bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return (targetPermanent.TopCard.HasGreymonName || targetPermanent.TopCard.HasDMTraits) && targetPermanent.TopCard.IsLevel5;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Blast Digivolve
  25. if (timing == EffectTiming.OnCounterTiming)
  26. {
  27. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  28. }
  29. #endregion
  30. #region Alliance/Blocker
  31. if (timing == EffectTiming.OnAllyAttack)
  32. {
  33. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  34. }
  35. if (timing == EffectTiming.None)
  36. {
  37. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  38. isInheritedEffect: false,
  39. card: card,
  40. condition: null));
  41. }
  42. #endregion
  43. #region On Play
  44. if (timing == EffectTiming.OnEnterFieldAnyone)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect("De-Digivolve 3 to 1 Digimon", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. 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.)";
  53. }
  54. bool CanSelectPermanentCondition(Permanent permanent)
  55. {
  56. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  74. {
  75. if (isExistOnField(card))
  76. {
  77. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  78. {
  79. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  80. {
  81. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectPermanentCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: CanEndSelectCondition,
  87. maxCount: 1,
  88. canNoSelect: false,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: SelectPermanentCoroutine,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. bool CanEndSelectCondition(List<Permanent> permanents)
  97. {
  98. if (permanents.Count <= 0)
  99. {
  100. return false;
  101. }
  102. return true;
  103. }
  104. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  105. {
  106. Permanent selectedPermanent = permanent;
  107. if (selectedPermanent != null)
  108. {
  109. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 3, activateClass).Degeneration());
  110. }
  111. yield return null;
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. #endregion
  119. #region When Digivolving
  120. if (timing == EffectTiming.OnEnterFieldAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("De-Digivolve 3 to 1 Digimon", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  125. cardEffects.Add(activateClass);
  126. string EffectDiscription()
  127. {
  128. 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.)";
  129. }
  130. bool CanSelectPermanentCondition(Permanent permanent)
  131. {
  132. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  133. }
  134. bool CanUseCondition(Hashtable hashtable)
  135. {
  136. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  137. }
  138. bool CanActivateCondition(Hashtable hashtable)
  139. {
  140. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  141. {
  142. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  143. {
  144. return true;
  145. }
  146. }
  147. return false;
  148. }
  149. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  150. {
  151. if (isExistOnField(card))
  152. {
  153. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  154. {
  155. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  156. {
  157. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  158. selectPermanentEffect.SetUp(
  159. selectPlayer: card.Owner,
  160. canTargetCondition: CanSelectPermanentCondition,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: CanEndSelectCondition,
  163. maxCount: 1,
  164. canNoSelect: false,
  165. canEndNotMax: false,
  166. selectPermanentCoroutine: SelectPermanentCoroutine,
  167. afterSelectPermanentCoroutine: null,
  168. mode: SelectPermanentEffect.Mode.Custom,
  169. cardEffect: activateClass);
  170. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  171. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  172. bool CanEndSelectCondition(List<Permanent> permanents)
  173. {
  174. if (permanents.Count <= 0)
  175. {
  176. return false;
  177. }
  178. return true;
  179. }
  180. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  181. {
  182. Permanent selectedPermanent = permanent;
  183. if (selectedPermanent != null)
  184. {
  185. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 3, activateClass).Degeneration());
  186. }
  187. yield return null;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. #endregion
  195. #region End of Your Turn
  196. if (timing == EffectTiming.OnEndTurn)
  197. {
  198. ActivateClass activateClass = new ActivateClass();
  199. activateClass.SetUpICardEffect("DNA into [Omnimon Alter-S]", CanUseCondition, card);
  200. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  201. cardEffects.Add(activateClass);
  202. string EffectDiscription()
  203. {
  204. 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.";
  205. }
  206. bool CanSelectDNACardCondition(CardSource cardSource)
  207. {
  208. return cardSource.IsDigimon &&
  209. cardSource.EqualsCardName("Omnimon Alter-S") &&
  210. cardSource.CanPlayJogress(true);
  211. }
  212. bool IsYourAttackingDigimon(Permanent permanent)
  213. {
  214. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  215. permanent.CanAttack(activateClass);
  216. }
  217. bool CanUseCondition(Hashtable hashtable)
  218. {
  219. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  220. CardEffectCommons.IsOwnerTurn(card);
  221. }
  222. bool CanActivateCondition(Hashtable hashtable)
  223. {
  224. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  225. }
  226. IEnumerator ActivateCoroutine(Hashtable hashtable)
  227. {
  228. if (card.Owner.GetBattleAreaDigimons().Count >= 2)
  229. {
  230. if (card.Owner.HandCards.Count(CanSelectDNACardCondition) >= 1)
  231. {
  232. List<CardSource> selectedDNACards = new List<CardSource>();
  233. SelectHandEffect selectDNAEffect = GManager.instance.GetComponent<SelectHandEffect>();
  234. selectDNAEffect.SetUp(
  235. selectPlayer: card.Owner,
  236. canTargetCondition: CanSelectDNACardCondition,
  237. canTargetCondition_ByPreSelecetedList: null,
  238. canEndSelectCondition: null,
  239. maxCount: 1,
  240. canNoSelect: true,
  241. canEndNotMax: false,
  242. isShowOpponent: true,
  243. selectCardCoroutine: SelectDNACoroutine,
  244. afterSelectCardCoroutine: null,
  245. mode: SelectHandEffect.Mode.Custom,
  246. cardEffect: activateClass);
  247. selectDNAEffect.SetUpCustomMessage("Select 1 card to DNA digivolve.",
  248. "The opponent is selecting 1 card to DNA digivolve.");
  249. selectDNAEffect.SetNotShowCard();
  250. yield return StartCoroutine(selectDNAEffect.Activate());
  251. IEnumerator SelectDNACoroutine(CardSource cardSource)
  252. {
  253. selectedDNACards.Add(cardSource);
  254. yield return null;
  255. }
  256. if (selectedDNACards.Count >= 1)
  257. {
  258. foreach (CardSource selectedCard in selectedDNACards)
  259. {
  260. if (selectedCard.CanPlayJogress(true))
  261. {
  262. _jogressEvoRootsFrameIDs = new int[0];
  263. yield return GManager.instance.photonWaitController.StartWait("BlitzGreymon_EX9_013");
  264. if (card.Owner.isYou || GManager.instance.IsAI)
  265. {
  266. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  267. (card: selectedCard,
  268. isLocal: true,
  269. isPayCost: true,
  270. canNoSelect: true,
  271. endSelectCoroutine_SelectDigivolutionRoots: EndSelectCoroutine_SelectDigivolutionRoots,
  272. noSelectCoroutine: null);
  273. yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectJogressEffect
  274. .SelectDigivolutionRoots());
  275. IEnumerator EndSelectCoroutine_SelectDigivolutionRoots(List<Permanent> permanents)
  276. {
  277. if (permanents.Count == 2)
  278. {
  279. _jogressEvoRootsFrameIDs = permanents.Distinct().ToArray()
  280. .Map(permanent => permanent.PermanentFrame.FrameID);
  281. }
  282. yield return null;
  283. }
  284. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All, _jogressEvoRootsFrameIDs);
  285. }
  286. else
  287. {
  288. GManager.instance.commandText.OpenCommandText(
  289. "The opponent is choosing a card to DNA digivolve.");
  290. }
  291. yield return new WaitWhile(() => !_endSelect);
  292. _endSelect = false;
  293. GManager.instance.commandText.CloseCommandText();
  294. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  295. if (_jogressEvoRootsFrameIDs.Length == 2)
  296. {
  297. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  298. .GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { selectedCard },
  299. "Played Card", true, true));
  300. PlayCardClass playCard = new PlayCardClass(
  301. cardSources: new List<CardSource>() { selectedCard },
  302. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  303. payCost: true,
  304. targetPermanent: null,
  305. isTapped: false,
  306. root: SelectCardEffect.Root.Hand,
  307. activateETB: true);
  308. playCard.SetJogress(_jogressEvoRootsFrameIDs);
  309. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. if (CardEffectCommons.HasMatchConditionPermanent(IsYourAttackingDigimon))
  317. {
  318. Permanent selectedPermanent = null;
  319. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  320. selectPermanentEffect.SetUp(
  321. selectPlayer: card.Owner,
  322. canTargetCondition: IsYourAttackingDigimon,
  323. canTargetCondition_ByPreSelecetedList: null,
  324. canEndSelectCondition: null,
  325. maxCount: 1,
  326. canNoSelect: true,
  327. canEndNotMax: false,
  328. selectPermanentCoroutine: SelectPermanentCoroutine,
  329. afterSelectPermanentCoroutine: null,
  330. mode: SelectPermanentEffect.Mode.Custom,
  331. cardEffect: activateClass);
  332. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  333. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  334. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  335. {
  336. selectedPermanent = permanent;
  337. yield return null;
  338. }
  339. if (selectedPermanent != null)
  340. {
  341. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  342. selectAttackEffect.SetUp(
  343. attacker: selectedPermanent,
  344. canAttackPlayerCondition: () => true,
  345. defenderCondition: _ => true,
  346. cardEffect: activateClass);
  347. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  348. }
  349. }
  350. }
  351. }
  352. #endregion
  353. #region Sec +1 - ESS
  354. if (timing == EffectTiming.None)
  355. {
  356. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  357. changeValue: 1,
  358. isInheritedEffect: true,
  359. card: card,
  360. condition: null));
  361. }
  362. #endregion
  363. return cardEffects;
  364. }
  365. private bool _endSelect = false;
  366. private int[] _jogressEvoRootsFrameIDs = new int[0];
  367. [PunRPC]
  368. public void SetJogressEvoRootsFrameIDs(int[] JogressEvoRootsFrameIDs)
  369. {
  370. this._jogressEvoRootsFrameIDs = JogressEvoRootsFrameIDs;
  371. _endSelect = true;
  372. }
  373. }
  374. }