EX3_020.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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.EX3
  8. {
  9. public class EX3_020 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.CardNames.Contains("Coredramon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  23. {
  24. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  25. }
  26. if (timing == EffectTiming.None)
  27. {
  28. AddJogressLevelsClass addJogressLevelsClass = new AddJogressLevelsClass();
  29. addJogressLevelsClass.SetUpICardEffect("Also treated as level 6 for DNA Digivolution", CanUseCondition, card);
  30. addJogressLevelsClass.SetUpAddJogressLevelsClass(AddJogressLevels);
  31. cardEffects.Add(addJogressLevelsClass);
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsExistOnBattleArea(card))
  35. {
  36. if (CardEffectCommons.IsOwnerTurn(card))
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43. List<int> AddJogressLevels(CardSource cardSource, Permanent permanent)
  44. {
  45. List<int> levels = new List<int>();
  46. if (permanent == card.PermanentOfThisCard())
  47. {
  48. if (cardSource != null)
  49. {
  50. if (cardSource.Owner == card.Owner)
  51. {
  52. if (cardSource.Owner.HandCards.Contains(cardSource))
  53. {
  54. if (cardSource.CardNames.Contains("Examon"))
  55. {
  56. levels.Add(6);
  57. }
  58. }
  59. }
  60. }
  61. }
  62. return levels;
  63. }
  64. }
  65. if (timing == EffectTiming.OnEndTurn)
  66. {
  67. ActivateClass activateClass = new ActivateClass();
  68. activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card);
  69. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  70. cardEffects.Add(activateClass);
  71. string EffectDiscription()
  72. {
  73. return "[End of Your Turn] This Digimon and 1 of your other Digimon with [Dramon] in its name may DNA digivolve into a Digimon card in your hand by paying its DNA digivolve cost.";
  74. }
  75. bool CanSelectCardCondition(CardSource cardSource)
  76. {
  77. if (cardSource != null)
  78. {
  79. if (cardSource.IsDigimon)
  80. {
  81. if (cardSource.Owner == card.Owner)
  82. {
  83. if (cardSource.CanPlayJogress(true))
  84. {
  85. if (isExistOnField(card))
  86. {
  87. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  88. {
  89. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  90. {
  91. if (permanent.TopCard.HasDramonName)
  92. {
  93. if (permanent != card.PermanentOfThisCard())
  94. {
  95. if (cardSource.CanJogressFromTargetPermanent(permanent, true))
  96. {
  97. if (cardSource.CanJogressFromTargetPermanents(new List<Permanent>() { card.PermanentOfThisCard(), permanent }, true))
  98. {
  99. return true;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. }
  111. return false;
  112. }
  113. bool CanUseCondition(Hashtable hashtable)
  114. {
  115. if (isExistOnField(card))
  116. {
  117. return true;
  118. }
  119. return false;
  120. }
  121. bool CanActivateCondition(Hashtable hashtable)
  122. {
  123. if (CardEffectCommons.IsExistOnBattleArea(card))
  124. {
  125. if (CardEffectCommons.IsOwnerTurn(card))
  126. {
  127. if (card.Owner.HandCards.Count >= 1)
  128. {
  129. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard() && permanent.TopCard.HasDramonName))
  130. {
  131. return true;
  132. }
  133. }
  134. }
  135. }
  136. return false;
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  139. {
  140. if (isExistOnField(card))
  141. {
  142. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  143. {
  144. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  145. {
  146. List<CardSource> selectedCards = new List<CardSource>();
  147. int maxCount = 1;
  148. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  149. selectHandEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectCardCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: maxCount,
  155. canNoSelect: true,
  156. canEndNotMax: false,
  157. isShowOpponent: true,
  158. selectCardCoroutine: SelectCardCoroutine,
  159. afterSelectCardCoroutine: null,
  160. mode: SelectHandEffect.Mode.Custom,
  161. cardEffect: activateClass);
  162. selectHandEffect.SetUpCustomMessage("Select 1 card to DNA digivolve.", "The opponent is selecting 1 card to DNA digivolve.");
  163. selectHandEffect.SetNotShowCard();
  164. yield return StartCoroutine(selectHandEffect.Activate());
  165. IEnumerator SelectCardCoroutine(CardSource cardSource)
  166. {
  167. selectedCards.Add(cardSource);
  168. yield return null;
  169. }
  170. if (selectedCards.Count >= 1)
  171. {
  172. foreach (CardSource selectedCard in selectedCards)
  173. {
  174. if (selectedCard.CanPlayJogress(true) && selectedCard.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  175. {
  176. JogressEvoRootsFrameIDs = new int[0];
  177. yield return GManager.instance.photonWaitController.StartWait("Wingdramon_EX3_020");
  178. if (card.Owner.isYou || GManager.instance.IsAI)
  179. {
  180. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  181. (card: selectedCard,
  182. isLocal: true,
  183. isPayCost: true,
  184. canNoSelect: true,
  185. endSelectCoroutine_SelectDigivolutionRoots: EndSelectCoroutine_SelectDigivolutionRoots,
  186. noSelectCoroutine: null);
  187. GManager.instance.selectJogressEffect.SetUpCustomPermanentConditions(new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard(), (permanent) => permanent != card.PermanentOfThisCard() && permanent.TopCard.HasDramonName });
  188. yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectJogressEffect.SelectDigivolutionRoots());
  189. IEnumerator EndSelectCoroutine_SelectDigivolutionRoots(List<Permanent> permanents)
  190. {
  191. permanents = permanents.Distinct().ToList();
  192. if (permanents.Count == 2)
  193. {
  194. JogressEvoRootsFrameIDs = new int[2];
  195. for (int i = 0; i < permanents.Count; i++)
  196. {
  197. if (i < JogressEvoRootsFrameIDs.Length)
  198. {
  199. JogressEvoRootsFrameIDs[i] = permanents[i].PermanentFrame.FrameID;
  200. }
  201. }
  202. }
  203. if (!permanents.Contains(card.PermanentOfThisCard()) || (permanents.Count((permanent) => permanent != card.PermanentOfThisCard() && permanent.TopCard.HasDramonName) == 0))
  204. {
  205. JogressEvoRootsFrameIDs = new int[0];
  206. }
  207. yield return null;
  208. }
  209. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All, JogressEvoRootsFrameIDs);
  210. }
  211. else
  212. {
  213. GManager.instance.commandText.OpenCommandText("The opponent is choosing a card to DNA digivolve.");
  214. }
  215. yield return new WaitWhile(() => !endSelect);
  216. endSelect = false;
  217. GManager.instance.commandText.CloseCommandText();
  218. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  219. if (JogressEvoRootsFrameIDs.Length == 2)
  220. {
  221. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { selectedCard }, "Played Card", true, true));
  222. PlayCardClass playCard = new PlayCardClass(
  223. cardSources: new List<CardSource>() { selectedCard },
  224. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  225. payCost: true,
  226. targetPermanent: null,
  227. isTapped: false,
  228. root: SelectCardEffect.Root.Hand,
  229. activateETB: true);
  230. playCard.SetJogress(JogressEvoRootsFrameIDs);
  231. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  242. {
  243. bool Condition()
  244. {
  245. if (CardEffectCommons.IsExistOnBattleArea(card))
  246. {
  247. if (card.PermanentOfThisCard().TopCard.HasDramonName)
  248. {
  249. return true;
  250. }
  251. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Examon"))
  252. {
  253. return true;
  254. }
  255. }
  256. return false;
  257. }
  258. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  259. }
  260. return cardEffects;
  261. }
  262. bool endSelect = false;
  263. int[] JogressEvoRootsFrameIDs = new int[0];
  264. [PunRPC]
  265. public void SetJogressEvoRootsFrameIDs(int[] JogressEvoRootsFrameIDs)
  266. {
  267. this.JogressEvoRootsFrameIDs = JogressEvoRootsFrameIDs;
  268. endSelect = true;
  269. }
  270. }
  271. }