Lucemon_BT18_034.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.BT18
  7. {
  8. public class Lucemon_BT18_034 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Cupimon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 5,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Start of Your Main Phase
  30. if (timing == EffectTiming.OnStartMainPhase)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Trash 1 card from hand to trash the opponents top security or Recovery +1", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[Start of Your Main Phase] By trashing 1 card in your hand, your opponent may trash their top security card. If this effect didn't trash, <Revovery +1>";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  43. {
  44. if (CardEffectCommons.IsOwnerTurn(card))
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  54. {
  55. if (card.Owner.HandCards.Count >= 1)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. if (card.Owner.HandCards.Count >= 1)
  65. {
  66. bool discarded = false;
  67. int discardCount = 1;
  68. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  69. selectHandEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: (cardSource) => true,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: discardCount,
  75. canNoSelect: true,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. selectCardCoroutine: null,
  79. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  80. mode: SelectHandEffect.Mode.Discard,
  81. cardEffect: activateClass);
  82. yield return StartCoroutine(selectHandEffect.Activate());
  83. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  84. {
  85. if (cardSources.Count >= 1)
  86. {
  87. discarded = true;
  88. yield return null;
  89. }
  90. }
  91. if (discarded)
  92. {
  93. if (card.Owner.Enemy.SecurityCards.Count == 0)
  94. {
  95. SetDoDiscard(false);
  96. }
  97. else
  98. {
  99. if (!card.Owner.isYou)
  100. {
  101. GManager.instance.commandText.OpenCommandText("Will you discard the top card of your security?");
  102. List<Command_SelectCommand> command_SelectCommands = new List<Command_SelectCommand>()
  103. {
  104. new Command_SelectCommand($"Discard", () => photonView.RPC("SetDoDiscard", RpcTarget.All, true), 0),
  105. new Command_SelectCommand($"Not Discard", () => photonView.RPC("SetDoDiscard", RpcTarget.All, false), 1),
  106. };
  107. GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
  108. }
  109. else
  110. {
  111. GManager.instance.commandText.OpenCommandText("The opponent is choosing whether to discard security.");
  112. #region AI
  113. if (GManager.instance.IsAI)
  114. {
  115. SetDoDiscard(RandomUtility.IsSucceedProbability(0.5f));
  116. }
  117. #endregion
  118. }
  119. }
  120. yield return new WaitWhile(() => !endSelect);
  121. endSelect = false;
  122. GManager.instance.commandText.CloseCommandText();
  123. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  124. if (!doDiscard)
  125. {
  126. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  127. }
  128. else
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  131. player: card.Owner.Enemy,
  132. destroySecurityCount: 1,
  133. cardEffect: activateClass,
  134. fromTop: true).DestroySecurity());
  135. }
  136. }
  137. }
  138. }
  139. }
  140. #endregion
  141. #region On Play
  142. if (timing == EffectTiming.OnEnterFieldAnyone)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect("Trash 1 card from hand to trash the opponents top security or Recovery +1", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  147. cardEffects.Add(activateClass);
  148. string EffectDiscription()
  149. {
  150. return "[On Play] By trashing 1 card in your hand, your opponent may trash their top security card. If this effect didn't trash, <Revovery +1>";
  151. }
  152. bool CanUseCondition(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  155. }
  156. bool CanActivateCondition(Hashtable hashtable)
  157. {
  158. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  159. {
  160. if (card.Owner.HandCards.Count >= 1)
  161. {
  162. return true;
  163. }
  164. }
  165. return false;
  166. }
  167. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  168. {
  169. if (card.Owner.HandCards.Count >= 1)
  170. {
  171. bool discarded = false;
  172. int discardCount = 1;
  173. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  174. selectHandEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: (cardSource) => true,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: discardCount,
  180. canNoSelect: true,
  181. canEndNotMax: false,
  182. isShowOpponent: true,
  183. selectCardCoroutine: null,
  184. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  185. mode: SelectHandEffect.Mode.Discard,
  186. cardEffect: activateClass);
  187. yield return StartCoroutine(selectHandEffect.Activate());
  188. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  189. {
  190. if (cardSources.Count >= 1)
  191. {
  192. discarded = true;
  193. yield return null;
  194. }
  195. }
  196. if (discarded)
  197. {
  198. if (card.Owner.Enemy.SecurityCards.Count == 0)
  199. {
  200. SetDoDiscard(false);
  201. }
  202. else
  203. {
  204. if (!card.Owner.isYou)
  205. {
  206. GManager.instance.commandText.OpenCommandText("Will you discard the top card of your security?");
  207. List<Command_SelectCommand> command_SelectCommands = new List<Command_SelectCommand>()
  208. {
  209. new Command_SelectCommand($"Discard", () => photonView.RPC("SetDoDiscard", RpcTarget.All, true), 0),
  210. new Command_SelectCommand($"Not Discard", () => photonView.RPC("SetDoDiscard", RpcTarget.All, false), 1),
  211. };
  212. GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
  213. }
  214. else
  215. {
  216. GManager.instance.commandText.OpenCommandText("The opponent is choosing whether to discard security.");
  217. #region AI
  218. if (GManager.instance.IsAI)
  219. {
  220. SetDoDiscard(RandomUtility.IsSucceedProbability(0.5f));
  221. }
  222. #endregion
  223. }
  224. }
  225. yield return new WaitWhile(() => !endSelect);
  226. endSelect = false;
  227. GManager.instance.commandText.CloseCommandText();
  228. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  229. if (!doDiscard)
  230. {
  231. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  232. }
  233. else
  234. {
  235. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  236. player: card.Owner.Enemy,
  237. destroySecurityCount: 1,
  238. cardEffect: activateClass,
  239. fromTop: true).DestroySecurity());
  240. }
  241. }
  242. }
  243. }
  244. }
  245. #endregion
  246. #region End of Your Turn
  247. if (timing == EffectTiming.OnEndTurn)
  248. {
  249. ActivateClass activateClass = new ActivateClass();
  250. activateClass.SetUpICardEffect("Place one of your level 6 Digimon on top of your security stack to digivolve into [Lucemon: Chaos Mode] in the trash without paying the cost.", CanUseCondition, card);
  251. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  252. activateClass.SetHashString("EOT_BT18-034");
  253. cardEffects.Add(activateClass);
  254. string EffectDescription()
  255. {
  256. return "[End of Your Turn] [Once Per Turn] By placing one of your level 6 Digimon on top of your security stack, this Digimon may digivolve into [Lucemon: Chaos Mode] in the trash without paying the cost.";
  257. }
  258. bool IsPermanentLevel6Condition(Permanent permanent)
  259. {
  260. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  261. {
  262. if (permanent.TopCard.IsLevel6)
  263. {
  264. return true;
  265. }
  266. }
  267. return false;
  268. }
  269. bool IsCardLucemonChaosModeCondition(CardSource cardSource)
  270. {
  271. if (cardSource.IsDigimon)
  272. {
  273. if (cardSource.ContainsCardName("Lucemon: Chaos Mode") || cardSource.ContainsCardName("Lucemon:ChaosMode") || cardSource.ContainsCardName("Lucemon Chaos Mode") || cardSource.ContainsCardName("LucemonChaosMode"))
  274. {
  275. if (cardSource.CanEvolve(card.PermanentOfThisCard(), true))
  276. {
  277. return true;
  278. }
  279. }
  280. }
  281. return false;
  282. }
  283. bool CanUseCondition(Hashtable hashtable)
  284. {
  285. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  286. {
  287. if (CardEffectCommons.IsOwnerTurn(card))
  288. {
  289. return true;
  290. }
  291. }
  292. return false;
  293. }
  294. bool CanActivateCondition(Hashtable hashtable)
  295. {
  296. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  297. {
  298. if (CardEffectCommons.HasMatchConditionPermanent(IsPermanentLevel6Condition))
  299. {
  300. return true;
  301. }
  302. }
  303. return false;
  304. }
  305. IEnumerator ActivateCoroutine(Hashtable hashtable)
  306. {
  307. if (CardEffectCommons.HasMatchConditionPermanent(IsPermanentLevel6Condition))
  308. {
  309. Permanent selectedPermanent = null;
  310. int maxCount = Math.Min(1,
  311. CardEffectCommons.MatchConditionPermanentCount(IsPermanentLevel6Condition));
  312. SelectPermanentEffect selectPermanentEffect =
  313. GManager.instance.GetComponent<SelectPermanentEffect>();
  314. selectPermanentEffect.SetUp(
  315. selectPlayer: card.Owner,
  316. canTargetCondition: IsPermanentLevel6Condition,
  317. canTargetCondition_ByPreSelecetedList: null,
  318. canEndSelectCondition: null,
  319. maxCount: maxCount,
  320. canNoSelect: true,
  321. canEndNotMax: false,
  322. selectPermanentCoroutine: SelectPermanentCoroutine,
  323. afterSelectPermanentCoroutine: null,
  324. mode: SelectPermanentEffect.Mode.Custom,
  325. cardEffect: activateClass);
  326. selectPermanentEffect.SetUpCustomMessage(
  327. "Select 1 Digimon to place on top of your security stack.",
  328. "The opponent is selecting 1 Digimon to place on top of their security stack.");
  329. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  330. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  331. {
  332. selectedPermanent = permanent;
  333. yield return null;
  334. }
  335. if (selectedPermanent != null)
  336. {
  337. if (selectedPermanent.TopCard != null)
  338. {
  339. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  340. {
  341. CardSource securityCard = selectedPermanent.TopCard;
  342. yield return ContinuousController.instance.StartCoroutine(
  343. new IPutSecurityPermanent(selectedPermanent,
  344. CardEffectCommons.CardEffectHashtable(activateClass),
  345. toTop: true).PutSecurity());
  346. if (selectedPermanent.TopCard == null)
  347. {
  348. if (securityCard.Owner.SecurityCards.Contains(securityCard))
  349. {
  350. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsCardLucemonChaosModeCondition))
  351. {
  352. yield return ContinuousController.instance.StartCoroutine(
  353. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  354. targetPermanent: card.PermanentOfThisCard(),
  355. cardCondition: IsCardLucemonChaosModeCondition,
  356. payCost: false,
  357. reduceCostTuple: null,
  358. fixedCostTuple: null,
  359. ignoreDigivolutionRequirementFixedCost: -1,
  360. isHand: false,
  361. activateClass: activateClass,
  362. successProcess: null));
  363. }
  364. }
  365. }
  366. }
  367. }
  368. }
  369. }
  370. }
  371. }
  372. #endregion
  373. return cardEffects;
  374. }
  375. #region Extras
  376. bool endSelect = false;
  377. bool doDiscard = false;
  378. [PunRPC]
  379. public void SetDoDiscard(bool doDiscard)
  380. {
  381. this.doDiscard = doDiscard;
  382. endSelect = true;
  383. }
  384. #endregion
  385. }
  386. }