EX9_064.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Megadramon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_064 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4 &&
  19. (targetPermanent.TopCard.EqualsTraits("DM") || targetPermanent.TopCard.EqualsTraits("Cyborg"));
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Play Cost Reduction
  25. if (timing == EffectTiming.BeforePayCost)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Trash 1 [Cyborg]/[Ver.4] card from hand, to get Play Cost -2", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  30. activateClass.SetHashString("PlayCost-2_EX9_064");
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "When this card would be played, by trashing 1 [Cyborg]/[Ver.4] card from your hand, reduce the play cost by 2.";
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card);
  39. }
  40. bool CanActivateCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  43. }
  44. bool CanSelectCardCondition(CardSource cardSource)
  45. {
  46. return CardEffectCommons.IsExistOnHand(cardSource) &&
  47. cardSource != card &&
  48. (cardSource.EqualsTraits("Cyborg") ||
  49. cardSource.EqualsTraits("Ver.4"));
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  52. {
  53. bool CanNoSelect =
  54. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable) != null &&
  55. card.PayingCost(
  56. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable).Root,
  57. null,
  58. checkAvailability: false)
  59. <= card.Owner.MaxMemoryCost;
  60. bool discarded = false;
  61. int discardCount = 1;
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectCardCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: discardCount,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: null,
  73. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  74. mode: SelectHandEffect.Mode.Discard,
  75. cardEffect: activateClass);
  76. selectHandEffect.SetUpCustomMessage("Choose a [Cyborg] or [Ver.4] card to discard", "The opponent is selecting 1 card in hand to discard.");
  77. selectHandEffect.SetUpCustomMessage_ShowCard("Discarded Card");
  78. yield return StartCoroutine(selectHandEffect.Activate());
  79. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  80. {
  81. if (cardSources.Count >= 1)
  82. {
  83. discarded = true;
  84. yield return null;
  85. }
  86. }
  87. if (discarded)
  88. {
  89. if (card.Owner.CanReduceCost(null, card))
  90. {
  91. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  92. }
  93. ChangeCostClass changeCostClass = new ChangeCostClass();
  94. changeCostClass.SetUpICardEffect("Play Cost -2", hashtable => true, card);
  95. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  96. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  98. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  99. {
  100. if (CardSourceCondition(cardSource) &&
  101. RootCondition(root) &&
  102. PermanentsCondition(targetPermanents))
  103. {
  104. Cost -= 2;
  105. }
  106. return Cost;
  107. }
  108. bool PermanentsCondition(List<Permanent> targetPermanents)
  109. {
  110. return targetPermanents == null ||
  111. targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  112. }
  113. bool CardSourceCondition(CardSource cardSource)
  114. {
  115. return cardSource != null &&
  116. cardSource == card;
  117. }
  118. bool RootCondition(SelectCardEffect.Root root)
  119. {
  120. return true;
  121. }
  122. bool isUpDown()
  123. {
  124. return true;
  125. }
  126. }
  127. }
  128. }
  129. #endregion
  130. #region On Play
  131. if (timing == EffectTiming.OnEnterFieldAnyone)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect("Place 1 digimon from trash FD in source, delete 2 digimon", CanUseCondition, card);
  135. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  136. cardEffects.Add(activateClass);
  137. string EffectDiscription()
  138. {
  139. return "[On Play] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, delete 2 of your opponent's play cost 4 or lower Digimon. For each of this Digimon's face-down digivolution cards, add 1 to this effect's play cost maximum.";
  140. }
  141. bool CanUseCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  144. }
  145. bool CanActivateCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  148. }
  149. bool CanSelectCardCondition(CardSource cardSource)
  150. {
  151. return cardSource.IsDigimon;
  152. }
  153. bool CanSelectPermanentCondition(Permanent permanent)
  154. {
  155. var playCost = 4 + card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count;
  156. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  157. permanent.TopCard.HasPlayCost && permanent.TopCard.BasePlayCostFromEntity <= playCost;
  158. }
  159. IEnumerator ActivateCoroutine(Hashtable hashtable)
  160. {
  161. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  162. {
  163. CardSource selectedCard = null;
  164. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  165. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  166. selectCardEffect.SetUp(
  167. canTargetCondition: CanSelectCardCondition,
  168. canTargetCondition_ByPreSelecetedList: null,
  169. canEndSelectCondition: null,
  170. canNoSelect: () => true,
  171. selectCardCoroutine: SelectCardCoroutine,
  172. afterSelectCardCoroutine: null,
  173. message: "Select 1 digimon to place FD as source",
  174. maxCount: maxCount,
  175. canEndNotMax: true,
  176. isShowOpponent: true,
  177. mode: SelectCardEffect.Mode.Custom,
  178. root: SelectCardEffect.Root.Trash,
  179. customRootCardList: null,
  180. canLookReverseCard: true,
  181. selectPlayer: card.Owner,
  182. cardEffect: activateClass);
  183. selectCardEffect.SetUpCustomMessage("Select 1 digimon to place FD as source", "The opponent is selecting 1 digimon");
  184. yield return StartCoroutine(selectCardEffect.Activate());
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. selectedCard = cardSource;
  188. yield return null;
  189. }
  190. if (selectedCard != null)
  191. {
  192. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  193. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  194. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  195. {
  196. int maxCount1 = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  197. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  198. selectPermanentEffect.SetUp(
  199. selectPlayer: card.Owner,
  200. canTargetCondition: CanSelectPermanentCondition,
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. maxCount: maxCount1,
  204. canNoSelect: false,
  205. canEndNotMax: false,
  206. selectPermanentCoroutine: null,
  207. afterSelectPermanentCoroutine: null,
  208. mode: SelectPermanentEffect.Mode.Destroy,
  209. cardEffect: activateClass);
  210. selectPermanentEffect.SetUpCustomMessage("Select 2 digimon to delete.", "The opponent is selecting 2 digimon to delete.");
  211. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  212. }
  213. }
  214. }
  215. }
  216. }
  217. #endregion
  218. #region When Digivolving
  219. if (timing == EffectTiming.OnEnterFieldAnyone)
  220. {
  221. ActivateClass activateClass = new ActivateClass();
  222. activateClass.SetUpICardEffect("Place 1 digimon from trash FD in source, delete 2 digimon", CanUseCondition, card);
  223. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  224. cardEffects.Add(activateClass);
  225. string EffectDiscription()
  226. {
  227. return "[When Digivolving] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, delete 2 of your opponent's play cost 4 or lower Digimon. For each of this Digimon's face-down digivolution cards, add 1 to this effect's play cost maximum.";
  228. }
  229. bool CanUseCondition(Hashtable hashtable)
  230. {
  231. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  232. }
  233. bool CanActivateCondition(Hashtable hashtable)
  234. {
  235. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  236. }
  237. bool CanSelectCardCondition(CardSource cardSource)
  238. {
  239. return cardSource.IsDigimon;
  240. }
  241. bool CanSelectPermanentCondition(Permanent permanent)
  242. {
  243. var playCost = 4 + card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count;
  244. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  245. permanent.TopCard.HasPlayCost && permanent.TopCard.BasePlayCostFromEntity <= playCost;
  246. }
  247. IEnumerator ActivateCoroutine(Hashtable hashtable)
  248. {
  249. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  250. {
  251. CardSource selectedCard = null;
  252. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  253. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  254. selectCardEffect.SetUp(
  255. canTargetCondition: CanSelectCardCondition,
  256. canTargetCondition_ByPreSelecetedList: null,
  257. canEndSelectCondition: null,
  258. canNoSelect: () => true,
  259. selectCardCoroutine: SelectCardCoroutine,
  260. afterSelectCardCoroutine: null,
  261. message: "Select 1 digimon to place FD as source",
  262. maxCount: maxCount,
  263. canEndNotMax: true,
  264. isShowOpponent: true,
  265. mode: SelectCardEffect.Mode.Custom,
  266. root: SelectCardEffect.Root.Trash,
  267. customRootCardList: null,
  268. canLookReverseCard: true,
  269. selectPlayer: card.Owner,
  270. cardEffect: activateClass);
  271. selectCardEffect.SetUpCustomMessage("Select 1 digimon to place FD as source", "The opponent is selecting 1 digimon");
  272. yield return StartCoroutine(selectCardEffect.Activate());
  273. IEnumerator SelectCardCoroutine(CardSource cardSource)
  274. {
  275. selectedCard = cardSource;
  276. yield return null;
  277. }
  278. if (selectedCard != null)
  279. {
  280. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  281. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  282. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  283. {
  284. int maxCount1 = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  285. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  286. selectPermanentEffect.SetUp(
  287. selectPlayer: card.Owner,
  288. canTargetCondition: CanSelectPermanentCondition,
  289. canTargetCondition_ByPreSelecetedList: null,
  290. canEndSelectCondition: null,
  291. maxCount: maxCount1,
  292. canNoSelect: false,
  293. canEndNotMax: false,
  294. selectPermanentCoroutine: null,
  295. afterSelectPermanentCoroutine: null,
  296. mode: SelectPermanentEffect.Mode.Destroy,
  297. cardEffect: activateClass);
  298. selectPermanentEffect.SetUpCustomMessage("Select 2 digimon to delete.", "The opponent is selecting 2 digimon to delete.");
  299. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  300. }
  301. }
  302. }
  303. }
  304. }
  305. #endregion
  306. #region ESS
  307. if (timing == EffectTiming.OnEndAttack)
  308. {
  309. ActivateClass activateClass = new ActivateClass();
  310. activateClass.SetUpICardEffect("Unsuspend, delete lowest level digimon", CanUseCondition, card);
  311. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  312. activateClass.SetHashString("EndAttack_EX9_064");
  313. activateClass.SetIsInheritedEffect(true);
  314. cardEffects.Add(activateClass);
  315. string EffectDiscription()
  316. {
  317. return "[End of Attack] [Once Per Turn] By unsuspending this Digimon, delete 1 of your Digimon with the lowest level.";
  318. }
  319. bool CanUseCondition(Hashtable hashtable)
  320. {
  321. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  322. }
  323. bool CanActivateCondition(Hashtable hashtable)
  324. {
  325. return CardEffectCommons.IsExistOnBattleArea(card);
  326. }
  327. bool CanSelectPermanentCondition(Permanent permanent)
  328. {
  329. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  330. CardEffectCommons.IsMinLevel(permanent, card.Owner);
  331. }
  332. IEnumerator ActivateCoroutine(Hashtable hashtable)
  333. {
  334. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  335. if (!card.PermanentOfThisCard().IsSuspended)
  336. {
  337. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  338. {
  339. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  340. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  341. selectPermanentEffect.SetUp(
  342. selectPlayer: card.Owner,
  343. canTargetCondition: CanSelectPermanentCondition,
  344. canTargetCondition_ByPreSelecetedList: null,
  345. canEndSelectCondition: null,
  346. maxCount: maxCount1,
  347. canNoSelect: false,
  348. canEndNotMax: false,
  349. selectPermanentCoroutine: null,
  350. afterSelectPermanentCoroutine: null,
  351. mode: SelectPermanentEffect.Mode.Destroy,
  352. cardEffect: activateClass);
  353. selectPermanentEffect.SetUpCustomMessage("Select a digimon to delete.", "The opponent is selecting a digimon to delete.");
  354. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  355. }
  356. }
  357. }
  358. }
  359. #endregion
  360. return cardEffects;
  361. }
  362. }
  363. }