EX9_011.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // MetalGreymon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_011 : 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. if (targetPermanent.TopCard.IsLevel4)
  19. {
  20. if (targetPermanent.TopCard.ContainsCardName("Greymon"))
  21. {
  22. return true;
  23. }
  24. if (targetPermanent.TopCard.EqualsTraits("DM"))
  25. {
  26. return true;
  27. }
  28. }
  29. return false;
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  32. }
  33. #endregion
  34. #region Play Cost Reduction
  35. if (timing == EffectTiming.BeforePayCost)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect("Trash 1 [Cyborg]/[Ver.1] card from hand, to get Play Cost -2", CanUseCondition, card);
  39. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  40. activateClass.SetHashString("PlayCost-4_BT13_083");
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "When this card would be played, by trashing 1 [Cyborg]/[Ver.1] card from your hand, reduce the play cost by 2.";
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card))
  49. {
  50. return true;
  51. }
  52. return false;
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  57. {
  58. return true;
  59. }
  60. return false;
  61. }
  62. bool CanSelectCardCondition(CardSource cardSource)
  63. {
  64. if (CardEffectCommons.IsExistOnHand(cardSource))
  65. {
  66. if (cardSource != card)
  67. {
  68. if (cardSource.EqualsTraits("Cyborg") || cardSource.EqualsTraits("Ver.1"))
  69. {
  70. return true;
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. bool CanNoSelect =
  79. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable) != null &&
  80. card.PayingCost(
  81. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable).Root,
  82. null,
  83. checkAvailability: false)
  84. <= card.Owner.MaxMemoryCost;
  85. bool discarded = false;
  86. int discardCount = 1;
  87. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  88. selectHandEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectCardCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: discardCount,
  94. canNoSelect: true,
  95. canEndNotMax: false,
  96. isShowOpponent: true,
  97. selectCardCoroutine: null,
  98. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  99. mode: SelectHandEffect.Mode.Discard,
  100. cardEffect: activateClass);
  101. selectHandEffect.SetUpCustomMessage("Choose a [Cyborg] or [Ver.1] card to discard", "The opponent is selecting 1 card in hand to discard.");
  102. selectHandEffect.SetUpCustomMessage_ShowCard("Discarded Card");
  103. yield return StartCoroutine(selectHandEffect.Activate());
  104. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  105. {
  106. if (cardSources.Count >= 1)
  107. {
  108. discarded = true;
  109. yield return null;
  110. }
  111. }
  112. if (discarded)
  113. {
  114. if (card.Owner.CanReduceCost(null, card))
  115. {
  116. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  117. }
  118. ChangeCostClass changeCostClass = new ChangeCostClass();
  119. changeCostClass.SetUpICardEffect("Play Cost -2", hashtable => true, card);
  120. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  121. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  122. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  123. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  124. {
  125. if (CardSourceCondition(cardSource))
  126. {
  127. if (RootCondition(root))
  128. {
  129. if (PermanentsCondition(targetPermanents))
  130. {
  131. Cost -= 2;
  132. }
  133. }
  134. }
  135. return Cost;
  136. }
  137. bool PermanentsCondition(List<Permanent> targetPermanents)
  138. {
  139. if (targetPermanents == null)
  140. {
  141. return true;
  142. }
  143. else
  144. {
  145. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  146. {
  147. return true;
  148. }
  149. }
  150. return false;
  151. }
  152. bool CardSourceCondition(CardSource cardSource)
  153. {
  154. if (cardSource != null)
  155. {
  156. if (cardSource == card)
  157. {
  158. return true;
  159. }
  160. }
  161. return false;
  162. }
  163. bool RootCondition(SelectCardEffect.Root root)
  164. {
  165. return true;
  166. }
  167. bool isUpDown()
  168. {
  169. return true;
  170. }
  171. }
  172. }
  173. }
  174. #endregion
  175. #region On Play
  176. if (timing == EffectTiming.OnEnterFieldAnyone)
  177. {
  178. ActivateClass activateClass = new ActivateClass();
  179. activateClass.SetUpICardEffect("Place 1 digimon in trash as source, to delete digimon", CanUseCondition, card);
  180. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  181. cardEffects.Add(activateClass);
  182. string EffectDiscription()
  183. => "[On Play] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, delete up to 5000 DP total worth of your opponent's Digimon. For each of this Digimon's face-down digivolution cards, add 2000 to this effect's DP maximum.";
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  187. {
  188. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  189. {
  190. return true;
  191. }
  192. }
  193. return false;
  194. }
  195. bool CanActivateCondition(Hashtable hashtable)
  196. {
  197. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  198. {
  199. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTrashCardCondition))
  200. {
  201. return true;
  202. }
  203. }
  204. return false;
  205. }
  206. bool CanSelectTrashCardCondition(CardSource cardSource)
  207. {
  208. return cardSource.IsDigimon;
  209. }
  210. int DeletionMaxDP()
  211. {
  212. return 5000 + (2000 * card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count);
  213. }
  214. bool CanSelectDeletePermanentCondition(Permanent permanent)
  215. {
  216. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  217. {
  218. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  219. {
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. IEnumerator ActivateCoroutine(Hashtable hashtable)
  226. {
  227. CardSource selectedCard = null;
  228. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectTrashCardCondition));
  229. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  230. selectCardEffect.SetUp(
  231. canTargetCondition: CanSelectTrashCardCondition,
  232. canTargetCondition_ByPreSelecetedList: null,
  233. canEndSelectCondition: null,
  234. canNoSelect: () => true,
  235. selectCardCoroutine: SelectCardCoroutine,
  236. afterSelectCardCoroutine: null,
  237. message: "Select 1 card to place face down under digimon",
  238. maxCount: maxCount,
  239. canEndNotMax: false,
  240. isShowOpponent: true,
  241. mode: SelectCardEffect.Mode.Custom,
  242. root: SelectCardEffect.Root.Trash,
  243. customRootCardList: null,
  244. canLookReverseCard: true,
  245. selectPlayer: card.Owner,
  246. cardEffect: activateClass);
  247. selectCardEffect.SetUpCustomMessage("Select 1 card to place face down under digimon", "The opponent is selecting 1 card to place face down under digimon.");
  248. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  249. yield return StartCoroutine(selectCardEffect.Activate());
  250. IEnumerator SelectCardCoroutine(CardSource cardSource)
  251. {
  252. selectedCard = cardSource;
  253. yield return null;
  254. }
  255. if (selectedCard != null)
  256. {
  257. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  258. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  259. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  260. {
  261. int maxCount1 = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectDeletePermanentCondition),
  262. CardEffectCommons.MatchConditionPermanentCount(CanSelectDeletePermanentCondition));
  263. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  264. selectPermanentEffect.SetUp(
  265. selectPlayer: card.Owner,
  266. canTargetCondition: CanSelectDeletePermanentCondition,
  267. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  268. canEndSelectCondition: CanEndSelectCondition,
  269. maxCount: maxCount1,
  270. canNoSelect: false,
  271. canEndNotMax: true,
  272. selectPermanentCoroutine: null,
  273. afterSelectPermanentCoroutine: null,
  274. mode: SelectPermanentEffect.Mode.Destroy,
  275. cardEffect: activateClass);
  276. selectPermanentEffect.SetUpCustomMessage("Choose digimon to delete, Opponent is choosing digimon to delete");
  277. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  278. bool CanEndSelectCondition(List<Permanent> permanents)
  279. {
  280. if (permanents.Count <= 0)
  281. {
  282. return false;
  283. }
  284. int sumDP = 0;
  285. foreach (Permanent permanent in permanents)
  286. {
  287. sumDP += permanent.DP;
  288. }
  289. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  290. {
  291. return false;
  292. }
  293. return true;
  294. }
  295. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  296. {
  297. int sumDP = 0;
  298. foreach (Permanent permanent1 in permanents)
  299. {
  300. sumDP += permanent1.DP;
  301. }
  302. sumDP += permanent.DP;
  303. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  304. {
  305. return false;
  306. }
  307. return true;
  308. }
  309. }
  310. }
  311. }
  312. }
  313. #endregion
  314. #region When Digivolving
  315. if (timing == EffectTiming.OnEnterFieldAnyone)
  316. {
  317. ActivateClass activateClass = new ActivateClass();
  318. activateClass.SetUpICardEffect("Place 1 digimon in trash as source, to delete digimon", CanUseCondition, card);
  319. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  320. cardEffects.Add(activateClass);
  321. string EffectDiscription()
  322. => "[When Digivolving] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, delete up to 5000 DP total worth of your opponent's Digimon. For each of this Digimon's face-down digivolution cards, add 2000 to this effect's DP maximum.";
  323. bool CanUseCondition(Hashtable hashtable)
  324. {
  325. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  326. {
  327. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  328. {
  329. return true;
  330. }
  331. }
  332. return false;
  333. }
  334. bool CanActivateCondition(Hashtable hashtable)
  335. {
  336. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  337. {
  338. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTrashCardCondition))
  339. {
  340. return true;
  341. }
  342. }
  343. return false;
  344. }
  345. bool CanSelectTrashCardCondition(CardSource cardSource)
  346. {
  347. return cardSource.IsDigimon;
  348. }
  349. int DeletionMaxDP()
  350. {
  351. return 5000 + (2000 * card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count);
  352. }
  353. bool CanSelectDeletePermanentCondition(Permanent permanent)
  354. {
  355. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  356. {
  357. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  358. {
  359. return true;
  360. }
  361. }
  362. return false;
  363. }
  364. IEnumerator ActivateCoroutine(Hashtable hashtable)
  365. {
  366. CardSource selectedCard = null;
  367. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectTrashCardCondition));
  368. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  369. selectCardEffect.SetUp(
  370. canTargetCondition: CanSelectTrashCardCondition,
  371. canTargetCondition_ByPreSelecetedList: null,
  372. canEndSelectCondition: null,
  373. canNoSelect: () => true,
  374. selectCardCoroutine: SelectCardCoroutine,
  375. afterSelectCardCoroutine: null,
  376. message: "Select 1 card to place face down under digimon",
  377. maxCount: maxCount,
  378. canEndNotMax: false,
  379. isShowOpponent: true,
  380. mode: SelectCardEffect.Mode.Custom,
  381. root: SelectCardEffect.Root.Trash,
  382. customRootCardList: null,
  383. canLookReverseCard: true,
  384. selectPlayer: card.Owner,
  385. cardEffect: activateClass);
  386. selectCardEffect.SetUpCustomMessage("Select 1 card to place face down under digimon", "The opponent is selecting 1 card to place face down under digimon.");
  387. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  388. yield return StartCoroutine(selectCardEffect.Activate());
  389. IEnumerator SelectCardCoroutine(CardSource cardSource)
  390. {
  391. selectedCard = cardSource;
  392. yield return null;
  393. }
  394. if (selectedCard != null)
  395. {
  396. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  397. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  398. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  399. {
  400. int maxCount1 = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectDeletePermanentCondition),
  401. CardEffectCommons.MatchConditionPermanentCount(CanSelectDeletePermanentCondition));
  402. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  403. selectPermanentEffect.SetUp(
  404. selectPlayer: card.Owner,
  405. canTargetCondition: CanSelectDeletePermanentCondition,
  406. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  407. canEndSelectCondition: CanEndSelectCondition,
  408. maxCount: maxCount1,
  409. canNoSelect: false,
  410. canEndNotMax: true,
  411. selectPermanentCoroutine: null,
  412. afterSelectPermanentCoroutine: null,
  413. mode: SelectPermanentEffect.Mode.Destroy,
  414. cardEffect: activateClass);
  415. selectPermanentEffect.SetUpCustomMessage("Choose digimon to delete, Opponent is choosing digimon to delete");
  416. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  417. bool CanEndSelectCondition(List<Permanent> permanents)
  418. {
  419. if (permanents.Count <= 0)
  420. {
  421. return false;
  422. }
  423. int sumDP = 0;
  424. foreach (Permanent permanent in permanents)
  425. {
  426. sumDP += permanent.DP;
  427. }
  428. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  429. {
  430. return false;
  431. }
  432. return true;
  433. }
  434. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  435. {
  436. int sumDP = 0;
  437. foreach (Permanent permanent1 in permanents)
  438. {
  439. sumDP += permanent1.DP;
  440. }
  441. sumDP += permanent.DP;
  442. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  443. {
  444. return false;
  445. }
  446. return true;
  447. }
  448. }
  449. }
  450. }
  451. }
  452. #endregion
  453. #region ESS
  454. if (timing == EffectTiming.None)
  455. {
  456. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: null));
  457. }
  458. #endregion
  459. return cardEffects;
  460. }
  461. }
  462. }