BT20_074.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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
  9. {
  10. public class BT20_074 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region DNA Digivolve
  16. if (timing == EffectTiming.None)
  17. {
  18. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  19. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  20. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  21. addJogressConditionClass.SetNotShowUI(true);
  22. cardEffects.Add(addJogressConditionClass);
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return true;
  26. }
  27. JogressCondition GetJogress(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. bool PermanentCondition1(Permanent permanent)
  32. {
  33. if (permanent != null)
  34. {
  35. if (permanent.TopCard != null)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  38. {
  39. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  40. {
  41. if (permanent.Levels_ForJogress(card).Contains(4))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool PermanentCondition2(Permanent permanent)
  52. {
  53. if (permanent != null)
  54. {
  55. if (permanent.TopCard != null)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  58. {
  59. if (permanent.TopCard.CardColors.Contains(CardColor.Red))
  60. {
  61. if (permanent.Levels_ForJogress(card).Contains(4))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. JogressConditionElement[] elements = new JogressConditionElement[]
  72. {
  73. new JogressConditionElement(PermanentCondition1, "a level 4 purple Digimon"),
  74. new JogressConditionElement(PermanentCondition2, "a level 4 red Digimon"),
  75. };
  76. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  77. return jogressCondition;
  78. }
  79. return null;
  80. }
  81. }
  82. #endregion
  83. #region On Play
  84. if (timing == EffectTiming.OnEnterFieldAnyone)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Return a card, DNA Digivolve into Imperialdramon", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  89. cardEffects.Add(activateClass);
  90. string EffectDiscription()
  91. {
  92. return "[On Play] You may return 1 Digimon card with [Imperialdramon] in its name or the [Free] trait from your trash to the hand.";
  93. }
  94. bool CanSelectCardCondition(CardSource cardSource){
  95. if (cardSource.EqualsTraits("Free") || cardSource.ContainsCardName("Imperialdramon")){
  96. return true;
  97. }
  98. return false;
  99. }
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  103. }
  104. bool CanActivateCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  107. }
  108. IEnumerator ActivateCoroutine(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  111. {
  112. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  113. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  114. selectCardEffect.SetUp(
  115. canTargetCondition: CanSelectCardCondition,
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. canNoSelect: () => true,
  119. selectCardCoroutine: null,
  120. afterSelectCardCoroutine: null,
  121. message: "Select 1 card to add to your hand.",
  122. maxCount: maxCount,
  123. canEndNotMax: false,
  124. isShowOpponent: true,
  125. mode: SelectCardEffect.Mode.AddHand,
  126. root: SelectCardEffect.Root.Trash,
  127. customRootCardList: null,
  128. canLookReverseCard: true,
  129. selectPlayer: card.Owner,
  130. cardEffect: activateClass);
  131. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  132. }
  133. }
  134. }
  135. #endregion
  136. #region When Digivolving
  137. if (timing == EffectTiming.OnEnterFieldAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("Return a card, DNA Digivolve into Imperialdramon", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[When Digivolving] You may return 1 Digimon card with [Imperialdramon] in its name or the [Free] trait from your trash to the hand.";
  146. }
  147. bool CanSelectCardCondition(CardSource cardSource){
  148. if (cardSource.EqualsTraits("Free") || cardSource.ContainsCardName("Imperialdramon")){
  149. return true;
  150. }
  151. return false;
  152. }
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  164. {
  165. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  166. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  167. selectCardEffect.SetUp(
  168. canTargetCondition: CanSelectCardCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. canNoSelect: () => true,
  172. selectCardCoroutine: null,
  173. afterSelectCardCoroutine: null,
  174. message: "Select 1 card to add to your hand.",
  175. maxCount: maxCount,
  176. canEndNotMax: false,
  177. isShowOpponent: true,
  178. mode: SelectCardEffect.Mode.AddHand,
  179. root: SelectCardEffect.Root.Trash,
  180. customRootCardList: null,
  181. canLookReverseCard: true,
  182. selectPlayer: card.Owner,
  183. cardEffect: activateClass);
  184. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  185. }
  186. }
  187. }
  188. #endregion
  189. #region All Turns
  190. if(timing == EffectTiming.WhenReturntoLibraryAnyone || timing == EffectTiming.WhenReturntoHandAnyone ){
  191. ActivateClass activateClass = new ActivateClass();
  192. activateClass.SetUpICardEffect("If returned, DNA Digivolve", CanUseCondition, card);
  193. activateClass.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine, -1, true, EffectDiscription());
  194. activateClass.SetIsInheritedEffect(true);
  195. activateClass.SetHashString("Dna Digivolve into Imperialdramon");
  196. cardEffects.Add(activateClass);
  197. string EffectDiscription(){
  198. return "[All Turns] When any of your [Dinobeemon]/[Paildramon] would be returned to hands or decks, 2 of your Digimon may DNA digivolve into [Imperialdramon: Dragon Mode] in the hand.";
  199. }
  200. bool isPaildramonOrDinoBeemon(Permanent permanent){
  201. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  202. {
  203. if(permanent.TopCard.EqualsCardName("Dinobeemon") || permanent.TopCard.EqualsCardName("Paildramon"))
  204. {
  205. return true;
  206. }
  207. }
  208. return false;
  209. }
  210. bool CanSelectDNACardCondition(CardSource cardSource)
  211. {
  212. if (cardSource.IsDigimon)
  213. {
  214. if (cardSource.CanPlayJogress(true))
  215. {
  216. if (cardSource.EqualsCardName("Imperialdramon: Dragon Mode"))
  217. {
  218. return true;
  219. }
  220. }
  221. }
  222. return false;
  223. }
  224. bool CanUseCondition(Hashtable hashtable)
  225. {
  226. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  227. }
  228. bool CanActivateCondition1(Hashtable hashtable)
  229. {
  230. if(CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, isPaildramonOrDinoBeemon)){
  231. if (CardEffectCommons.MatchConditionPermanentCount(isPaildramonOrDinoBeemon)>=2){
  232. return true;
  233. }
  234. return false;
  235. }
  236. return false;
  237. }
  238. IEnumerator ActivateCoroutine(Hashtable hashtable)
  239. {
  240. List<CardSource> selectedCards = new List<CardSource>();
  241. int maxCount = 1;
  242. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  243. selectHandEffect.SetUp(
  244. selectPlayer: card.Owner,
  245. canTargetCondition: CanSelectDNACardCondition,
  246. canTargetCondition_ByPreSelecetedList: null,
  247. canEndSelectCondition: null,
  248. maxCount: maxCount,
  249. canNoSelect: true,
  250. canEndNotMax: false,
  251. isShowOpponent: true,
  252. selectCardCoroutine: SelectCardCoroutine,
  253. afterSelectCardCoroutine: null,
  254. mode: SelectHandEffect.Mode.Custom,
  255. cardEffect: activateClass);
  256. selectHandEffect.SetUpCustomMessage("Select 1 card to DNA digivolve.", "The opponent is selecting 1 card to DNA digivolve.");
  257. selectHandEffect.SetNotShowCard();
  258. yield return StartCoroutine(selectHandEffect.Activate());
  259. IEnumerator SelectCardCoroutine(CardSource cardSource)
  260. {
  261. selectedCards.Add(cardSource);
  262. yield return null;
  263. }
  264. if (selectedCards.Count >= 1)
  265. {
  266. foreach (CardSource selectedCard in selectedCards)
  267. {
  268. if (selectedCard.CanPlayJogress(true))
  269. {
  270. _jogressEvoRootsFrameIDs = new int[0];
  271. yield return GManager.instance.photonWaitController.StartWait("Dinobeemon_BT20_074");
  272. if (card.Owner.isYou || GManager.instance.IsAI)
  273. {
  274. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  275. (card: selectedCard,
  276. isLocal: true,
  277. isPayCost: true,
  278. canNoSelect: true,
  279. endSelectCoroutine_SelectDigivolutionRoots: EndSelectCoroutine_SelectDigivolutionRoots,
  280. noSelectCoroutine: null);
  281. yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectJogressEffect.SelectDigivolutionRoots());
  282. IEnumerator EndSelectCoroutine_SelectDigivolutionRoots(List<Permanent> permanents)
  283. {
  284. if (permanents.Count == 2)
  285. {
  286. _jogressEvoRootsFrameIDs = permanents.Distinct().ToArray().Map(permanent => permanent.PermanentFrame.FrameID);
  287. }
  288. yield return null;
  289. }
  290. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All, _jogressEvoRootsFrameIDs);
  291. }
  292. else
  293. {
  294. GManager.instance.commandText.OpenCommandText("The opponent is choosing a card to DNA digivolve.");
  295. }
  296. yield return new WaitWhile(() => !_endSelect);
  297. _endSelect = false;
  298. GManager.instance.commandText.CloseCommandText();
  299. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  300. if (_jogressEvoRootsFrameIDs.Length == 2)
  301. {
  302. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { selectedCard }, "Played Card", true, true));
  303. PlayCardClass playCard = new PlayCardClass(
  304. cardSources: new List<CardSource>() { selectedCard },
  305. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  306. payCost: true,
  307. targetPermanent: null,
  308. isTapped: false,
  309. root: SelectCardEffect.Root.Hand,
  310. activateETB: true);
  311. playCard.SetJogress(_jogressEvoRootsFrameIDs);
  312. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  313. }
  314. }
  315. }
  316. }
  317. }
  318. }
  319. #endregion
  320. #region Inherited Effect
  321. if (timing == EffectTiming.None)
  322. {
  323. DisableEffectClass invalidationClass = new DisableEffectClass();
  324. invalidationClass.SetUpICardEffect("Ignore Security Effect", CanUseCondition, card);
  325. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  326. invalidationClass.SetIsInheritedEffect(true);
  327. cardEffects.Add(invalidationClass);
  328. bool CanUseCondition(Hashtable hashtable)
  329. {
  330. return true;
  331. }
  332. bool InvalidateCondition(ICardEffect cardEffect)
  333. {
  334. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOwnerTurn(card) && cardEffect.EffectSourceCard != null && cardEffect.EffectSourceCard.IsOption && cardEffect.IsSecurityEffect && GManager.instance.attackProcess.AttackingPermanent == card.PermanentOfThisCard())
  335. {
  336. return true;
  337. }
  338. return false;
  339. }
  340. }
  341. #endregion
  342. return cardEffects;
  343. }
  344. private bool _endSelect = false;
  345. private int[] _jogressEvoRootsFrameIDs = new int[0];
  346. [PunRPC]
  347. public void SetJogressEvoRootsFrameIDs(int[] JogressEvoRootsFrameIDs)
  348. {
  349. this._jogressEvoRootsFrameIDs = JogressEvoRootsFrameIDs;
  350. _endSelect = true;
  351. }
  352. }
  353. }