EX10_011.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_011 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.ContainsCardName("Myotismon") &&
  18. targetPermanent.TopCard.IsLevel5;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Trash - Main
  24. if (timing == EffectTiming.OnDeclaration)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Play for reduced cost of 11", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  29. activateClass.SetIsDigimonEffect(true);
  30. cardEffects.Add(activateClass);
  31. string EffectDiscription()
  32. {
  33. return "[Trash] [Main] By deleting 2 of your level 5 or higher Digimon with [Myotismon] in their texts, play this card with the play cost reduced by 11.";
  34. }
  35. bool IsLvl5Myotismon(Permanent targetPermanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card) &&
  38. targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level >= 5 &&
  39. targetPermanent.TopCard.HasText("Myotismon");
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnTrash(card) &&
  44. CardEffectCommons.MatchConditionPermanentCount(IsLvl5Myotismon) >= 2 &&
  45. CardEffectCommons.CanPlayAsNewPermanent(cardSource: card, payCost: false, cardEffect: activateClass);
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(IsLvl5Myotismon));
  50. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  51. selectPermanentEffect.SetUp(
  52. selectPlayer: card.Owner,
  53. canTargetCondition: IsLvl5Myotismon,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canEndSelectCondition: null,
  56. maxCount: maxCount,
  57. canNoSelect: false,
  58. canEndNotMax: false,
  59. selectPermanentCoroutine: null,
  60. afterSelectPermanentCoroutine: AfterSelectDigimon,
  61. mode: SelectPermanentEffect.Mode.Custom,
  62. cardEffect: activateClass);
  63. selectPermanentEffect.SetUpCustomMessage("Select 2 Digimon to delete.", "The opponent is selecting 2 Digimon to delete.");
  64. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  65. IEnumerator AfterSelectDigimon(List<Permanent> permanents)
  66. {
  67. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  68. targetPermanents: permanents, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  69. }
  70. IEnumerator SuccessProcess()
  71. {
  72. #region reduce play cost
  73. if (card.Owner.CanReduceCost(null, card))
  74. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  75. ChangeCostClass changeCostClass = new ChangeCostClass();
  76. changeCostClass.SetUpICardEffect($"Play Cost -11", CanUseCondition1, card);
  77. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  78. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  79. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  80. bool CanUseCondition1(Hashtable hashtable)
  81. {
  82. return true;
  83. }
  84. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  85. {
  86. if (CardSourceCondition(cardSource))
  87. {
  88. if (RootCondition(root))
  89. {
  90. if (PermanentsCondition(targetPermanents))
  91. {
  92. Cost -= 11;
  93. }
  94. }
  95. }
  96. return Cost;
  97. }
  98. bool PermanentsCondition(List<Permanent> targetPermanents)
  99. {
  100. if (targetPermanents == null)
  101. {
  102. return true;
  103. }
  104. else
  105. {
  106. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. bool CardSourceCondition(CardSource cardSource)
  114. {
  115. return true;
  116. }
  117. bool RootCondition(SelectCardEffect.Root root)
  118. {
  119. return true;
  120. }
  121. bool isUpDown()
  122. {
  123. return true;
  124. }
  125. #endregion
  126. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  127. cardSources: new List<CardSource> { card },
  128. activateClass: activateClass,
  129. payCost: true,
  130. isTapped: false,
  131. root: SelectCardEffect.Root.Trash,
  132. activateETB: true));
  133. }
  134. }
  135. }
  136. #endregion
  137. #region On Play/When Digivolving/When Attacking Shared
  138. bool CanSelectPermanentCondition(Permanent permanent)
  139. {
  140. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  141. permanent != card.PermanentOfThisCard() &&
  142. !permanent.IsSuspended;
  143. }
  144. bool CanActivateSharedCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleArea(card);
  147. }
  148. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  149. {
  150. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  151. {
  152. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  153. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  154. selectPermanentEffect.SetUp(
  155. selectPlayer: card.Owner,
  156. canTargetCondition: CanSelectPermanentCondition,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. maxCount: maxCount,
  160. canNoSelect: false,
  161. canEndNotMax: false,
  162. selectPermanentCoroutine: null,
  163. afterSelectPermanentCoroutine: null,
  164. mode: SelectPermanentEffect.Mode.Destroy,
  165. cardEffect: activateClass);
  166. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  167. }
  168. }
  169. #endregion
  170. #region On Play
  171. if (timing == EffectTiming.OnEnterFieldAnyone)
  172. {
  173. ActivateClass activateClass = new ActivateClass();
  174. activateClass.SetUpICardEffect("Delete 2 unsuspended Digimon", CanUseCondition, card);
  175. activateClass.SetUpActivateClass(CanActivateSharedCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), 1, false, EffectDescription());
  176. activateClass.SetHashString("Delete2_EX10-011");
  177. cardEffects.Add(activateClass);
  178. string EffectDescription()
  179. {
  180. return "[On Play] [Once Per Turn] Delete 2 other unsuspended Digimon.";
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  185. }
  186. }
  187. #endregion
  188. #region When Digivolving
  189. if (timing == EffectTiming.OnEnterFieldAnyone)
  190. {
  191. ActivateClass activateClass = new ActivateClass();
  192. activateClass.SetUpICardEffect("Delete 2 unsuspended Digimon", CanUseCondition, card);
  193. activateClass.SetUpActivateClass(CanActivateSharedCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), 1, false, EffectDescription());
  194. activateClass.SetHashString("Delete2_EX10-011");
  195. cardEffects.Add(activateClass);
  196. string EffectDescription()
  197. {
  198. return "[When Digivolving] [Once Per Turn] Delete 2 other unsuspended Digimon.";
  199. }
  200. bool CanUseCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  203. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  204. }
  205. }
  206. #endregion
  207. #region When Attacking
  208. if (timing == EffectTiming.OnAllyAttack)
  209. {
  210. ActivateClass activateClass = new ActivateClass();
  211. activateClass.SetUpICardEffect("Delete 2 unsuspended Digimon", CanUseCondition, card);
  212. activateClass.SetUpActivateClass(CanActivateSharedCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), 1, false, EffectDescription());
  213. activateClass.SetHashString("Delete2_EX10-011");
  214. cardEffects.Add(activateClass);
  215. string EffectDescription()
  216. {
  217. return "[When Attacking] [Once Per Turn] Delete 2 other unsuspended Digimon.";
  218. }
  219. bool CanUseCondition(Hashtable hashtable)
  220. {
  221. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  222. }
  223. }
  224. #endregion
  225. #region All Turns
  226. if (timing == EffectTiming.OnDestroyedAnyone)
  227. {
  228. ActivateClass activateClass = new ActivateClass();
  229. activateClass.SetUpICardEffect("Trash security, then return 1 to bottom deck", CanUseCondition, card);
  230. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  231. activateClass.SetHashString("AllTurns_EX10-001");
  232. cardEffects.Add(activateClass);
  233. string EffectDiscription()
  234. {
  235. return "[All Turns] [Once Per Turn] When any of your other Digimon or Tamers are deleted, trash your opponent's top security card and return 1 of their Digimon with the lowest DP to the bottom of the deck.";
  236. }
  237. bool YourOtherPermanent(Permanent permanent)
  238. {
  239. return CardEffectCommons.IsOwnerPermanent(permanent, card) &&
  240. (permanent.IsDigimon || permanent.IsTamer);
  241. }
  242. bool OpponentsLowestDP(Permanent permanent)
  243. {
  244. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  245. CardEffectCommons.IsMinDP(permanent, permanent.TopCard.Owner);
  246. }
  247. bool CanUseCondition(Hashtable hashtable)
  248. {
  249. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  250. CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, YourOtherPermanent, activateClass);
  251. }
  252. bool CanActivateCondition(Hashtable hashtable)
  253. {
  254. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  255. }
  256. IEnumerator ActivateCoroutine(Hashtable hashtable)
  257. {
  258. if(card.Owner.Enemy.SecurityCards.Count > 0)
  259. {
  260. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  261. player: card.Owner.Enemy,
  262. destroySecurityCount: 1,
  263. cardEffect: activateClass,
  264. fromTop: true).DestroySecurity());
  265. }
  266. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsLowestDP))
  267. {
  268. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  269. selectPermanentEffect1.SetUp(
  270. selectPlayer: card.Owner,
  271. canTargetCondition: OpponentsLowestDP,
  272. canTargetCondition_ByPreSelecetedList: null,
  273. canEndSelectCondition: null,
  274. maxCount: 1,
  275. canNoSelect: false,
  276. canEndNotMax: false,
  277. selectPermanentCoroutine: null,
  278. afterSelectPermanentCoroutine: null,
  279. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  280. cardEffect: activateClass);
  281. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  282. }
  283. }
  284. }
  285. #endregion
  286. return cardEffects;
  287. }
  288. }
  289. }