EX10_054.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. // VenomMyotismon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_054 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Trash - Main
  14. if (timing == EffectTiming.OnDeclaration)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Play for reduced cost of 7", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  19. activateClass.SetIsDigimonEffect(true);
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[Trash] [Main] By deleting 1 of your level 5 Digimon with [Myotismon] in its text, play this card with the play cost reduced by 7.";
  24. }
  25. bool IsLvl5Myotismon(Permanent targetPermanent)
  26. {
  27. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card) &&
  28. targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5 &&
  29. targetPermanent.TopCard.HasText("Myotismon");
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnTrash(card) &&
  34. CardEffectCommons.MatchConditionPermanentCount(IsLvl5Myotismon) >= 1;
  35. }
  36. IEnumerator ActivateCoroutine(Hashtable hashtable)
  37. {
  38. Permanent targetPermament = null;
  39. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLvl5Myotismon));
  40. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  41. selectPermanentEffect.SetUp(
  42. selectPlayer: card.Owner,
  43. canTargetCondition: IsLvl5Myotismon,
  44. canTargetCondition_ByPreSelecetedList: null,
  45. canEndSelectCondition: null,
  46. maxCount: maxCount,
  47. canNoSelect: false,
  48. canEndNotMax: false,
  49. selectPermanentCoroutine: SelectPermanentCoroutine,
  50. afterSelectPermanentCoroutine: null,
  51. mode: SelectPermanentEffect.Mode.Custom,
  52. cardEffect: activateClass);
  53. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  54. {
  55. targetPermament = permanent;
  56. yield return null;
  57. }
  58. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  59. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  60. if (targetPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  61. targetPermanents: new List<Permanent>() { targetPermament },
  62. activateClass: activateClass,
  63. successProcess: SuccessProcess,
  64. failureProcess: null));
  65. IEnumerator SuccessProcess(List<Permanent> permanents)
  66. {
  67. #region reduce play cost
  68. ChangeCostClass changeCostClass = new ChangeCostClass();
  69. changeCostClass.SetUpICardEffect("Play Cost -7", CanUseCondition1, card);
  70. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  71. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  72. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  73. ICardEffect GetCardEffect(EffectTiming _timing)
  74. {
  75. if (_timing == EffectTiming.None)
  76. {
  77. return changeCostClass;
  78. }
  79. return null;
  80. }
  81. bool CanUseCondition1(Hashtable hashtable)
  82. {
  83. return true;
  84. }
  85. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  86. {
  87. if (CardSourceCondition(cardSource))
  88. {
  89. if (RootCondition(root))
  90. {
  91. if (PermanentsCondition(targetPermanents))
  92. {
  93. Cost -= 7;
  94. }
  95. }
  96. }
  97. return Cost;
  98. }
  99. bool PermanentsCondition(List<Permanent> targetPermanents)
  100. {
  101. if (targetPermanents == null)
  102. {
  103. return true;
  104. }
  105. else
  106. {
  107. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  108. {
  109. return true;
  110. }
  111. }
  112. return false;
  113. }
  114. bool CardSourceCondition(CardSource cardSource)
  115. {
  116. if (cardSource != null)
  117. {
  118. if (cardSource.Owner == card.Owner)
  119. {
  120. if (cardSource == card)
  121. {
  122. return true;
  123. }
  124. }
  125. }
  126. return false;
  127. }
  128. bool RootCondition(SelectCardEffect.Root root)
  129. {
  130. return true;
  131. }
  132. bool isUpDown()
  133. {
  134. return true;
  135. }
  136. #endregion
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  138. cardSources: new List<CardSource> { card },
  139. activateClass: activateClass,
  140. payCost: true,
  141. isTapped: false,
  142. root: SelectCardEffect.Root.Trash,
  143. activateETB: true));
  144. #region release reducing play cost
  145. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  146. #endregion
  147. }
  148. }
  149. }
  150. #endregion
  151. #region On Play/When Digivolving Shared
  152. const string OnPlayWhenDigiEffectDescription = "You may suspend 2 of your opponent's Digimon or Tamers. Then, 2 of their Digimon or Tamers can't unsuspend until their turn ends.";
  153. bool CanSelectPermanentConditionShared(Permanent permanent)
  154. {
  155. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  156. || CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaTamer(permanent, card);
  157. }
  158. bool CanActivateConditionShared(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  161. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared);
  162. }
  163. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  164. {
  165. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared))
  166. {
  167. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionShared));
  168. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  169. selectPermanentEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: CanSelectPermanentConditionShared,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: maxCount,
  175. canNoSelect: true,
  176. canEndNotMax: true,
  177. selectPermanentCoroutine: null,
  178. afterSelectPermanentCoroutine: null,
  179. mode: SelectPermanentEffect.Mode.Tap,
  180. cardEffect: activateClass);
  181. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  182. selectPermanentEffect.SetUp(
  183. selectPlayer: card.Owner,
  184. canTargetCondition: CanSelectPermanentConditionShared,
  185. canTargetCondition_ByPreSelecetedList: null,
  186. canEndSelectCondition: null,
  187. maxCount: maxCount,
  188. canNoSelect: false,
  189. canEndNotMax: true,
  190. selectPermanentCoroutine: SelectPermanentCoroutine,
  191. afterSelectPermanentCoroutine: null,
  192. mode: SelectPermanentEffect.Mode.Custom,
  193. cardEffect: activateClass);
  194. selectPermanentEffect.SetUpCustomMessage(
  195. "Select 2 Digimon or Tamers that will be unable to unsuspend.",
  196. "The opponent is selecting 2 Digimon or Tamers that will be unable to unsuspend.");
  197. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  198. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  199. {
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendUntilOpponentTurnEnd(
  201. targetPermanent: permanent,
  202. activateClass: activateClass
  203. ));
  204. }
  205. }
  206. }
  207. #endregion
  208. #region On Play
  209. if (timing == EffectTiming.OnEnterFieldAnyone)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect("Suspend 2 opponent Digimon or Tamers", CanUseCondition, card);
  213. activateClass.SetUpActivateClass(CanActivateConditionShared, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDescription());
  214. cardEffects.Add(activateClass);
  215. string EffectDescription()
  216. {
  217. return
  218. "[On Play] " + OnPlayWhenDigiEffectDescription;
  219. }
  220. bool CanUseCondition(Hashtable hashtable)
  221. {
  222. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  223. }
  224. }
  225. #endregion
  226. #region When Digivolving
  227. if (timing == EffectTiming.OnEnterFieldAnyone)
  228. {
  229. ActivateClass activateClass = new ActivateClass();
  230. activateClass.SetUpICardEffect("Suspend 2 opponent Digimon or Tamers", CanUseCondition, card);
  231. activateClass.SetUpActivateClass(CanActivateConditionShared, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDescription());
  232. cardEffects.Add(activateClass);
  233. string EffectDescription()
  234. {
  235. return
  236. "[When Digivolving] " + OnPlayWhenDigiEffectDescription;
  237. }
  238. bool CanUseCondition(Hashtable hashtable)
  239. {
  240. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  241. }
  242. }
  243. #endregion
  244. #region On Deletion
  245. if (timing == EffectTiming.OnDestroyedAnyone)
  246. {
  247. ActivateClass activateClass = new ActivateClass();
  248. activateClass.SetUpICardEffect("Delete 1 suspended Digimon", CanUseCondition, card);
  249. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  250. cardEffects.Add(activateClass);
  251. string EffectDiscription()
  252. {
  253. return "[On Deletion] Delete 1 of your opponent's suspended Digimon.";
  254. }
  255. bool CanSelectPermanentCondition(Permanent permanent)
  256. {
  257. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  258. {
  259. if (permanent.IsSuspended)
  260. {
  261. return true;
  262. }
  263. }
  264. return false;
  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(CanSelectPermanentCondition))
  275. {
  276. return true;
  277. }
  278. }
  279. return false;
  280. }
  281. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  282. {
  283. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  284. {
  285. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  286. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  287. selectPermanentEffect.SetUp(
  288. selectPlayer: card.Owner,
  289. canTargetCondition: CanSelectPermanentCondition,
  290. canTargetCondition_ByPreSelecetedList: null,
  291. canEndSelectCondition: null,
  292. maxCount: maxCount,
  293. canNoSelect: false,
  294. canEndNotMax: false,
  295. selectPermanentCoroutine: null,
  296. afterSelectPermanentCoroutine: null,
  297. mode: SelectPermanentEffect.Mode.Destroy,
  298. cardEffect: activateClass);
  299. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  300. }
  301. }
  302. }
  303. #endregion
  304. return cardEffects;
  305. }
  306. }
  307. }