BT20_066.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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. namespace DCGO.CardEffects.BT20
  9. {
  10. public class BT20_066 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region On Play
  16. if (timing == EffectTiming.OnEnterFieldAnyone)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Delete digimon and digivolve into ImperialDramon", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[On Play][When Digivolving] Delete 1 of your opponent's level 3 Digimon. Then, if it's your turn, 2 of your Digimon may DNA digivolve into a Digimon card with [Imperialdramon] in its name or the [Free] trait in the hand.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  29. {
  30. if (permanent.Level == 3)
  31. {
  32. if (permanent.TopCard.HasLevel)
  33. {
  34. if (permanent.CanSelectBySkill(activateClass))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  50. {
  51. return true;
  52. }
  53. return false;
  54. }
  55. bool CanSelectCardCondition(CardSource cardSource)
  56. {
  57. if (cardSource != null)
  58. {
  59. if (cardSource.IsDigimon)
  60. {
  61. if (cardSource.Owner == card.Owner)
  62. {
  63. if(cardSource.CardTraits.Contains("Free") || cardSource.ContainsCardName("Imperialdramon"))
  64. {
  65. if (cardSource.CanPlayJogress(true))
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable hashtable)
  76. {
  77. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  78. {
  79. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  80. int maxCount = 1;
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: null,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Destroy,
  92. cardEffect: activateClass);
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. }
  95. if (isExistOnField(card))
  96. {
  97. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  98. {
  99. if (card.Owner.HandCards.Count >= 1)
  100. {
  101. List<CardSource> selectedCards = new List<CardSource>();
  102. int maxCount = 1;
  103. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  104. selectHandEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: CanSelectCardCondition,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: maxCount,
  110. canNoSelect: true,
  111. canEndNotMax: false,
  112. isShowOpponent: true,
  113. selectCardCoroutine: SelectCardCoroutine,
  114. afterSelectCardCoroutine: null,
  115. mode: SelectHandEffect.Mode.Custom,
  116. cardEffect: activateClass);
  117. selectHandEffect.SetUpCustomMessage("Select 1 card to DNA digivolve.", "The opponent is selecting 1 card to DNA digivolve.");
  118. selectHandEffect.SetNotShowCard();
  119. yield return StartCoroutine(selectHandEffect.Activate());
  120. IEnumerator SelectCardCoroutine(CardSource cardSource)
  121. {
  122. selectedCards.Add(cardSource);
  123. yield return null;
  124. }
  125. if (selectedCards.Count >= 1)
  126. {
  127. foreach (CardSource selectedCard in selectedCards)
  128. {
  129. if (selectedCard.CanPlayJogress(true) && selectedCard.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  130. {
  131. JogressEvoRootsFrameIDs = new int[0];
  132. yield return GManager.instance.photonWaitController.StartWait("Stingmon_BT20_066");
  133. if (card.Owner.isYou || GManager.instance.IsAI)
  134. {
  135. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  136. (card: selectedCard,
  137. isLocal: true,
  138. isPayCost: true,
  139. canNoSelect: true,
  140. endSelectCoroutine_SelectDigivolutionRoots: EndSelectCoroutine_SelectDigivolutionRoots,
  141. noSelectCoroutine: null);
  142. GManager.instance.selectJogressEffect.SetUpCustomPermanentConditions(new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() });
  143. yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectJogressEffect.SelectDigivolutionRoots());
  144. IEnumerator EndSelectCoroutine_SelectDigivolutionRoots(List<Permanent> permanents)
  145. {
  146. permanents = permanents.Distinct().ToList();
  147. if (permanents.Count == 2)
  148. {
  149. JogressEvoRootsFrameIDs = new int[2];
  150. for (int i = 0; i < permanents.Count; i++)
  151. {
  152. if (i < JogressEvoRootsFrameIDs.Length)
  153. {
  154. JogressEvoRootsFrameIDs[i] = permanents[i].PermanentFrame.FrameID;
  155. }
  156. }
  157. }
  158. if (!permanents.Contains(card.PermanentOfThisCard()))
  159. {
  160. JogressEvoRootsFrameIDs = new int[0];
  161. }
  162. yield return null;
  163. }
  164. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All, JogressEvoRootsFrameIDs);
  165. }
  166. else
  167. {
  168. GManager.instance.commandText.OpenCommandText("The opponent is choosing a card to DNA digivolve.");
  169. }
  170. yield return new WaitWhile(() => !endSelect);
  171. endSelect = false;
  172. GManager.instance.commandText.CloseCommandText();
  173. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  174. if (JogressEvoRootsFrameIDs.Length == 2)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { selectedCard }, "Played Card", true, true));
  177. PlayCardClass playCard = new PlayCardClass(
  178. cardSources: new List<CardSource>() { selectedCard },
  179. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  180. payCost: true,
  181. targetPermanent: null,
  182. isTapped: false,
  183. root: SelectCardEffect.Root.Hand,
  184. activateETB: true);
  185. playCard.SetJogress(JogressEvoRootsFrameIDs);
  186. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. }
  196. #endregion
  197. #region When Digivolving
  198. if (timing == EffectTiming.OnEnterFieldAnyone)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("Delete digimon and digivolve into ImperialDramon", CanUseCondition, card);
  202. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  203. cardEffects.Add(activateClass);
  204. string EffectDiscription()
  205. {
  206. return "[On Play][When Digivolving] Delete 1 of your opponent's level 3 Digimon. Then, if it's your turn, 2 of your Digimon may DNA digivolve into a Digimon card with [Imperialdramon] in its name or the [Free] trait in the hand.";
  207. }
  208. bool CanSelectPermanentCondition(Permanent permanent)
  209. {
  210. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  211. {
  212. if (permanent.Level == 3)
  213. {
  214. if (permanent.TopCard.HasLevel)
  215. {
  216. if (permanent.CanSelectBySkill(activateClass))
  217. {
  218. return true;
  219. }
  220. }
  221. }
  222. }
  223. return false;
  224. }
  225. bool CanUseCondition(Hashtable hashtable)
  226. {
  227. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  228. }
  229. bool CanActivateCondition(Hashtable hashtable)
  230. {
  231. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  232. {
  233. return true;
  234. }
  235. return false;
  236. }
  237. bool CanSelectCardCondition(CardSource cardSource)
  238. {
  239. if (cardSource != null)
  240. {
  241. if (cardSource.IsDigimon)
  242. {
  243. if (cardSource.Owner == card.Owner)
  244. {
  245. if(cardSource.CardTraits.Contains("Free") || cardSource.ContainsCardName("Imperialdramon"))
  246. {
  247. if (cardSource.CanPlayJogress(true))
  248. {
  249. return true;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. return false;
  256. }
  257. IEnumerator ActivateCoroutine(Hashtable hashtable)
  258. {
  259. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  260. {
  261. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  262. int maxCount = 1;
  263. selectPermanentEffect.SetUp(
  264. selectPlayer: card.Owner,
  265. canTargetCondition: CanSelectPermanentCondition,
  266. canTargetCondition_ByPreSelecetedList: null,
  267. canEndSelectCondition: null,
  268. maxCount: maxCount,
  269. canNoSelect: false,
  270. canEndNotMax: false,
  271. selectPermanentCoroutine: null,
  272. afterSelectPermanentCoroutine: null,
  273. mode: SelectPermanentEffect.Mode.Destroy,
  274. cardEffect: activateClass);
  275. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  276. }
  277. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  278. {
  279. if (isExistOnField(card))
  280. {
  281. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  282. {
  283. if (card.Owner.HandCards.Count >= 1)
  284. {
  285. List<CardSource> selectedCards = new List<CardSource>();
  286. int maxCount = 1;
  287. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  288. selectHandEffect.SetUp(
  289. selectPlayer: card.Owner,
  290. canTargetCondition: CanSelectCardCondition,
  291. canTargetCondition_ByPreSelecetedList: null,
  292. canEndSelectCondition: null,
  293. maxCount: maxCount,
  294. canNoSelect: true,
  295. canEndNotMax: false,
  296. isShowOpponent: true,
  297. selectCardCoroutine: SelectCardCoroutine,
  298. afterSelectCardCoroutine: null,
  299. mode: SelectHandEffect.Mode.Custom,
  300. cardEffect: activateClass);
  301. selectHandEffect.SetUpCustomMessage("Select 1 card to DNA digivolve.", "The opponent is selecting 1 card to DNA digivolve.");
  302. selectHandEffect.SetNotShowCard();
  303. yield return StartCoroutine(selectHandEffect.Activate());
  304. IEnumerator SelectCardCoroutine(CardSource cardSource)
  305. {
  306. selectedCards.Add(cardSource);
  307. yield return null;
  308. }
  309. if (selectedCards.Count >= 1)
  310. {
  311. foreach (CardSource selectedCard in selectedCards)
  312. {
  313. if (selectedCard.CanPlayJogress(true) && selectedCard.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  314. {
  315. JogressEvoRootsFrameIDs = new int[0];
  316. yield return GManager.instance.photonWaitController.StartWait("Stingmon_BT20_066");
  317. if (card.Owner.isYou || GManager.instance.IsAI)
  318. {
  319. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  320. (card: selectedCard,
  321. isLocal: true,
  322. isPayCost: true,
  323. canNoSelect: true,
  324. endSelectCoroutine_SelectDigivolutionRoots: EndSelectCoroutine_SelectDigivolutionRoots,
  325. noSelectCoroutine: null);
  326. GManager.instance.selectJogressEffect.SetUpCustomPermanentConditions(new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() });
  327. yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectJogressEffect.SelectDigivolutionRoots());
  328. IEnumerator EndSelectCoroutine_SelectDigivolutionRoots(List<Permanent> permanents)
  329. {
  330. permanents = permanents.Distinct().ToList();
  331. if (permanents.Count == 2)
  332. {
  333. JogressEvoRootsFrameIDs = new int[2];
  334. for (int i = 0; i < permanents.Count; i++)
  335. {
  336. if (i < JogressEvoRootsFrameIDs.Length)
  337. {
  338. JogressEvoRootsFrameIDs[i] = permanents[i].PermanentFrame.FrameID;
  339. }
  340. }
  341. }
  342. if (!permanents.Contains(card.PermanentOfThisCard()))
  343. {
  344. JogressEvoRootsFrameIDs = new int[0];
  345. }
  346. yield return null;
  347. }
  348. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All, JogressEvoRootsFrameIDs);
  349. }
  350. else
  351. {
  352. GManager.instance.commandText.OpenCommandText("The opponent is choosing a card to DNA digivolve.");
  353. }
  354. yield return new WaitWhile(() => !endSelect);
  355. endSelect = false;
  356. GManager.instance.commandText.CloseCommandText();
  357. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  358. if (JogressEvoRootsFrameIDs.Length == 2)
  359. {
  360. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { selectedCard }, "Played Card", true, true));
  361. PlayCardClass playCard = new PlayCardClass(
  362. cardSources: new List<CardSource>() { selectedCard },
  363. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  364. payCost: true,
  365. targetPermanent: null,
  366. isTapped: false,
  367. root: SelectCardEffect.Root.Hand,
  368. activateETB: true);
  369. playCard.SetJogress(JogressEvoRootsFrameIDs);
  370. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  371. }
  372. }
  373. }
  374. }
  375. }
  376. }
  377. }
  378. }
  379. }
  380. }
  381. #endregion
  382. #region InheritedEffects
  383. if (timing == EffectTiming.OnDestroyedAnyone)
  384. {
  385. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  386. }
  387. #endregion
  388. return cardEffects;
  389. }
  390. bool endSelect = false;
  391. int[] JogressEvoRootsFrameIDs = new int[0];
  392. [PunRPC]
  393. public void SetJogressEvoRootsFrameIDs(int[] JogressEvoRootsFrameIDs)
  394. {
  395. this.JogressEvoRootsFrameIDs = JogressEvoRootsFrameIDs;
  396. endSelect = true;
  397. }
  398. }
  399. }