BT20_011.cs 24 KB

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