BT20_016.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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_016 : 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 red Digimon"),
  74. new JogressConditionElement(PermanentCondition2, "a level 4 purple 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("Piercing and Digivolve into Imperialdramon Dragon Mode", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  89. cardEffects.Add(activateClass);
  90. string EffectDiscription()
  91. {
  92. return "[On Play]For the turn, 1 of your Digimon gains <Piercing> (When this Digimon attacks and deletes an opponent's Digimon and survives the battle, it performs any security checks it normally would) and gets +4000 DP. Then, this Digimon may attack.";
  93. }
  94. bool CanSelectPermanentCondition(Permanent permanent)
  95. {
  96. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  97. }
  98. bool CanActivateCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  107. {
  108. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  109. {
  110. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  111. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  112. selectPermanentEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: CanSelectPermanentCondition,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: maxCount,
  118. canNoSelect: false,
  119. canEndNotMax: false,
  120. selectPermanentCoroutine: SelectPermanentCoroutine,
  121. afterSelectPermanentCoroutine: null,
  122. mode: SelectPermanentEffect.Mode.Custom,
  123. cardEffect: activateClass);
  124. selectPermanentEffect.SetUpCustomMessage(
  125. "Select 1 Digimon that will gain Pierce and 4000DP.",
  126. "The opponent is selecting 1 Digimon that will gain Pierce and 4000DP.");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(
  131. targetPermanent: permanent,
  132. effectDuration: EffectDuration.UntilEachTurnEnd,
  133. activateClass: activateClass));
  134. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  135. targetPermanent: permanent,
  136. changeValue: 4000,
  137. effectDuration: EffectDuration.UntilEachTurnEnd,
  138. activateClass: activateClass));
  139. }
  140. }
  141. if (card.PermanentOfThisCard().CanAttack(activateClass))
  142. {
  143. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  144. selectAttackEffect.SetUp(
  145. attacker: card.PermanentOfThisCard(),
  146. canAttackPlayerCondition: () => true,
  147. defenderCondition: _ => true,
  148. cardEffect: activateClass);
  149. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  150. }
  151. }
  152. }
  153. #endregion
  154. #region On Digivolving
  155. if (timing == EffectTiming.OnEnterFieldAnyone)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect("1 Digimon gains Piercing and 4000DP, then this digimon may attack", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  160. cardEffects.Add(activateClass);
  161. string EffectDiscription()
  162. {
  163. return "[When Digivolving] For the turn, 1 of your Digimon gains <Piercing> (When this Digimon attacks and deletes an opponent's Digimon and survives the battle, it performs any security checks it normally would) and gets +4000 DP. Then, this Digimon may attack.";
  164. }
  165. bool CanSelectPermanentCondition(Permanent permanent)
  166. {
  167. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  168. }
  169. bool CanActivateCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  176. }
  177. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  178. {
  179. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  180. {
  181. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  182. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  183. selectPermanentEffect.SetUp(
  184. selectPlayer: card.Owner,
  185. canTargetCondition: CanSelectPermanentCondition,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. maxCount: maxCount,
  189. canNoSelect: false,
  190. canEndNotMax: false,
  191. selectPermanentCoroutine: SelectPermanentCoroutine,
  192. afterSelectPermanentCoroutine: null,
  193. mode: SelectPermanentEffect.Mode.Custom,
  194. cardEffect: activateClass);
  195. selectPermanentEffect.SetUpCustomMessage(
  196. "Select 1 Digimon that will gain Pierce and 4000DP.",
  197. "The opponent is selecting 1 Digimon that will gain Pierce and 4000DP.");
  198. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  199. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  200. {
  201. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(
  202. targetPermanent: permanent,
  203. effectDuration: EffectDuration.UntilEachTurnEnd,
  204. activateClass: activateClass));
  205. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  206. targetPermanent: permanent,
  207. changeValue: 4000,
  208. effectDuration: EffectDuration.UntilEachTurnEnd,
  209. activateClass: activateClass));
  210. }
  211. }
  212. if (card.PermanentOfThisCard().CanAttack(activateClass))
  213. {
  214. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  215. selectAttackEffect.SetUp(
  216. attacker: card.PermanentOfThisCard(),
  217. canAttackPlayerCondition: () => true,
  218. defenderCondition: _ => true,
  219. cardEffect: activateClass);
  220. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  221. }
  222. }
  223. }
  224. #endregion
  225. #region All Turns
  226. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  227. {
  228. ActivateClass activateClass = new ActivateClass();
  229. activateClass.SetUpICardEffect("If would be deleted, DNA Digivolve", CanUseCondition, card);
  230. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  231. activateClass.SetHashString("Dna Digivolve into Imperialdramon Dragon Mode");
  232. cardEffects.Add(activateClass);
  233. string EffectDiscription()
  234. {
  235. return "[All Turns] When any of your [Paildramon]/[Dinobeemon] would be deleted, 2 of your Digimon may DNA digivolve into [Imperialdramon: Dragon Mode] in the hand.";
  236. }
  237. bool isPaildramonOrDinoBeemon(Permanent permanent)
  238. {
  239. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  240. {
  241. if (permanent.TopCard.EqualsCardName("Dinobeemon") || permanent.TopCard.EqualsCardName("Paildramon"))
  242. {
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248. bool CanActivateCondition(Hashtable hashtable)
  249. {
  250. return CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, isPaildramonOrDinoBeemon);
  251. }
  252. bool CanSelectDNACardCondition(CardSource cardSource)
  253. {
  254. if (cardSource.IsDigimon)
  255. {
  256. if (cardSource.CanPlayJogress(true))
  257. {
  258. if (cardSource.EqualsCardName("Imperialdramon: Dragon Mode"))
  259. {
  260. return true;
  261. }
  262. }
  263. }
  264. return false;
  265. }
  266. bool CanUseCondition(Hashtable hashtable)
  267. {
  268. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  269. }
  270. IEnumerator ActivateCoroutine(Hashtable hashtable)
  271. {
  272. List<CardSource> selectedCards = new List<CardSource>();
  273. int maxCount = 1;
  274. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  275. selectHandEffect.SetUp(
  276. selectPlayer: card.Owner,
  277. canTargetCondition: CanSelectDNACardCondition,
  278. canTargetCondition_ByPreSelecetedList: null,
  279. canEndSelectCondition: null,
  280. maxCount: maxCount,
  281. canNoSelect: true,
  282. canEndNotMax: false,
  283. isShowOpponent: true,
  284. selectCardCoroutine: SelectCardCoroutine,
  285. afterSelectCardCoroutine: null,
  286. mode: SelectHandEffect.Mode.Custom,
  287. cardEffect: activateClass);
  288. selectHandEffect.SetUpCustomMessage("Select 1 card to DNA digivolve.", "The opponent is selecting 1 card to DNA digivolve.");
  289. selectHandEffect.SetNotShowCard();
  290. yield return StartCoroutine(selectHandEffect.Activate());
  291. IEnumerator SelectCardCoroutine(CardSource cardSource)
  292. {
  293. selectedCards.Add(cardSource);
  294. yield return null;
  295. }
  296. if (selectedCards.Count >= 1)
  297. {
  298. foreach (CardSource selectedCard in selectedCards)
  299. {
  300. if (selectedCard.CanPlayJogress(true))
  301. {
  302. _jogressEvoRootsFrameIDs = new int[0];
  303. yield return GManager.instance.photonWaitController.StartWait("Paildramon_BT_016");
  304. if (card.Owner.isYou || GManager.instance.IsAI)
  305. {
  306. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  307. (card: selectedCard,
  308. isLocal: true,
  309. isPayCost: true,
  310. canNoSelect: true,
  311. endSelectCoroutine_SelectDigivolutionRoots: EndSelectCoroutine_SelectDigivolutionRoots,
  312. noSelectCoroutine: null);
  313. yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectJogressEffect.SelectDigivolutionRoots());
  314. IEnumerator EndSelectCoroutine_SelectDigivolutionRoots(List<Permanent> permanents)
  315. {
  316. if (permanents.Count == 2)
  317. {
  318. _jogressEvoRootsFrameIDs = permanents.Distinct().ToArray().Map(permanent => permanent.PermanentFrame.FrameID);
  319. }
  320. yield return null;
  321. }
  322. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All, _jogressEvoRootsFrameIDs);
  323. }
  324. else
  325. {
  326. GManager.instance.commandText.OpenCommandText("The opponent is choosing a card to DNA digivolve.");
  327. }
  328. yield return new WaitWhile(() => !_endSelect);
  329. _endSelect = false;
  330. GManager.instance.commandText.CloseCommandText();
  331. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  332. if (_jogressEvoRootsFrameIDs.Length == 2)
  333. {
  334. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { selectedCard }, "Played Card", true, true));
  335. PlayCardClass playCard = new PlayCardClass(
  336. cardSources: new List<CardSource>() { selectedCard },
  337. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  338. payCost: true,
  339. targetPermanent: null,
  340. isTapped: false,
  341. root: SelectCardEffect.Root.Hand,
  342. activateETB: true);
  343. playCard.SetJogress(_jogressEvoRootsFrameIDs);
  344. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. #endregion
  352. #region InheritedEffect
  353. if (timing == EffectTiming.None)
  354. {
  355. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: null));
  356. }
  357. #endregion
  358. return cardEffects;
  359. }
  360. private bool _endSelect = false;
  361. private int[] _jogressEvoRootsFrameIDs = new int[0];
  362. [PunRPC]
  363. public void SetJogressEvoRootsFrameIDs(int[] JogressEvoRootsFrameIDs)
  364. {
  365. this._jogressEvoRootsFrameIDs = JogressEvoRootsFrameIDs;
  366. _endSelect = true;
  367. }
  368. }
  369. }