P_121.cs 14 KB

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