EX9_018.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //EX9-018 MetalMamemon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_018 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if (targetPermanent.TopCard.IsLevel4)
  19. {
  20. if (targetPermanent.TopCard.EqualsTraits("DM"))
  21. {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  28. permanentCondition: PermanentCondition,
  29. digivolutionCost: 3,
  30. ignoreDigivolutionRequirement: false,
  31. card: card,
  32. condition: null)
  33. );
  34. }
  35. if (timing == EffectTiming.None)
  36. {
  37. bool PermanentCondition(Permanent targetPermanent)
  38. {
  39. if (targetPermanent.TopCard.EqualsCardName("Mamemon"))
  40. {
  41. return true;
  42. }
  43. return false;
  44. }
  45. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  46. permanentCondition: PermanentCondition,
  47. digivolutionCost: 1,
  48. ignoreDigivolutionRequirement: false,
  49. card: card,
  50. condition: null)
  51. );
  52. }
  53. #endregion
  54. #region Play Cost Reduction
  55. if (timing == EffectTiming.BeforePayCost)
  56. {
  57. ActivateClass activateClass = new ActivateClass();
  58. activateClass.SetUpICardEffect("Trash 1 [Cyborg]/[Ver.1] card from hand, to get Play Cost -2", CanUseCondition, card);
  59. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  60. activateClass.SetHashString("PlayCost-4_BT13_083");
  61. cardEffects.Add(activateClass);
  62. string EffectDiscription()
  63. {
  64. return "When this card would be played, by trashing 1 [Cyborg]/[Ver.1] card from your hand, reduce the play cost by 2.";
  65. }
  66. bool CanUseCondition(Hashtable hashtable)
  67. {
  68. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card))
  69. {
  70. return true;
  71. }
  72. return false;
  73. }
  74. bool CanActivateCondition(Hashtable hashtable)
  75. {
  76. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  77. {
  78. return true;
  79. }
  80. return false;
  81. }
  82. bool CanSelectCardCondition(CardSource cardSource)
  83. {
  84. if (CardEffectCommons.IsExistOnHand(cardSource))
  85. {
  86. if (cardSource != card)
  87. {
  88. if (cardSource.EqualsTraits("Cyborg") || cardSource.EqualsTraits("Ver.2"))
  89. {
  90. return true;
  91. }
  92. }
  93. }
  94. return false;
  95. }
  96. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  97. {
  98. bool CanNoSelect =
  99. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable) != null &&
  100. card.PayingCost(
  101. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable).Root,
  102. null,
  103. checkAvailability: false)
  104. <= card.Owner.MaxMemoryCost;
  105. bool discarded = false;
  106. int discardCount = 1;
  107. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  108. selectHandEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: CanSelectCardCondition,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: discardCount,
  114. canNoSelect: true,
  115. canEndNotMax: false,
  116. isShowOpponent: true,
  117. selectCardCoroutine: null,
  118. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  119. mode: SelectHandEffect.Mode.Discard,
  120. cardEffect: activateClass);
  121. selectHandEffect.SetUpCustomMessage("Choose a [Cyborg] or [Ver.2] card to discard", "The opponent is selecting 1 card in hand to discard.");
  122. selectHandEffect.SetUpCustomMessage_ShowCard("Discarded Card");
  123. yield return StartCoroutine(selectHandEffect.Activate());
  124. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  125. {
  126. if (cardSources.Count >= 1)
  127. {
  128. discarded = true;
  129. yield return null;
  130. }
  131. }
  132. if (discarded)
  133. {
  134. if (card.Owner.CanReduceCost(null, card))
  135. {
  136. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  137. }
  138. ChangeCostClass changeCostClass = new ChangeCostClass();
  139. changeCostClass.SetUpICardEffect("Play Cost -2", hashtable => true, card);
  140. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  141. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  142. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  143. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  144. {
  145. if (CardSourceCondition(cardSource))
  146. {
  147. if (RootCondition(root))
  148. {
  149. if (PermanentsCondition(targetPermanents))
  150. {
  151. Cost -= 2;
  152. }
  153. }
  154. }
  155. return Cost;
  156. }
  157. bool PermanentsCondition(List<Permanent> targetPermanents)
  158. {
  159. if (targetPermanents == null)
  160. {
  161. return true;
  162. }
  163. else
  164. {
  165. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  166. {
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. bool CardSourceCondition(CardSource cardSource)
  173. {
  174. if (cardSource != null)
  175. {
  176. if (cardSource == card)
  177. {
  178. return true;
  179. }
  180. }
  181. return false;
  182. }
  183. bool RootCondition(SelectCardEffect.Root root)
  184. {
  185. return true;
  186. }
  187. bool isUpDown()
  188. {
  189. return true;
  190. }
  191. }
  192. }
  193. }
  194. #endregion
  195. #region On Play
  196. if (timing == EffectTiming.OnEnterFieldAnyone)
  197. {
  198. ActivateClass activateClass = new ActivateClass();
  199. activateClass.SetUpICardEffect("By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, from 1 of your opponent's Digimon, trash any 1 digivolution card for each of this Digimon's face-down digivolution cards. Then, return 1 of their Digimon with no digivolution cards to the bottom of the deck.\r\n", CanUseCondition, card);
  200. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  201. cardEffects.Add(activateClass);
  202. string EffectDiscription()
  203. => "[On Play] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, from 1 of your opponent's Digimon, trash any 1 digivolution card for each of this Digimon's face-down digivolution cards. Then, return 1 of their Digimon with no digivolution cards to the bottom of the deck.\r\n";
  204. bool CanUseCondition(Hashtable hashtable)
  205. {
  206. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  207. {
  208. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  209. {
  210. return true;
  211. }
  212. }
  213. return false;
  214. }
  215. bool isFlipped(CardSource source)
  216. {
  217. return source.IsFlipped;
  218. }
  219. bool CanSelectCardCondition(CardSource cardSource)
  220. {
  221. if (cardSource.IsDigimon)
  222. {
  223. return true;
  224. }
  225. return false;
  226. }
  227. bool CanSelectStripableCardCondition(CardSource cardSource)
  228. {
  229. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  230. }
  231. int count()
  232. {
  233. int count = 0;
  234. if (CardEffectCommons.IsExistOnBattleArea(card))
  235. {
  236. count = card.PermanentOfThisCard().DigivolutionCards.Count(isFlipped);
  237. }
  238. return count;
  239. }
  240. bool CanSelectPermanentStripCondition(Permanent permanent)
  241. {
  242. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  243. }
  244. bool CanSelectPermanentBounceCondition(Permanent permanent)
  245. {
  246. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.DigivolutionCards.Count() == 0;
  247. }
  248. bool CanActivateCondition(Hashtable hashtable)
  249. {
  250. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  251. {
  252. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  253. {
  254. return true;
  255. }
  256. }
  257. return false;
  258. }
  259. IEnumerator ActivateCoroutine(Hashtable hashtable)
  260. {
  261. if (CardEffectCommons.IsExistOnBattleArea(card))
  262. {
  263. bool added = false;
  264. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  265. {
  266. List<CardSource> selectedCards = new List<CardSource>();
  267. int maxCount = 1;
  268. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  269. selectCardEffect.SetUp(
  270. canTargetCondition: CanSelectCardCondition,
  271. canTargetCondition_ByPreSelecetedList: null,
  272. canEndSelectCondition: null,
  273. canNoSelect: () => true,
  274. selectCardCoroutine: SelectCardCoroutine,
  275. afterSelectCardCoroutine: null,
  276. message: "Select 1 card to place on bottom of digivolution cards.",
  277. maxCount: maxCount,
  278. canEndNotMax: false,
  279. isShowOpponent: true,
  280. mode: SelectCardEffect.Mode.Custom,
  281. root: SelectCardEffect.Root.Trash,
  282. customRootCardList: null,
  283. canLookReverseCard: true,
  284. selectPlayer: card.Owner,
  285. cardEffect: activateClass);
  286. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  287. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  288. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  289. IEnumerator SelectCardCoroutine(CardSource cardSource)
  290. {
  291. selectedCards.Add(cardSource);
  292. yield return null;
  293. }
  294. if (selectedCards.Count >= 1)
  295. {
  296. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass, isFacedown: true));
  297. added = true;
  298. }
  299. }
  300. if (added)
  301. {
  302. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentStripCondition) && count() > 0)
  303. {
  304. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  305. permanentCondition: CanSelectPermanentStripCondition,
  306. cardCondition: CanSelectStripableCardCondition,
  307. maxCount: count(),
  308. canNoTrash: false,
  309. isFromOnly1Permanent: true,
  310. activateClass: activateClass
  311. ));
  312. }
  313. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentBounceCondition))
  314. {
  315. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  316. selectPermanentEffect1.SetUp(
  317. selectPlayer: card.Owner,
  318. canTargetCondition: CanSelectPermanentBounceCondition,
  319. canTargetCondition_ByPreSelecetedList: null,
  320. canEndSelectCondition: null,
  321. maxCount: 1,
  322. canNoSelect: false,
  323. canEndNotMax: false,
  324. selectPermanentCoroutine: null,
  325. afterSelectPermanentCoroutine: null,
  326. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  327. cardEffect: activateClass);
  328. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  329. }
  330. }
  331. }
  332. }
  333. }
  334. #endregion
  335. #region When Digivolving
  336. if (timing == EffectTiming.OnEnterFieldAnyone)
  337. {
  338. ActivateClass activateClass = new ActivateClass();
  339. activateClass.SetUpICardEffect("By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, from 1 of your opponent's Digimon, trash any 1 digivolution card for each of this Digimon's face-down digivolution cards. Then, return 1 of their Digimon with no digivolution cards to the bottom of the deck.\r\n", CanUseCondition, card);
  340. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  341. cardEffects.Add(activateClass);
  342. string EffectDiscription()
  343. => "[When Digivolving] By placing 1 Digimon card from your trash face down as this Digimon's bottom digivolution card, from 1 of your opponent's Digimon, trash any 1 digivolution card for each of this Digimon's face-down digivolution cards. Then, return 1 of their Digimon with no digivolution cards to the bottom of the deck.\r\n";
  344. bool CanUseCondition(Hashtable hashtable)
  345. {
  346. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  347. {
  348. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  349. {
  350. return true;
  351. }
  352. }
  353. return false;
  354. }
  355. bool isFlipped(CardSource source)
  356. {
  357. return source.IsFlipped;
  358. }
  359. bool CanSelectCardCondition(CardSource cardSource)
  360. {
  361. if (cardSource.IsDigimon)
  362. {
  363. return true;
  364. }
  365. return false;
  366. }
  367. bool CanSelectStripableCardCondition(CardSource cardSource)
  368. {
  369. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  370. }
  371. int count()
  372. {
  373. int count = 0;
  374. if (CardEffectCommons.IsExistOnBattleArea(card))
  375. {
  376. count = card.PermanentOfThisCard().DigivolutionCards.Count(isFlipped);
  377. }
  378. return count;
  379. }
  380. bool CanSelectPermanentStripCondition(Permanent permanent)
  381. {
  382. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  383. }
  384. bool CanSelectPermanentBounceCondition(Permanent permanent)
  385. {
  386. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.DigivolutionCards.Count() == 0;
  387. }
  388. bool CanActivateCondition(Hashtable hashtable)
  389. {
  390. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  391. {
  392. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  393. {
  394. return true;
  395. }
  396. }
  397. return false;
  398. }
  399. IEnumerator ActivateCoroutine(Hashtable hashtable)
  400. {
  401. if (CardEffectCommons.IsExistOnBattleArea(card))
  402. {
  403. bool added = false;
  404. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  405. {
  406. List<CardSource> selectedCards = new List<CardSource>();
  407. int maxCount = 1;
  408. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  409. selectCardEffect.SetUp(
  410. canTargetCondition: CanSelectCardCondition,
  411. canTargetCondition_ByPreSelecetedList: null,
  412. canEndSelectCondition: null,
  413. canNoSelect: () => true,
  414. selectCardCoroutine: SelectCardCoroutine,
  415. afterSelectCardCoroutine: null,
  416. message: "Select 1 card to place on bottom of digivolution cards.",
  417. maxCount: maxCount,
  418. canEndNotMax: false,
  419. isShowOpponent: true,
  420. mode: SelectCardEffect.Mode.Custom,
  421. root: SelectCardEffect.Root.Trash,
  422. customRootCardList: null,
  423. canLookReverseCard: true,
  424. selectPlayer: card.Owner,
  425. cardEffect: activateClass);
  426. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  427. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  428. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  429. IEnumerator SelectCardCoroutine(CardSource cardSource)
  430. {
  431. selectedCards.Add(cardSource);
  432. yield return null;
  433. }
  434. if (selectedCards.Count >= 1)
  435. {
  436. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass, isFacedown: true));
  437. added = true;
  438. }
  439. }
  440. if (added)
  441. {
  442. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentStripCondition) && count() > 0)
  443. {
  444. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  445. permanentCondition: CanSelectPermanentStripCondition,
  446. cardCondition: CanSelectStripableCardCondition,
  447. maxCount: count(),
  448. canNoTrash: false,
  449. isFromOnly1Permanent: true,
  450. activateClass: activateClass
  451. ));
  452. }
  453. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentBounceCondition))
  454. {
  455. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  456. selectPermanentEffect1.SetUp(
  457. selectPlayer: card.Owner,
  458. canTargetCondition: CanSelectPermanentBounceCondition,
  459. canTargetCondition_ByPreSelecetedList: null,
  460. canEndSelectCondition: null,
  461. maxCount: 1,
  462. canNoSelect: false,
  463. canEndNotMax: false,
  464. selectPermanentCoroutine: null,
  465. afterSelectPermanentCoroutine: null,
  466. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  467. cardEffect: activateClass);
  468. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  469. }
  470. }
  471. }
  472. }
  473. }
  474. #endregion
  475. #region End of Turn - ESS
  476. if (timing == EffectTiming.OnEndTurn)
  477. {
  478. ActivateClass activateClass = new ActivateClass();
  479. activateClass.SetUpICardEffect("1 of your Digimon unsuspends.", CanUseCondition, card);
  480. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  481. activateClass.SetIsInheritedEffect(true);
  482. activateClass.SetHashString("ESS_EX8-018");
  483. cardEffects.Add(activateClass);
  484. string EffectDiscription()
  485. {
  486. return "[End of Your Turn] 1 of your Digimon unsuspends.";
  487. }
  488. bool CanUseCondition(Hashtable hashtable)
  489. {
  490. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  491. {
  492. if(CardEffectCommons.IsOwnerTurn(card))
  493. {
  494. return true;
  495. }
  496. }
  497. return false;
  498. }
  499. bool PermanentCondition(Permanent _permanent)
  500. {
  501. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(_permanent, card);
  502. }
  503. bool CanActivateCondition(Hashtable hashtable)
  504. {
  505. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  506. }
  507. IEnumerator ActivateCoroutine(Hashtable hashtable)
  508. {
  509. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  510. selectPermanentEffect.SetUp(
  511. selectPlayer: card.Owner,
  512. canTargetCondition: PermanentCondition,
  513. canTargetCondition_ByPreSelecetedList: null,
  514. canEndSelectCondition: null,
  515. maxCount: 1,
  516. canNoSelect: false,
  517. canEndNotMax: false,
  518. selectPermanentCoroutine: null,
  519. afterSelectPermanentCoroutine: null,
  520. mode: SelectPermanentEffect.Mode.UnTap,
  521. cardEffect: activateClass);
  522. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  523. }
  524. }
  525. #endregion
  526. return cardEffects;
  527. }
  528. }
  529. }