EX11_045.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Metatromon
  4. namespace DCGO.CardEffects.EX11
  5. {
  6. public class EX11_045 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alt Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.HasText("Maquinamon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region Blocker
  22. if (timing == EffectTiming.None)
  23. {
  24. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  25. }
  26. #endregion
  27. #region Shared OP / WD /WA
  28. string SharedHashString = "EX11_045_OP_WD_WA";
  29. string SharedEffectName = "<De-Digivolve> 2 1 Opponent's Digimon. 1 Opponent's Digimon or Tamer can't digivolve.";
  30. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] <De-Digivolve 2> 1 of your opponent's Digimon. Then, 1 of their Digimon or Tamers can't digivolve until their turn ends.";
  31. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  32. bool OpponentsDigimonCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  33. bool CannotUnsuspendValidTargets(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  36. && (permanent.IsDigimon || permanent.IsTamer);
  37. }
  38. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  39. {
  40. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, OpponentsDigimonCondition))
  41. {
  42. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  43. selectPermanentEffect.SetUp(
  44. selectPlayer: card.Owner,
  45. canTargetCondition: OpponentsDigimonCondition,
  46. canTargetCondition_ByPreSelecetedList: null,
  47. canEndSelectCondition: null,
  48. maxCount: 1,
  49. canNoSelect: false,
  50. canEndNotMax: false,
  51. selectPermanentCoroutine: SelectPermanentCoroutine,
  52. afterSelectPermanentCoroutine: null,
  53. mode: SelectPermanentEffect.Mode.Custom,
  54. cardEffect: activateClass);
  55. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to De-Digivolve.", "Opponent is selecting 1 digimon to De-Digivolve.");
  56. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  57. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  58. {
  59. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 2, activateClass).Degeneration());
  60. }
  61. }
  62. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CannotUnsuspendValidTargets))
  63. {
  64. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  65. selectPermanentEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: CannotUnsuspendValidTargets,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. maxCount: 1,
  71. canNoSelect: false,
  72. canEndNotMax: false,
  73. selectPermanentCoroutine: SelectPermanentCoroutine,
  74. afterSelectPermanentCoroutine: null,
  75. mode: SelectPermanentEffect.Mode.Custom,
  76. cardEffect: activateClass);
  77. selectPermanentEffect.SetUpCustomMessage("Select 1 card to prevent from digivolving.", "Opponent is selecting 1 card to prevent from digivolving.");
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. IEnumerator SelectPermanentCoroutine(Permanent selectedPermanent)
  80. {
  81. CanNotDigivolveClass canNotPutFieldClass = new CanNotDigivolveClass();
  82. canNotPutFieldClass.SetUpICardEffect("Can't Digivolve", CanUseCondition1, card);
  83. canNotPutFieldClass.SetUpCanNotEvolveClass(permanentCondition: PermanentCondition, cardCondition: CardCondition);
  84. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  85. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().DebuffSE);
  86. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  87. bool CanUseCondition1(Hashtable hashtable) => true;
  88. bool PermanentCondition(Permanent permanent)
  89. {
  90. return permanent == selectedPermanent
  91. && permanent.TopCard != null
  92. && !permanent.TopCard.CanNotBeAffected(canNotPutFieldClass);
  93. }
  94. bool CardCondition(CardSource cardSource)
  95. {
  96. return cardSource.Owner == card.Owner.Enemy
  97. && !cardSource.CanNotBeAffected(canNotPutFieldClass);
  98. }
  99. ICardEffect GetCardEffect(EffectTiming _timing)
  100. {
  101. if (_timing == EffectTiming.None)
  102. {
  103. return canNotPutFieldClass;
  104. }
  105. return null;
  106. }
  107. }
  108. }
  109. }
  110. #endregion
  111. #region On Play
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  116. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("On Play"));
  117. activateClass.SetHashString(SharedHashString);
  118. cardEffects.Add(activateClass);
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  122. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  123. }
  124. }
  125. #endregion
  126. #region When Digivolving
  127. if (timing == EffectTiming.OnEnterFieldAnyone)
  128. {
  129. ActivateClass activateClass = new ActivateClass();
  130. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  131. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  132. activateClass.SetHashString(SharedHashString);
  133. cardEffects.Add(activateClass);
  134. bool CanUseCondition(Hashtable hashtable)
  135. {
  136. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  137. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  138. }
  139. }
  140. #endregion
  141. #region When Attacking
  142. if(timing == EffectTiming.OnAllyAttack)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  146. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  147. activateClass.SetHashString(SharedHashString);
  148. cardEffects.Add(activateClass);
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  152. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  153. }
  154. }
  155. #endregion
  156. #region End of Your Turn
  157. if (timing == EffectTiming.OnEndTurn)
  158. {
  159. ActivateClass activateClass = new ActivateClass();
  160. activateClass.SetUpICardEffect("1 other digimon may digivolve into a green card w/[Maquinamon] in text for free", CanUseCondition, card);
  161. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  162. activateClass.SetHashString("EX11_045_EOYT");
  163. cardEffects.Add(activateClass);
  164. string EffectDescription() => "[End of Your Turn] [Once Per Turn] 1 of your other Digimon may digivolve into a green Digimon card with [Maquinamon] in its text in the hand without paying the cost.";
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  168. && CardEffectCommons.IsOwnerTurn(card);
  169. }
  170. bool CanActivateCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  173. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanDigivolvePermanentCondition);
  174. }
  175. bool CanDigivolvePermanentCondition(Permanent permanent)
  176. {
  177. return permanent != card.PermanentOfThisCard()
  178. && CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  179. && CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanDigivolveCardCondition(cardSource, permanent));
  180. }
  181. bool CanDigivolveCardCondition(CardSource cardSource, Permanent permanent)
  182. {
  183. return CanSelectCardCondition(cardSource)
  184. && cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass);
  185. }
  186. bool CanSelectCardCondition(CardSource cardSource)
  187. {
  188. return cardSource.HasText("Maquinamon")
  189. && cardSource.HasCardColor(CardColor.Green);
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  194. selectPermanentEffect.SetUp(
  195. selectPlayer: card.Owner,
  196. canTargetCondition: CanDigivolvePermanentCondition,
  197. canTargetCondition_ByPreSelecetedList: null,
  198. canEndSelectCondition: null,
  199. maxCount: 1,
  200. canNoSelect: true,
  201. canEndNotMax: false,
  202. selectPermanentCoroutine: SelectPermanentCoroutine,
  203. afterSelectPermanentCoroutine: null,
  204. mode: SelectPermanentEffect.Mode.Custom,
  205. cardEffect: activateClass);
  206. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "Opponent is selecting a Digimon to digivolve.");
  207. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  208. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  209. {
  210. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  211. targetPermanent: permanent,
  212. cardCondition: CanSelectCardCondition,
  213. payCost: false,
  214. reduceCostTuple: null,
  215. fixedCostTuple: null,
  216. ignoreDigivolutionRequirementFixedCost: -1,
  217. isHand: true,
  218. activateClass: activateClass,
  219. successProcess: null
  220. ));
  221. }
  222. }
  223. }
  224. #endregion
  225. #region Assembly
  226. if (timing == EffectTiming.None)
  227. {
  228. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  229. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  230. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  231. addAssemblyConditionClass.SetNotShowUI(true);
  232. cardEffects.Add(addAssemblyConditionClass);
  233. bool CanUseCondition(Hashtable hashtable)
  234. {
  235. return true;
  236. }
  237. AssemblyCondition GetAssembly(CardSource cardSource)
  238. {
  239. if (cardSource == card)
  240. {
  241. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition);
  242. bool CanSelectCardCondition(CardSource cardSource)
  243. {
  244. return cardSource != null
  245. && cardSource.Owner == card.Owner
  246. && cardSource.IsDigimon
  247. && cardSource.HasCardColor(CardColor.Black)
  248. && cardSource.HasText("Maquinamon");
  249. }
  250. AssemblyCondition assemblyCondition = new AssemblyCondition(
  251. element: element,
  252. CanTargetCondition_ByPreSelecetedList: null,
  253. selectMessage: "5 Black Digimon cards with [Maquinamon] in text",
  254. elementCount: 5,
  255. reduceCost: 5);
  256. return assemblyCondition;
  257. }
  258. return null;
  259. }
  260. }
  261. #endregion
  262. #region ESS
  263. if (timing == EffectTiming.OnAddDigivolutionCards)
  264. {
  265. ActivateClass activateClass = new ActivateClass();
  266. activateClass.SetUpICardEffect("Delete 1 lowest play cost", CanUseCondition, card);
  267. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  268. activateClass.SetIsInheritedEffect(true);
  269. activateClass.SetHashString("EX11_045_DELETE_ESS");
  270. cardEffects.Add(activateClass);
  271. string EffectDescription()
  272. {
  273. return "[All Turns] [Once Per Turn] When effects add to this Digimon's digivolution cards, delete 1 of your opponent's Digimon with the lowest play cost.";
  274. }
  275. bool CanUseCondition(Hashtable hashtable)
  276. {
  277. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  278. && CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  279. hashtable: hashtable,
  280. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  281. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  282. cardCondition: null);
  283. }
  284. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  285. bool ValidTarget(Permanent permanent) => CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, true);
  286. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  287. {
  288. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, ValidTarget))
  289. {
  290. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  291. selectPermanentEffect.SetUp(
  292. selectPlayer: card.Owner,
  293. canTargetCondition: ValidTarget,
  294. canTargetCondition_ByPreSelecetedList: null,
  295. canEndSelectCondition: null,
  296. maxCount: 1,
  297. canNoSelect: false,
  298. canEndNotMax: false,
  299. selectPermanentCoroutine: null,
  300. afterSelectPermanentCoroutine: null,
  301. mode: SelectPermanentEffect.Mode.Destroy,
  302. cardEffect: activateClass);
  303. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  304. }
  305. }
  306. }
  307. #endregion
  308. return cardEffects;
  309. }
  310. }
  311. }