EX9_043.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // MetalTyrannomon
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_043 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Play Cost Reduction
  14. bool reducePlayCost = false;
  15. #region When Would be Played
  16. if (timing == EffectTiming.BeforePayCost)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Trash 1 Cyborg/Ver.5 to get Play Cost -2", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  21. activateClass.SetHashString("PlayCost-2_EX9_043");
  22. activateClass.SetIsDigimonEffect(true);
  23. cardEffects.Add(activateClass);
  24. string EffectDescription() => "When this card would be played, by trashing 1 [Cyborg]/[Ver.5] trait card from your hand, reduce the play cost by 2.";
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  28. }
  29. bool CardCondition(CardSource cardSource)
  30. {
  31. return cardSource == card && CardEffectCommons.IsExistOnHand(cardSource);
  32. }
  33. bool TrashCardCondition(CardSource cardSource)
  34. {
  35. if (cardSource.EqualsTraits("Cyborg") || cardSource.EqualsTraits("Ver.5"))
  36. {
  37. return true;
  38. }
  39. return false;
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.HasMatchConditionOwnersHand(card, TrashCardCondition);
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable hashtable)
  46. {
  47. bool canNoSelect = true;
  48. CardSource cardFromHashtable = CardEffectCommons.GetCardFromHashtable(hashtable);
  49. if (cardFromHashtable && cardFromHashtable.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) >
  50. cardFromHashtable.Owner.MaxMemoryCost)
  51. {
  52. canNoSelect = false;
  53. }
  54. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  55. selectHandEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: TrashCardCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: 1,
  61. canNoSelect: canNoSelect,
  62. canEndNotMax: false,
  63. isShowOpponent: true,
  64. selectCardCoroutine: null,
  65. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  66. mode: SelectHandEffect.Mode.Discard,
  67. cardEffect: activateClass);
  68. selectHandEffect.SetUpCustomMessage("Select 1 card to trash.", "The opponent is selecting 1 card to trash.");
  69. selectHandEffect.SetUpCustomMessage_ShowCard("Trashed Card");
  70. yield return StartCoroutine(selectHandEffect.Activate());
  71. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  72. {
  73. if (CardEffectCommons.IsExistOnTrash(cardSources[0]))
  74. {
  75. if (card.Owner.CanReduceCost(null, card))
  76. {
  77. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  78. }
  79. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  80. {
  81. if (CardSourceCondition(cardSource) && RootCondition(root)) cost -= 2;
  82. return cost;
  83. }
  84. bool CardSourceCondition(CardSource cardSource)
  85. {
  86. return cardSource == card;
  87. }
  88. bool RootCondition(SelectCardEffect.Root root)
  89. {
  90. return true;
  91. }
  92. ChangeCostClass changeCostClass = new ChangeCostClass();
  93. changeCostClass.SetUpICardEffect("Play Cost -2", _ => true, card);
  94. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  95. rootCondition: RootCondition, isUpDown: () => true, isCheckAvailability: () => false,
  96. isChangePayingCost: () => true);
  97. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  99. reducePlayCost = true;
  100. }
  101. }
  102. }
  103. }
  104. #endregion
  105. #region Reduce Play Cost - Not Shown
  106. if (timing == EffectTiming.None)
  107. {
  108. ChangeCostClass changeCostClass = new ChangeCostClass();
  109. changeCostClass.SetUpICardEffect("Play Cost -2", CanUseCondition1, card);
  110. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  111. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => true,
  112. isChangePayingCost: () => true);
  113. changeCostClass.SetNotShowUI(true);
  114. cardEffects.Add(changeCostClass);
  115. bool CanUseCondition1(Hashtable hashtable1)
  116. {
  117. return true;
  118. }
  119. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  120. {
  121. if (CardSourceCondition(cardSource) && RootCondition(root) && reducePlayCost) cost -= 2;
  122. return cost;
  123. }
  124. bool CardSourceCondition(CardSource cardSource)
  125. {
  126. return cardSource == card;
  127. }
  128. bool RootCondition(SelectCardEffect.Root root)
  129. {
  130. return true;
  131. }
  132. bool IsUpDown()
  133. {
  134. return true;
  135. }
  136. }
  137. #endregion
  138. #endregion
  139. #region Digivolution Cost Reduction
  140. if (timing == EffectTiming.None)
  141. {
  142. bool PermanentCondition(Permanent targetPermanent)
  143. {
  144. if (targetPermanent.TopCard.IsLevel4)
  145. {
  146. if (targetPermanent.TopCard.ContainsCardName("Tyrannomon") || targetPermanent.TopCard.EqualsTraits("DM"))
  147. {
  148. return true;
  149. }
  150. }
  151. return false;
  152. }
  153. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  154. digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  155. }
  156. #endregion
  157. #endregion
  158. #region On Play/When Digivolving Shared
  159. bool SharedCardCondition(CardSource cardSource)
  160. {
  161. return cardSource.IsDigimon && CardEffectCommons.IsExistOnTrash(cardSource);
  162. }
  163. IEnumerator SharedActivateCoroutine(ActivateClass activateClass)
  164. {
  165. bool CardCondition(CardSource cardSource)
  166. {
  167. return cardSource.IsDigimon && CardEffectCommons.IsExistOnTrash(cardSource);
  168. }
  169. CardSource selectedCard = null;
  170. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CardCondition))
  171. {
  172. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  173. selectCardEffect.SetUp(
  174. canTargetCondition: CardCondition,
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. canNoSelect: () => true,
  178. selectCardCoroutine: SelectCardCoroutine,
  179. afterSelectCardCoroutine: null,
  180. message: "Select 1 card to add as bottom digivolution card",
  181. maxCount: 1,
  182. canEndNotMax: false,
  183. isShowOpponent: false,
  184. mode: SelectCardEffect.Mode.Custom,
  185. root: SelectCardEffect.Root.Trash,
  186. customRootCardList: card.Owner.TrashCards,
  187. canLookReverseCard: true,
  188. selectPlayer: card.Owner,
  189. cardEffect: activateClass
  190. );
  191. selectCardEffect.SetUpCustomMessage("Select 1 card to add as bottom digivolution card.", "The opponent is selecting 1 card to add as bottom digivolution card.");
  192. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  193. IEnumerator SelectCardCoroutine(CardSource cardSource)
  194. {
  195. selectedCard = cardSource;
  196. yield return null;
  197. }
  198. }
  199. if (selectedCard != null)
  200. {
  201. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  202. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  203. bool CanSelectPermanentCondition(Permanent permanent)
  204. {
  205. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  206. }
  207. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  208. {
  209. Permanent selectedPermanent = null;
  210. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  211. selectPermanentEffect.SetUp(
  212. selectPlayer: card.Owner,
  213. canTargetCondition: CanSelectPermanentCondition,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. maxCount: 1,
  217. canNoSelect: false,
  218. canEndNotMax: false,
  219. selectPermanentCoroutine: SelectPermanentCoroutine,
  220. afterSelectPermanentCoroutine: null,
  221. mode: SelectPermanentEffect.Mode.Custom,
  222. cardEffect: activateClass);
  223. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to de-digivolve", "The opponent is selecting 1 Digimon to de-digivolve");
  224. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  225. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  226. {
  227. selectedPermanent = permanent;
  228. yield return null;
  229. }
  230. if (selectedPermanent != null)
  231. {
  232. var degenCount = card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count;
  233. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, degenCount, activateClass).Degeneration());
  234. }
  235. }
  236. }
  237. bool CanSelectPermanentDeleteCondition(Permanent permanent)
  238. {
  239. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  240. permanent.DP <= 3000;
  241. }
  242. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentDeleteCondition))
  243. {
  244. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  245. selectPermanentEffect.SetUp(
  246. selectPlayer: card.Owner,
  247. canTargetCondition: CanSelectPermanentDeleteCondition,
  248. canTargetCondition_ByPreSelecetedList: null,
  249. canEndSelectCondition: null,
  250. maxCount: 1,
  251. canNoSelect: false,
  252. canEndNotMax: false,
  253. selectPermanentCoroutine: null,
  254. afterSelectPermanentCoroutine: null,
  255. mode: SelectPermanentEffect.Mode.Destroy,
  256. cardEffect: activateClass);
  257. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete", "The opponent is selecting 1 Digimon to delete");
  258. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  259. }
  260. }
  261. #endregion
  262. #region On Play
  263. if (timing == EffectTiming.OnEnterFieldAnyone)
  264. {
  265. ActivateClass activateClass = new ActivateClass();
  266. activateClass.SetUpICardEffect("By adding 1 digimon flipped from trash to sources, De-Digi for each flipped card, then delete a 3K DP or lower", CanUseCondition, card);
  267. activateClass.SetUpActivateClass(CanActivateCondition, _ => SharedActivateCoroutine(activateClass), -1, true, EffectDiscription());
  268. cardEffects.Add(activateClass);
  269. string EffectDiscription()
  270. {
  271. return "[On Play] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, to 1 of your opponent's Digimon, <De-Digivolve 1> (Trash the top card. You can't trash past level 3 cards) for each of this Digimon's face-down digivolution cards. Then, delete 1 of your opponent's 3000 DP or lower Digimon.";
  272. }
  273. bool CanUseCondition(Hashtable hashtable)
  274. {
  275. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  276. }
  277. bool CanActivateCondition(Hashtable hashtable)
  278. {
  279. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCardCondition);
  280. }
  281. }
  282. #endregion
  283. #region When Digivolving
  284. if (timing == EffectTiming.OnEnterFieldAnyone)
  285. {
  286. ActivateClass activateClass = new ActivateClass();
  287. activateClass.SetUpICardEffect("By adding 1 digimon flipped from trash to sources, De-Digi for each flipped card, then delete a 3K DP or lower", CanUseCondition, card);
  288. activateClass.SetUpActivateClass(CanActivateCondition, _ => SharedActivateCoroutine(activateClass), -1, true, EffectDiscription());
  289. cardEffects.Add(activateClass);
  290. string EffectDiscription()
  291. {
  292. return "[When Digivolving] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, to 1 of your opponent's Digimon, <De-Digivolve 1> (Trash the top card. You can't trash past level 3 cards) for each of this Digimon's face-down digivolution cards. Then, delete 1 of your opponent's 3000 DP or lower Digimon.";
  293. }
  294. bool CanUseCondition(Hashtable hashtable)
  295. {
  296. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  297. }
  298. bool CanActivateCondition(Hashtable hashtable)
  299. {
  300. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCardCondition);
  301. }
  302. }
  303. #endregion
  304. #region ESS
  305. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  306. {
  307. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  308. }
  309. #endregion
  310. return cardEffects;
  311. }
  312. }
  313. }