EX9_030.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_030 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel4 &&
  18. (targetPermanent.TopCard.EqualsTraits("Machine") ||
  19. targetPermanent.TopCard.EqualsTraits("DM"));
  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.3] card from hand, to get Play Cost -2", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  30. activateClass.SetHashString("PlayCost-2_EX9_030");
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "When this card would be played, by trashing 1 [Cyborg]/[Ver.3] 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.3"));
  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.3] 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 as source to reduce DP", 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, 1 of your opponent's Digimon gets -3000 DP until their turn ends. It further gets -2000 DP for each of this Digimon's face-down digivolution cards.";
  140. }
  141. bool CanUseCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  144. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  149. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTrashCardCondition);
  150. }
  151. bool CanSelectTrashCardCondition(CardSource cardSource)
  152. {
  153. return cardSource.IsDigimon;
  154. }
  155. int DPToReduce()
  156. {
  157. return -3000 - (2000 * card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count);
  158. }
  159. bool CanSelectPermanentCondition(Permanent permanent)
  160. {
  161. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  162. }
  163. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  164. {
  165. CardSource selectedCard = null;
  166. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectTrashCardCondition));
  167. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  168. selectCardEffect.SetUp(
  169. canTargetCondition: CanSelectTrashCardCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. canNoSelect: () => true,
  173. selectCardCoroutine: SelectCardCoroutine,
  174. afterSelectCardCoroutine: null,
  175. message: "Select 1 card to place face down under digimon",
  176. maxCount: maxCount,
  177. canEndNotMax: false,
  178. isShowOpponent: true,
  179. mode: SelectCardEffect.Mode.Custom,
  180. root: SelectCardEffect.Root.Trash,
  181. customRootCardList: null,
  182. canLookReverseCard: true,
  183. selectPlayer: card.Owner,
  184. cardEffect: activateClass);
  185. selectCardEffect.SetUpCustomMessage("Select 1 card to place face down under digimon", "The opponent is selecting 1 card to place face down under digimon.");
  186. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  187. yield return StartCoroutine(selectCardEffect.Activate());
  188. IEnumerator SelectCardCoroutine(CardSource cardSource)
  189. {
  190. selectedCard = cardSource;
  191. yield return null;
  192. }
  193. if (selectedCard != null)
  194. {
  195. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  196. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  197. int maxCountDPReduction = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  198. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  199. selectPermanentEffect.SetUp(
  200. selectPlayer: card.Owner,
  201. canTargetCondition: CanSelectPermanentCondition,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canEndSelectCondition: null,
  204. maxCount: maxCountDPReduction,
  205. canNoSelect: false,
  206. canEndNotMax: false,
  207. selectPermanentCoroutine: SelectPermanentCoroutine,
  208. afterSelectPermanentCoroutine: null,
  209. mode: SelectPermanentEffect.Mode.Custom,
  210. cardEffect: activateClass);
  211. selectPermanentEffect.SetUpCustomMessage(customMessageArray: CardEffectCommons.customPermanentMessageArray_ChangeDP(changeValue: DPToReduce(), maxCount: maxCountDPReduction));
  212. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  213. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  214. {
  215. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  216. targetPermanent: permanent,
  217. changeValue: DPToReduce(),
  218. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  219. activateClass: activateClass));
  220. }
  221. }
  222. }
  223. }
  224. #endregion
  225. #region When Digivolving
  226. if (timing == EffectTiming.OnEnterFieldAnyone)
  227. {
  228. ActivateClass activateClass = new ActivateClass();
  229. activateClass.SetUpICardEffect("Place 1 digimon from trash as source to reduce DP", CanUseCondition, card);
  230. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  231. cardEffects.Add(activateClass);
  232. string EffectDiscription()
  233. {
  234. return "[When Digivolving] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, 1 of your opponent's Digimon gets -3000 DP until their turn ends. It further gets -2000 DP for each of this Digimon's face-down digivolution cards.";
  235. }
  236. bool CanUseCondition(Hashtable hashtable)
  237. {
  238. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  239. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  240. }
  241. bool CanActivateCondition(Hashtable hashtable)
  242. {
  243. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  244. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTrashCardCondition);
  245. }
  246. bool CanSelectTrashCardCondition(CardSource cardSource)
  247. {
  248. return cardSource.IsDigimon;
  249. }
  250. int DPToReduce()
  251. {
  252. return -3000 - (2000 * card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count);
  253. }
  254. bool CanSelectPermanentCondition(Permanent permanent)
  255. {
  256. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  257. }
  258. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  259. {
  260. CardSource selectedCard = null;
  261. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectTrashCardCondition));
  262. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  263. selectCardEffect.SetUp(
  264. canTargetCondition: CanSelectTrashCardCondition,
  265. canTargetCondition_ByPreSelecetedList: null,
  266. canEndSelectCondition: null,
  267. canNoSelect: () => true,
  268. selectCardCoroutine: SelectCardCoroutine,
  269. afterSelectCardCoroutine: null,
  270. message: "Select 1 card to place face down under digimon",
  271. maxCount: maxCount,
  272. canEndNotMax: false,
  273. isShowOpponent: true,
  274. mode: SelectCardEffect.Mode.Custom,
  275. root: SelectCardEffect.Root.Trash,
  276. customRootCardList: null,
  277. canLookReverseCard: true,
  278. selectPlayer: card.Owner,
  279. cardEffect: activateClass);
  280. selectCardEffect.SetUpCustomMessage("Select 1 card to place face down under digimon", "The opponent is selecting 1 card to place face down under digimon.");
  281. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  282. yield return StartCoroutine(selectCardEffect.Activate());
  283. IEnumerator SelectCardCoroutine(CardSource cardSource)
  284. {
  285. selectedCard = cardSource;
  286. yield return null;
  287. }
  288. if (selectedCard != null)
  289. {
  290. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  291. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  292. int maxCountDPReduction = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  293. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  294. selectPermanentEffect.SetUp(
  295. selectPlayer: card.Owner,
  296. canTargetCondition: CanSelectPermanentCondition,
  297. canTargetCondition_ByPreSelecetedList: null,
  298. canEndSelectCondition: null,
  299. maxCount: maxCountDPReduction,
  300. canNoSelect: false,
  301. canEndNotMax: false,
  302. selectPermanentCoroutine: SelectPermanentCoroutine,
  303. afterSelectPermanentCoroutine: null,
  304. mode: SelectPermanentEffect.Mode.Custom,
  305. cardEffect: activateClass);
  306. selectPermanentEffect.SetUpCustomMessage(customMessageArray: CardEffectCommons.customPermanentMessageArray_ChangeDP(changeValue: DPToReduce(), maxCount: maxCountDPReduction));
  307. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  308. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  309. {
  310. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  311. targetPermanent: permanent,
  312. changeValue: DPToReduce(),
  313. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  314. activateClass: activateClass));
  315. }
  316. }
  317. }
  318. }
  319. #endregion
  320. #region Blocker - ESS
  321. if (timing == EffectTiming.None)
  322. {
  323. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  324. isInheritedEffect: true,
  325. card: card,
  326. condition: null));
  327. }
  328. #endregion
  329. return cardEffects;
  330. }
  331. }
  332. }