EX9_043.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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. CardSource selectedCard = null;
  166. bool CanSelectPermanentDeleteCondition(Permanent permanent)
  167. {
  168. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  169. permanent.DP <= card.Owner.MaxDP_DeleteEffect(3000, activateClass);
  170. }
  171. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCardCondition))
  172. {
  173. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  174. selectCardEffect.SetUp(
  175. canTargetCondition: SharedCardCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. canNoSelect: () => true,
  179. selectCardCoroutine: SelectCardCoroutine,
  180. afterSelectCardCoroutine: null,
  181. message: "Select 1 card to add as bottom digivolution card",
  182. maxCount: 1,
  183. canEndNotMax: false,
  184. isShowOpponent: false,
  185. mode: SelectCardEffect.Mode.Custom,
  186. root: SelectCardEffect.Root.Trash,
  187. customRootCardList: card.Owner.TrashCards,
  188. canLookReverseCard: true,
  189. selectPlayer: card.Owner,
  190. cardEffect: activateClass
  191. );
  192. selectCardEffect.SetUpCustomMessage("Select 1 card to add as bottom digivolution card.", "The opponent is selecting 1 card to add as bottom digivolution card.");
  193. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  194. IEnumerator SelectCardCoroutine(CardSource cardSource)
  195. {
  196. selectedCard = cardSource;
  197. yield return null;
  198. }
  199. }
  200. if (selectedCard != null)
  201. {
  202. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  203. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  204. bool CanSelectPermanentCondition(Permanent permanent)
  205. {
  206. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  207. }
  208. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  209. {
  210. Permanent selectedPermanent = null;
  211. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  212. selectPermanentEffect.SetUp(
  213. selectPlayer: card.Owner,
  214. canTargetCondition: CanSelectPermanentCondition,
  215. canTargetCondition_ByPreSelecetedList: null,
  216. canEndSelectCondition: null,
  217. maxCount: 1,
  218. canNoSelect: false,
  219. canEndNotMax: false,
  220. selectPermanentCoroutine: SelectPermanentCoroutine,
  221. afterSelectPermanentCoroutine: null,
  222. mode: SelectPermanentEffect.Mode.Custom,
  223. cardEffect: activateClass);
  224. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to de-digivolve", "The opponent is selecting 1 Digimon to de-digivolve");
  225. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  226. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  227. {
  228. selectedPermanent = permanent;
  229. yield return null;
  230. }
  231. if (selectedPermanent != null)
  232. {
  233. var degenCount = card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count;
  234. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, degenCount, activateClass,false).Degeneration());
  235. }
  236. }
  237. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentDeleteCondition))
  238. {
  239. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  240. selectPermanentEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: CanSelectPermanentDeleteCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: 1,
  246. canNoSelect: false,
  247. canEndNotMax: false,
  248. selectPermanentCoroutine: null,
  249. afterSelectPermanentCoroutine: null,
  250. mode: SelectPermanentEffect.Mode.Destroy,
  251. cardEffect: activateClass);
  252. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete", "The opponent is selecting 1 Digimon to delete");
  253. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  254. }
  255. }
  256. }
  257. #endregion
  258. #region On Play
  259. if (timing == EffectTiming.OnEnterFieldAnyone)
  260. {
  261. ActivateClass activateClass = new ActivateClass();
  262. 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);
  263. activateClass.SetUpActivateClass(CanActivateCondition, _ => SharedActivateCoroutine(activateClass), -1, true, EffectDiscription());
  264. cardEffects.Add(activateClass);
  265. string EffectDiscription()
  266. {
  267. 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.";
  268. }
  269. bool CanUseCondition(Hashtable hashtable)
  270. {
  271. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  272. }
  273. bool CanActivateCondition(Hashtable hashtable)
  274. {
  275. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCardCondition);
  276. }
  277. }
  278. #endregion
  279. #region When Digivolving
  280. if (timing == EffectTiming.OnEnterFieldAnyone)
  281. {
  282. ActivateClass activateClass = new ActivateClass();
  283. 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);
  284. activateClass.SetUpActivateClass(CanActivateCondition, _ => SharedActivateCoroutine(activateClass), -1, true, EffectDiscription());
  285. cardEffects.Add(activateClass);
  286. string EffectDiscription()
  287. {
  288. 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.";
  289. }
  290. bool CanUseCondition(Hashtable hashtable)
  291. {
  292. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  293. }
  294. bool CanActivateCondition(Hashtable hashtable)
  295. {
  296. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCardCondition);
  297. }
  298. }
  299. #endregion
  300. #region ESS
  301. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  302. {
  303. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  304. }
  305. #endregion
  306. return cardEffects;
  307. }
  308. }
  309. }