EX12_064.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Megadramon
  5. namespace DCGO.CardEffects.EX12
  6. {
  7. public class EX12_064 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsTraits("Machine")
  18. || targetPermanent.TopCard.EqualsTraits("ME");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null,
  26. level: 4)
  27. );
  28. }
  29. #endregion
  30. #region Shared OP/WD
  31. string SharedEffectName = "Delete 1 enemy lvl 4 or lower Digimon, if fail, <De-Digivolve 1> 1 of enemy Digimon";
  32. CardEffectFactory.ActivateClassesForSharedEffects
  33. (ref cardEffects, timing, card,
  34. SharedEffectName,
  35. SharedActivateCoroutine,
  36. SharedEffectDescription,
  37. optional: false,
  38. onPlay: true,
  39. whenDigivolving: true);
  40. string SharedEffectDescription(string tag)
  41. {
  42. return $"[{tag}] Delete 1 of your opponent's level 4 or lower Digimon. If this effect didn't delete, <De-Digivolve 1> 1 of your opponent's Digimon.";
  43. }
  44. bool CanSelectPermanentCondition1(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  47. && permanent.TopCard.HasLevel
  48. && permanent.Level <= 4;
  49. }
  50. bool CanSelectPermanentCondition2(Permanent permanent)
  51. {
  52. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  53. }
  54. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  55. {
  56. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  57. bool failedToDelete = true;
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  59. {
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: CanSelectPermanentCondition1,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: 1,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: null,
  70. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  74. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  75. {
  76. deleteTargetPermanents = permanents.Clone();
  77. yield return null;
  78. }
  79. }
  80. if (deleteTargetPermanents.Count > 0)
  81. {
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: SuccessDeleteProcess, failureProcess: null));
  83. IEnumerator SuccessDeleteProcess(List<Permanent> permanents)
  84. {
  85. if (permanents.Count > 0)
  86. failedToDelete = false;
  87. yield return null;
  88. }
  89. }
  90. if (failedToDelete
  91. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition2))
  92. {
  93. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  94. selectPermanentEffect.SetUp(
  95. selectPlayer: card.Owner,
  96. canTargetCondition: CanSelectPermanentCondition2,
  97. canTargetCondition_ByPreSelecetedList: null,
  98. canEndSelectCondition: null,
  99. maxCount: 1,
  100. canNoSelect: false,
  101. canEndNotMax: false,
  102. selectPermanentCoroutine: null,
  103. afterSelectPermanentCoroutine: null,
  104. mode: SelectPermanentEffect.Mode.Degenerate,
  105. cardEffect: activateClass);
  106. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
  107. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  108. }
  109. }
  110. #endregion
  111. #region All Turns
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("May activate 1 of this Digimon's [When Digivolving] effects", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  117. activateClass.SetHashString("EX12_064_AT");
  118. cardEffects.Add(activateClass);
  119. string EffectDescription()
  120. {
  121. return "[All Turns] [Once Per Turn] When any of your [Machine], [Cyborg] or [ME] trait Digimon are played, you may activate 1 of this Digimon's [When Digivolving] effects.";
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  126. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PlayedPermanentCondition);
  127. }
  128. bool CanActivateCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  131. && card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone).Any(CanBeEffectCandidate);
  132. }
  133. bool PlayedPermanentCondition(Permanent permanent)
  134. {
  135. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  136. && (permanent.TopCard.EqualsTraits("Machine")
  137. || permanent.TopCard.EqualsTraits("Cyborg")
  138. || permanent.TopCard.EqualsTraits("ME"));
  139. }
  140. bool CanBeEffectCandidate(ICardEffect cardEffect)
  141. {
  142. if (cardEffect != null
  143. && cardEffect is ActivateICardEffect
  144. && !cardEffect.IsSecurityEffect
  145. && cardEffect.IsWhenDigivolving)
  146. {
  147. Hashtable digivolvingHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(cardEffect.EffectSourceCard);
  148. return cardEffect.CanUse(digivolvingHashtable);
  149. }
  150. return false;
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable hashtable)
  153. {
  154. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone).Clone().Filter(CanBeEffectCandidate);
  155. if (candidateEffects.Count >= 1)
  156. {
  157. ICardEffect selectedEffect = null;
  158. if (candidateEffects.Count == 1)
  159. {
  160. selectedEffect = candidateEffects[0];
  161. }
  162. else
  163. {
  164. List<SkillInfo> skillInfos = candidateEffects
  165. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  166. List<CardSource> cardSources = candidateEffects
  167. .Map(cardEffect => cardEffect.EffectSourceCard);
  168. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  169. selectCardEffect.SetUp(
  170. canTargetCondition: (cardSource) => true,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. canNoSelect: () => false,
  174. selectCardCoroutine: null,
  175. afterSelectCardCoroutine: null,
  176. message: "Select 1 effect to activate.",
  177. maxCount: 1,
  178. canEndNotMax: false,
  179. isShowOpponent: false,
  180. mode: SelectCardEffect.Mode.Custom,
  181. root: SelectCardEffect.Root.Custom,
  182. customRootCardList: cardSources,
  183. canLookReverseCard: true,
  184. selectPlayer: card.Owner,
  185. cardEffect: activateClass);
  186. selectCardEffect.SetNotShowCard();
  187. selectCardEffect.SetUpSkillInfos(skillInfos);
  188. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  189. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  190. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  191. {
  192. if (selectedIndexes.Count == 1)
  193. {
  194. selectedEffect = candidateEffects[selectedIndexes[0]];
  195. yield return null;
  196. }
  197. }
  198. }
  199. if (selectedEffect != null
  200. && selectedEffect.EffectSourceCard != null
  201. && selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  202. {
  203. selectedEffect.SetIsDigimonEffect(true);
  204. Hashtable digivolvingHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  205. if (selectedEffect.CanUse(digivolvingHashtable))
  206. {
  207. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(digivolvingHashtable));
  208. }
  209. }
  210. }
  211. }
  212. }
  213. #endregion
  214. #region Assembly
  215. if (timing == EffectTiming.None)
  216. {
  217. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  218. addAssemblyConditionClass.SetUpICardEffect("Assembly", CanUseCondition, card);
  219. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  220. addAssemblyConditionClass.SetNotShowUI(true);
  221. cardEffects.Add(addAssemblyConditionClass);
  222. bool CanUseCondition(Hashtable hashtable)
  223. {
  224. return true;
  225. }
  226. AssemblyCondition GetAssembly(CardSource cardSource)
  227. {
  228. if (cardSource == card)
  229. {
  230. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition);
  231. bool CanSelectCardCondition(CardSource cardSource)
  232. {
  233. return cardSource.HasLevel
  234. && cardSource.Level <= 4
  235. && (cardSource.EqualsTraits("Machine")
  236. || cardSource.EqualsTraits("Cyborg")
  237. || cardSource.EqualsTraits("Me"));
  238. }
  239. AssemblyCondition assemblyCondition = new AssemblyCondition(
  240. element: element,
  241. CanTargetCondition_ByPreSelecetedList: null,
  242. selectMessage: "Lv.4 or lower [Machine]/[Cyborg]/[Me] trait card",
  243. elementCount: 1,
  244. reduceCost: 2);
  245. return assemblyCondition;
  246. }
  247. return null;
  248. }
  249. }
  250. #endregion
  251. #region Inherited
  252. if (timing == EffectTiming.OnEndAttack)
  253. {
  254. ActivateClass activateClass = new ActivateClass();
  255. activateClass.SetUpICardEffect("Unsuspend this Digimon to delete own lowest play cost digimon", CanUseCondition, card);
  256. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  257. activateClass.SetHashString("EX12_064_Inherited");
  258. activateClass.SetIsInheritedEffect(true);
  259. cardEffects.Add(activateClass);
  260. string EffectDescription()
  261. {
  262. return "[End of Attack] [Once Per Turn] By unsuspending this Digimon, delete 1 of your Digimon with the lowest play cost.";
  263. }
  264. bool CanUseCondition(Hashtable hashtable)
  265. {
  266. return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
  267. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  268. }
  269. bool CanActivateCondition(Hashtable hashtable)
  270. {
  271. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass);
  272. }
  273. bool CanSelectPermanentCondition(Permanent permanent)
  274. {
  275. return CardEffectCommons.IsMinCost(permanent, card.Owner, true);
  276. }
  277. IEnumerator ActivateCoroutine(Hashtable hashtable)
  278. {
  279. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  280. if (!card.PermanentOfThisCard().IsSuspended)
  281. {
  282. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  283. selectPermanentEffect.SetUp(
  284. selectPlayer: card.Owner,
  285. canTargetCondition: CanSelectPermanentCondition,
  286. canTargetCondition_ByPreSelecetedList: null,
  287. canEndSelectCondition: null,
  288. maxCount: 1,
  289. canNoSelect: false,
  290. canEndNotMax: false,
  291. selectPermanentCoroutine: null,
  292. afterSelectPermanentCoroutine: null,
  293. mode: SelectPermanentEffect.Mode.Destroy,
  294. cardEffect: activateClass);
  295. selectPermanentEffect.SetUpCustomMessage("Select a digimon to delete.", "The opponent is selecting a digimon to delete.");
  296. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  297. }
  298. }
  299. }
  300. #endregion
  301. return cardEffects;
  302. }
  303. }
  304. }