EX10_048.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Myotismon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_048 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region When Would be Played
  14. if (timing == EffectTiming.BeforePayCost)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Delete 1 of your Myotis-in-text Digimon to get Play Cost -4", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  19. activateClass.SetIsDigimonEffect(true);
  20. cardEffects.Add(activateClass);
  21. string EffectDescription()
  22. {
  23. return "When this card would be played, by deleting 1 of your Digimon with [Myotismon] in its text, reduce the play cost by 4.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  28. }
  29. bool CardCondition(CardSource cardSource)
  30. {
  31. return cardSource == card && CardEffectCommons.IsExistOnHand(cardSource);
  32. }
  33. bool CanSelectPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  36. !permanent.TopCard.CanNotBeAffected(activateClass) &&
  37. permanent.TopCard.HasText("Myotismon");
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  42. }
  43. IEnumerator ActivateCoroutine(Hashtable hashtable)
  44. {
  45. // First, select a valid Digimon
  46. bool canNoSelect = true;
  47. CardSource cardFromHashtable = CardEffectCommons.GetCardFromHashtable(hashtable);
  48. if (cardFromHashtable && cardFromHashtable.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) >
  49. cardFromHashtable.Owner.MaxMemoryCost)
  50. {
  51. canNoSelect = false;
  52. }
  53. Permanent selectedPermanent = null;
  54. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  55. selectPermanentEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: CanSelectPermanentCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: 1,
  61. canNoSelect: canNoSelect,
  62. canEndNotMax: false,
  63. selectPermanentCoroutine: SelectPermanentCoroutine,
  64. afterSelectPermanentCoroutine: null,
  65. mode: SelectPermanentEffect.Mode.Custom,
  66. cardEffect: activateClass);
  67. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  68. "The opponent is selecting 1 Digimon to delete.");
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  71. {
  72. selectedPermanent = permanent;
  73. yield return null;
  74. }
  75. // If the player selected a Digimon, continue with the rest of the effect
  76. if (selectedPermanent != null)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  79. targetPermanents: new List<Permanent>() { selectedPermanent },
  80. activateClass: activateClass,
  81. successProcess: SuccessProcess,
  82. failureProcess: null
  83. ));
  84. IEnumerator SuccessProcess(List<Permanent> permanents)
  85. {
  86. #region Setup Reduce Cost Effect
  87. bool CanUseCondition1(Hashtable hashtable1)
  88. {
  89. return true;
  90. }
  91. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  92. List<Permanent> targetPermanents)
  93. {
  94. if (CardSourceCondition(cardSource) &&
  95. RootCondition(root) &&
  96. PermanentsCondition(targetPermanents))
  97. {
  98. cost -= 4;
  99. }
  100. return cost;
  101. }
  102. bool PermanentsCondition(List<Permanent> targetPermanents)
  103. {
  104. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  105. }
  106. bool CardSourceCondition(CardSource cardSource)
  107. {
  108. return cardSource == card;
  109. }
  110. bool RootCondition(SelectCardEffect.Root root)
  111. {
  112. return true;
  113. }
  114. bool IsUpDown()
  115. {
  116. return true;
  117. }
  118. #endregion
  119. if (card.Owner.CanReduceCost(null, card))
  120. {
  121. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  122. ChangeCostClass changeCostClass = new ChangeCostClass();
  123. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  124. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  125. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => false,
  126. isChangePayingCost: () => true);
  127. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  128. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  129. }
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. #region Reduce Play Cost - Not Shown
  136. if (timing == EffectTiming.None)
  137. {
  138. ChangeCostClass changeCostClass = new ChangeCostClass();
  139. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  140. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  141. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => true,
  142. isChangePayingCost: () => true);
  143. changeCostClass.SetNotShowUI(true);
  144. cardEffects.Add(changeCostClass);
  145. bool CanUseCondition1(Hashtable hashtable1)
  146. {
  147. return CardEffectCommons.MatchConditionPermanentCount(PermanentCondition) >= 1;
  148. }
  149. bool PermanentCondition(Permanent permanent)
  150. {
  151. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  152. !permanent.IsSuspended && permanent.CanSuspend &&
  153. permanent.TopCard.HasWGTraits;
  154. }
  155. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  156. List<Permanent> targetPermanents)
  157. {
  158. if (CardSourceCondition(cardSource) &&
  159. RootCondition(root) &&
  160. PermanentsCondition(targetPermanents))
  161. {
  162. cost -= 4;
  163. }
  164. return cost;
  165. }
  166. bool PermanentsCondition(List<Permanent> targetPermanents)
  167. {
  168. return targetPermanents == null ||
  169. targetPermanents.Count(targetPermanent => CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(targetPermanent) &&
  170. targetPermanent != null &&
  171. targetPermanent.TopCard &&
  172. !targetPermanent.TopCard.CanNotBeAffected(changeCostClass) &&
  173. !targetPermanent.IsSuspended && targetPermanent.CanSuspend &&
  174. targetPermanent.TopCard.HasText("Myotismon")) <= 1;
  175. }
  176. bool CardSourceCondition(CardSource cardSource)
  177. {
  178. return cardSource == card;
  179. }
  180. bool RootCondition(SelectCardEffect.Root root)
  181. {
  182. return true;
  183. }
  184. bool IsUpDown()
  185. {
  186. return true;
  187. }
  188. }
  189. #endregion
  190. #region On Play/On Deletion Shared
  191. bool CanSelectPurplePermanentCondition(Permanent permanent)
  192. {
  193. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  194. && permanent.TopCard.CardColors.Contains(CardColor.Purple);
  195. }
  196. #endregion
  197. #region On Play
  198. if (timing == EffectTiming.OnEnterFieldAnyone)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("Your 1 Digimon gains Retaliation and Blocker", CanUseCondition, card);
  202. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  203. cardEffects.Add(activateClass);
  204. string EffectDiscription()
  205. {
  206. return "[On Play] 1 of your purple Digimon gains <Blocker> and <Retaliation> until your opponent's turn ends.";
  207. }
  208. bool CanUseCondition(Hashtable hashtable)
  209. {
  210. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  211. }
  212. bool CanActivateCondition(Hashtable hashtable)
  213. {
  214. if (CardEffectCommons.IsExistOnBattleArea(card))
  215. {
  216. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPurplePermanentCondition))
  217. {
  218. return true;
  219. }
  220. }
  221. return false;
  222. }
  223. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  224. {
  225. if (CardEffectCommons.IsExistOnBattleArea(card))
  226. {
  227. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPurplePermanentCondition))
  228. {
  229. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPurplePermanentCondition));
  230. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  231. selectPermanentEffect.SetUp(
  232. selectPlayer: card.Owner,
  233. canTargetCondition: CanSelectPurplePermanentCondition,
  234. canTargetCondition_ByPreSelecetedList: null,
  235. canEndSelectCondition: null,
  236. maxCount: maxCount,
  237. canNoSelect: false,
  238. canEndNotMax: false,
  239. selectPermanentCoroutine: SelectPermanentCoroutine,
  240. afterSelectPermanentCoroutine: null,
  241. mode: SelectPermanentEffect.Mode.Custom,
  242. cardEffect: activateClass);
  243. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Blocker and Retaliation.", "The opponent is selecting 1 Digimon that will get Blocker and Retaliation.");
  244. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  245. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  246. {
  247. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  248. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRetaliation(targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  249. }
  250. }
  251. }
  252. }
  253. }
  254. #endregion
  255. #region On Deletion
  256. if (timing == EffectTiming.OnDestroyedAnyone)
  257. {
  258. ActivateClass activateClass = new ActivateClass();
  259. activateClass.SetUpICardEffect("Your 1 Digimon gains Retaliation and Blocker", CanUseCondition, card);
  260. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  261. cardEffects.Add(activateClass);
  262. string EffectDiscription()
  263. {
  264. return "[On Deletion] 1 of your purple Digimon gains <Blocker> and <Retaliation> until your opponent's turn ends.";
  265. }
  266. bool CanUseCondition(Hashtable hashtable)
  267. {
  268. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  269. }
  270. bool CanActivateCondition(Hashtable hashtable)
  271. {
  272. if (CardEffectCommons.CanActivateOnDeletion(card))
  273. {
  274. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPurplePermanentCondition))
  275. {
  276. return true;
  277. }
  278. }
  279. return false;
  280. }
  281. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  282. {
  283. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPurplePermanentCondition))
  284. {
  285. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPurplePermanentCondition));
  286. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  287. selectPermanentEffect.SetUp(
  288. selectPlayer: card.Owner,
  289. canTargetCondition: CanSelectPurplePermanentCondition,
  290. canTargetCondition_ByPreSelecetedList: null,
  291. canEndSelectCondition: null,
  292. maxCount: maxCount,
  293. canNoSelect: false,
  294. canEndNotMax: false,
  295. selectPermanentCoroutine: SelectPermanentCoroutine,
  296. afterSelectPermanentCoroutine: null,
  297. mode: SelectPermanentEffect.Mode.Custom,
  298. cardEffect: activateClass);
  299. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Blocker and Retaliation.", "The opponent is selecting 1 Digimon that will get Blocker and Retaliation.");
  300. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  301. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  302. {
  303. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  304. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRetaliation(targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  305. }
  306. }
  307. }
  308. }
  309. #endregion
  310. #region ESS - On Deletion
  311. if (timing == EffectTiming.OnDestroyedAnyone)
  312. {
  313. ActivateClass activateClass = new ActivateClass();
  314. activateClass.SetUpICardEffect("Play 1 purple Tamer from trash suspended", CanUseCondition, card);
  315. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  316. activateClass.SetIsInheritedEffect(true);
  317. cardEffects.Add(activateClass);
  318. string EffectDiscription()
  319. {
  320. return "[On Deletion] You may play 1 purple Tamer card from your trash suspended without paying the cost.";
  321. }
  322. bool CanSelectCardCondition(CardSource cardSource)
  323. {
  324. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  325. {
  326. if (cardSource.CardColors.Contains(CardColor.Purple))
  327. {
  328. if (cardSource.IsTamer)
  329. {
  330. return true;
  331. }
  332. }
  333. }
  334. return false;
  335. }
  336. bool CanUseCondition(Hashtable hashtable)
  337. {
  338. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  339. }
  340. bool CanActivateCondition(Hashtable hashtable)
  341. {
  342. if (CardEffectCommons.CanActivateOnDeletion(card))
  343. {
  344. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  345. {
  346. return true;
  347. }
  348. }
  349. return false;
  350. }
  351. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  352. {
  353. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  354. {
  355. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  356. List<CardSource> selectedCards = new List<CardSource>();
  357. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  358. selectCardEffect.SetUp(
  359. canTargetCondition: CanSelectCardCondition,
  360. canTargetCondition_ByPreSelecetedList: null,
  361. canEndSelectCondition: null,
  362. canNoSelect: () => true,
  363. selectCardCoroutine: SelectCardCoroutine,
  364. afterSelectCardCoroutine: null,
  365. message: "Select 1 card to play.",
  366. maxCount: maxCount,
  367. canEndNotMax: false,
  368. isShowOpponent: true,
  369. mode: SelectCardEffect.Mode.Custom,
  370. root: SelectCardEffect.Root.Trash,
  371. customRootCardList: null,
  372. canLookReverseCard: true,
  373. selectPlayer: card.Owner,
  374. cardEffect: activateClass);
  375. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  376. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  377. yield return StartCoroutine(selectCardEffect.Activate());
  378. IEnumerator SelectCardCoroutine(CardSource cardSource)
  379. {
  380. selectedCards.Add(cardSource);
  381. yield return null;
  382. }
  383. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  384. cardSources: selectedCards,
  385. activateClass: activateClass,
  386. payCost: false,
  387. isTapped: true,
  388. root: SelectCardEffect.Root.Trash,
  389. activateETB: true));
  390. }
  391. }
  392. }
  393. #endregion
  394. return cardEffects;
  395. }
  396. }
  397. }