BT18_034.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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 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. GManager.instance.userSelectionManager.SetBool(false);
  96. }
  97. else
  98. {
  99. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  100. {
  101. new SelectionElement<bool>(message: $"Discard", value : true, spriteIndex: 0),
  102. new SelectionElement<bool>(message: $"Not Discard", value : false, spriteIndex: 1),
  103. };
  104. string selectPlayerMessage = "Will you discard the top card of your security?";
  105. string notSelectPlayerMessage = "The opponent is choosing whether to discard security.";
  106. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner.Enemy, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  107. }
  108. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  109. bool doDiscard = GManager.instance.userSelectionManager.SelectedBoolValue;
  110. if (!doDiscard)
  111. {
  112. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  113. }
  114. else
  115. {
  116. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  117. player: card.Owner.Enemy,
  118. destroySecurityCount: 1,
  119. cardEffect: activateClass,
  120. fromTop: true).DestroySecurity());
  121. }
  122. }
  123. }
  124. }
  125. }
  126. #endregion
  127. #region On Play
  128. if (timing == EffectTiming.OnEnterFieldAnyone)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect("Trash 1 card from hand to trash the opponents top security or Recovery +1", CanUseCondition, card);
  132. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  133. cardEffects.Add(activateClass);
  134. string EffectDiscription()
  135. {
  136. 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>";
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  141. }
  142. bool CanActivateCondition(Hashtable hashtable)
  143. {
  144. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  145. {
  146. if (card.Owner.HandCards.Count >= 1)
  147. {
  148. return true;
  149. }
  150. }
  151. return false;
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  154. {
  155. if (card.Owner.HandCards.Count >= 1)
  156. {
  157. bool discarded = false;
  158. int discardCount = 1;
  159. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  160. selectHandEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition: (cardSource) => true,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. maxCount: discardCount,
  166. canNoSelect: true,
  167. canEndNotMax: false,
  168. isShowOpponent: true,
  169. selectCardCoroutine: null,
  170. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  171. mode: SelectHandEffect.Mode.Discard,
  172. cardEffect: activateClass);
  173. yield return StartCoroutine(selectHandEffect.Activate());
  174. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  175. {
  176. if (cardSources.Count >= 1)
  177. {
  178. discarded = true;
  179. yield return null;
  180. }
  181. }
  182. if (discarded)
  183. {
  184. if (card.Owner.Enemy.SecurityCards.Count == 0)
  185. {
  186. GManager.instance.userSelectionManager.SetBool(false);
  187. }
  188. else
  189. {
  190. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  191. {
  192. new SelectionElement<bool>(message: $"Discard", value : true, spriteIndex: 0),
  193. new SelectionElement<bool>(message: $"Not Discard", value : false, spriteIndex: 1),
  194. };
  195. string selectPlayerMessage = "Will you discard the top card of your security?";
  196. string notSelectPlayerMessage = "The opponent is choosing whether to discard security.";
  197. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner.Enemy, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  198. }
  199. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  200. bool doDiscard = GManager.instance.userSelectionManager.SelectedBoolValue;
  201. if (!doDiscard)
  202. {
  203. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  204. }
  205. else
  206. {
  207. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  208. player: card.Owner.Enemy,
  209. destroySecurityCount: 1,
  210. cardEffect: activateClass,
  211. fromTop: true).DestroySecurity());
  212. }
  213. }
  214. }
  215. }
  216. }
  217. #endregion
  218. #region End of Your Turn
  219. if (timing == EffectTiming.OnEndTurn)
  220. {
  221. ActivateClass activateClass = new ActivateClass();
  222. 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);
  223. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  224. activateClass.SetHashString("EOT_BT18-034");
  225. cardEffects.Add(activateClass);
  226. string EffectDescription()
  227. {
  228. 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.";
  229. }
  230. bool IsPermanentLevel6Condition(Permanent permanent)
  231. {
  232. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  233. {
  234. if (permanent.TopCard.IsLevel6)
  235. {
  236. return true;
  237. }
  238. }
  239. return false;
  240. }
  241. bool IsCardLucemonChaosModeCondition(CardSource cardSource)
  242. {
  243. if (cardSource.IsDigimon)
  244. {
  245. if (cardSource.ContainsCardName("Lucemon: Chaos Mode") || cardSource.ContainsCardName("Lucemon:ChaosMode") || cardSource.ContainsCardName("Lucemon Chaos Mode") || cardSource.ContainsCardName("LucemonChaosMode"))
  246. {
  247. if (cardSource.CanEvolve(card.PermanentOfThisCard(), true))
  248. {
  249. return true;
  250. }
  251. }
  252. }
  253. return false;
  254. }
  255. bool CanUseCondition(Hashtable hashtable)
  256. {
  257. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  258. {
  259. if (CardEffectCommons.IsOwnerTurn(card))
  260. {
  261. return true;
  262. }
  263. }
  264. return false;
  265. }
  266. bool CanActivateCondition(Hashtable hashtable)
  267. {
  268. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  269. {
  270. if (CardEffectCommons.HasMatchConditionPermanent(IsPermanentLevel6Condition))
  271. {
  272. return true;
  273. }
  274. }
  275. return false;
  276. }
  277. IEnumerator ActivateCoroutine(Hashtable hashtable)
  278. {
  279. if (CardEffectCommons.HasMatchConditionPermanent(IsPermanentLevel6Condition))
  280. {
  281. Permanent selectedPermanent = null;
  282. int maxCount = Math.Min(1,
  283. CardEffectCommons.MatchConditionPermanentCount(IsPermanentLevel6Condition));
  284. SelectPermanentEffect selectPermanentEffect =
  285. GManager.instance.GetComponent<SelectPermanentEffect>();
  286. selectPermanentEffect.SetUp(
  287. selectPlayer: card.Owner,
  288. canTargetCondition: IsPermanentLevel6Condition,
  289. canTargetCondition_ByPreSelecetedList: null,
  290. canEndSelectCondition: null,
  291. maxCount: maxCount,
  292. canNoSelect: true,
  293. canEndNotMax: false,
  294. selectPermanentCoroutine: SelectPermanentCoroutine,
  295. afterSelectPermanentCoroutine: null,
  296. mode: SelectPermanentEffect.Mode.Custom,
  297. cardEffect: activateClass);
  298. selectPermanentEffect.SetUpCustomMessage(
  299. "Select 1 Digimon to place on top of your security stack.",
  300. "The opponent is selecting 1 Digimon to place on top of their security stack.");
  301. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  302. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  303. {
  304. selectedPermanent = permanent;
  305. yield return null;
  306. }
  307. if (selectedPermanent != null)
  308. {
  309. if (selectedPermanent.TopCard != null)
  310. {
  311. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  312. {
  313. CardSource securityCard = selectedPermanent.TopCard;
  314. yield return ContinuousController.instance.StartCoroutine(
  315. CardEffectCommons.PlacePermanentInSecurityAndProcessAccordingToResult(
  316. selectedPermanent,
  317. activateClass,
  318. true,
  319. SuccessProcess));
  320. IEnumerator SuccessProcess(CardSource cardSource)
  321. {
  322. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsCardLucemonChaosModeCondition))
  323. {
  324. yield return ContinuousController.instance.StartCoroutine(
  325. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  326. targetPermanent: card.PermanentOfThisCard(),
  327. cardCondition: IsCardLucemonChaosModeCondition,
  328. payCost: false,
  329. reduceCostTuple: null,
  330. fixedCostTuple: null,
  331. ignoreDigivolutionRequirementFixedCost: -1,
  332. isHand: false,
  333. activateClass: activateClass,
  334. successProcess: null));
  335. }
  336. yield return null;
  337. }
  338. }
  339. }
  340. }
  341. }
  342. }
  343. }
  344. #endregion
  345. return cardEffects;
  346. }
  347. }
  348. }