BT17_019.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using System;
  6. using Photon.Pun;
  7. namespace DCGO.CardEffects.BT17
  8. {
  9. public class BT17_019 : 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
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.EqualsCardName("Tsunomon");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false,
  23. card: card, condition: null));
  24. }
  25. #endregion
  26. #region Start of Your Main Phase
  27. if (timing == EffectTiming.OnStartMainPhase)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  31. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  32. EffectDescription());
  33. cardEffects.Add(activateClass);
  34. string EffectDescription()
  35. {
  36. return
  37. "[Start of Your Main Phase] If you have a Tamer with [Matt Ishida] in its name, [Draw 1].";
  38. }
  39. bool OwnTamerPermanentCondition(Permanent permanent)
  40. {
  41. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  42. {
  43. if (permanent.IsTamer)
  44. {
  45. if (permanent.TopCard.ContainsCardName("Matt Ishida") || permanent.TopCard.ContainsCardName("MattIshida"))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. if (CardEffectCommons.IsOwnerTurn(card))
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, OwnTamerPermanentCondition))
  69. {
  70. if (card.Owner.LibraryCards.Count >= 1)
  71. {
  72. return true;
  73. }
  74. }
  75. }
  76. return false;
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable hashtable)
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(
  81. new DrawClass(card.Owner, 1, activateClass).Draw());
  82. }
  83. }
  84. #endregion
  85. #region End of Your Turn - ESS
  86. if (timing == EffectTiming.OnEndTurn)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  91. EffectDescription());
  92. activateClass.SetIsInheritedEffect(true);
  93. cardEffects.Add(activateClass);
  94. string EffectDescription()
  95. {
  96. return
  97. "[End of Your Turn] This Digimon and another of your Digimon may DNA digivolve into a Digimon card in the hand.";
  98. }
  99. bool CanSelectCardCondition(CardSource cardSource)
  100. {
  101. if (cardSource != null)
  102. {
  103. if (cardSource.IsDigimon)
  104. {
  105. if (cardSource.Owner == card.Owner)
  106. {
  107. if (cardSource.CanPlayJogress(true))
  108. {
  109. if (isExistOnField(card))
  110. {
  111. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. return false;
  121. }
  122. bool CanUseCondition(Hashtable hashtable)
  123. {
  124. if (isExistOnField(card))
  125. {
  126. return true;
  127. }
  128. return false;
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleArea(card))
  133. {
  134. if (CardEffectCommons.IsOwnerTurn(card))
  135. {
  136. if (card.Owner.HandCards.Count >= 1)
  137. {
  138. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card,
  139. (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.",
  173. "The opponent is selecting 1 card to DNA digivolve.");
  174. selectHandEffect.SetNotShowCard();
  175. yield return StartCoroutine(selectHandEffect.Activate());
  176. IEnumerator SelectCardCoroutine(CardSource cardSource)
  177. {
  178. selectedCards.Add(cardSource);
  179. yield return null;
  180. }
  181. if (selectedCards.Count >= 1)
  182. {
  183. foreach (CardSource selectedCard in selectedCards)
  184. {
  185. if (selectedCard.CanPlayJogress(true) &&
  186. selectedCard.CanJogressFromTargetPermanent(card.PermanentOfThisCard(),
  187. true))
  188. {
  189. JogressEvoRootsFrameIDs = Array.Empty<int>();
  190. yield return GManager.instance.photonWaitController.StartWait(
  191. "Gabumon_BT17_019");
  192. if (card.Owner.isYou || GManager.instance.IsAI)
  193. {
  194. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  195. (card: selectedCard,
  196. isLocal: true,
  197. isPayCost: true,
  198. canNoSelect: true,
  199. endSelectCoroutine_SelectDigivolutionRoots:
  200. EndSelectCoroutineSelectDigivolutionRoots,
  201. noSelectCoroutine: null);
  202. GManager.instance.selectJogressEffect.SetUpCustomPermanentConditions(
  203. new Func<Permanent, bool>[]
  204. { (permanent) => permanent == card.PermanentOfThisCard() });
  205. yield return ContinuousController.instance.StartCoroutine(
  206. GManager.instance.selectJogressEffect.SelectDigivolutionRoots());
  207. IEnumerator EndSelectCoroutineSelectDigivolutionRoots(
  208. List<Permanent> permanents)
  209. {
  210. permanents = permanents.Distinct().ToList();
  211. if (permanents.Count == 2)
  212. {
  213. JogressEvoRootsFrameIDs = new int[2];
  214. for (int i = 0; i < permanents.Count; i++)
  215. {
  216. if (i < JogressEvoRootsFrameIDs.Length)
  217. {
  218. JogressEvoRootsFrameIDs[i] =
  219. permanents[i].PermanentFrame.FrameID;
  220. }
  221. }
  222. }
  223. if (!permanents.Contains(card.PermanentOfThisCard()))
  224. {
  225. JogressEvoRootsFrameIDs = Array.Empty<int>();
  226. }
  227. yield return null;
  228. }
  229. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All,
  230. JogressEvoRootsFrameIDs);
  231. }
  232. else
  233. {
  234. GManager.instance.commandText.OpenCommandText(
  235. "The opponent is choosing a card to DNA digivolve.");
  236. }
  237. yield return new WaitWhile(() => !endSelect);
  238. endSelect = false;
  239. GManager.instance.commandText.CloseCommandText();
  240. yield return new WaitWhile(() =>
  241. GManager.instance.commandText.gameObject.activeSelf);
  242. if (JogressEvoRootsFrameIDs.Length == 2)
  243. {
  244. yield return ContinuousController.instance.StartCoroutine(GManager
  245. .instance.GetComponent<Effects>()
  246. .ShowCardEffect(new List<CardSource>() { selectedCard },
  247. "Played Card", true, true));
  248. PlayCardClass playCard = new PlayCardClass(
  249. cardSources: new List<CardSource>() { selectedCard },
  250. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  251. payCost: true,
  252. targetPermanent: null,
  253. isTapped: false,
  254. root: SelectCardEffect.Root.Hand,
  255. activateETB: true);
  256. playCard.SetJogress(JogressEvoRootsFrameIDs);
  257. yield return ContinuousController.instance.StartCoroutine(
  258. playCard.PlayCard());
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
  268. #endregion
  269. return cardEffects;
  270. }
  271. #region Photon DNA ESS
  272. bool endSelect;
  273. int[] JogressEvoRootsFrameIDs = Array.Empty<int>();
  274. [PunRPC]
  275. public void SetJogressEvoRootsFrameIDs(int[] jogressEvoRootsFrameIDs)
  276. {
  277. this.JogressEvoRootsFrameIDs = jogressEvoRootsFrameIDs;
  278. endSelect = true;
  279. }
  280. #endregion
  281. }
  282. }