BT17_057.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_057 : 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
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.ContainsTraits("SoC") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region [DigiXros -2] [Machinedramon] x 1 Lv.5 Digimon card w/[Cyborg] trait
  23. if (timing == EffectTiming.None)
  24. {
  25. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  26. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  27. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  28. addDigiXrosConditionClass.SetNotShowUI(true);
  29. cardEffects.Add(addDigiXrosConditionClass);
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return true;
  33. }
  34. DigiXrosCondition GetDigiXros(CardSource cardSource)
  35. {
  36. if (cardSource == card)
  37. {
  38. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Machinedramon");
  39. bool CanSelectCardCondition(CardSource cardSource)
  40. {
  41. if (cardSource != null)
  42. {
  43. if (cardSource.Owner == card.Owner)
  44. {
  45. if (cardSource.IsDigimon)
  46. {
  47. if (cardSource.CardNames_DigiXros.Contains("Machinedramon"))
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "Lv.5 Digimon card w/[Cyborg] trait");
  57. bool CanSelectCardCondition1(CardSource cardSource)
  58. {
  59. if (cardSource != null)
  60. {
  61. if (cardSource.Owner == card.Owner)
  62. {
  63. if (cardSource.IsDigimon)
  64. {
  65. if(cardSource.HasLevel && cardSource.Level == 5)
  66. {
  67. if (cardSource.ContainsTraits("Cyborg"))
  68. {
  69. return true;
  70. }
  71. }
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  78. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  79. return digiXrosCondition;
  80. }
  81. return null;
  82. }
  83. }
  84. if (timing == EffectTiming.None)
  85. {
  86. AddMaxTrashCountDigiXrosClass addMaxTrashCountDigiXrosClass = new AddMaxTrashCountDigiXrosClass();
  87. addMaxTrashCountDigiXrosClass.SetUpICardEffect($"Trash cards can be selected for DigiXros", CanUseCondition, card);
  88. addMaxTrashCountDigiXrosClass.SetUpAddMaxTrashCountDigiXrosClass(getMaxTrashCount: GetCount);
  89. addMaxTrashCountDigiXrosClass.SetNotShowUI(true);
  90. cardEffects.Add(addMaxTrashCountDigiXrosClass);
  91. bool HasTamer(Permanent permanent)
  92. {
  93. if (permanent.IsTamer)
  94. return permanent.TopCard.CardColors.Contains(CardColor.Black);
  95. return false;
  96. }
  97. bool CanUseCondition(Hashtable hashtable)
  98. {
  99. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasTamer);
  100. }
  101. int GetCount(CardSource cardSource)
  102. {
  103. if (cardSource == card)
  104. {
  105. return 100;
  106. }
  107. return 0;
  108. }
  109. }
  110. #endregion
  111. #region On Play/When Digivolving Shared
  112. int maxCost = 7;
  113. bool IsCyborgOrSoC(CardSource source)
  114. {
  115. if (source.ContainsTraits("Cyborg"))
  116. return true;
  117. if (source.HasSocTraits)
  118. return true;
  119. return false;
  120. }
  121. bool CanSelectOpponentsPermanent(Permanent permanent)
  122. {
  123. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  124. {
  125. if (permanent.TopCard.GetCostItself <= maxCost)
  126. {
  127. if (permanent.TopCard.HasPlayCost)
  128. {
  129. return true;
  130. }
  131. }
  132. }
  133. return false;
  134. }
  135. #endregion
  136. #region On Play
  137. if (timing == EffectTiming.OnEnterFieldAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("By placing 1 digivolution source, delete up to 7 play cost", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[On Play] By placing 1 card with the [Cyborg] or [SoC] trait from your trash as this Digimon's bottom digivolution card, delete up to 7 play cost worth of your opponent's Digimon.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  150. {
  151. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  152. {
  153. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsCyborgOrSoC))
  154. return true;
  155. }
  156. }
  157. return false;
  158. }
  159. bool CanActivateCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  162. }
  163. IEnumerator ActivateCoroutine(Hashtable hashtable)
  164. {
  165. bool sourceAdded = false;
  166. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsCyborgOrSoC));
  167. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  168. selectCardEffect.SetUp(
  169. canTargetCondition: IsCyborgOrSoC,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. canNoSelect: () => false,
  173. selectCardCoroutine: SelectCardCoroutine,
  174. afterSelectCardCoroutine: null,
  175. message: "Select 1 card to place at the bottom of digivolution cards.",
  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 at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  186. yield return StartCoroutine(selectCardEffect.Activate());
  187. IEnumerator SelectCardCoroutine(CardSource cardSource)
  188. {
  189. if(cardSource != null)
  190. {
  191. sourceAdded = true;
  192. }
  193. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource> { cardSource }, activateClass));
  194. }
  195. if (sourceAdded)
  196. {
  197. int destroyCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsPermanent);
  198. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  199. selectPermanentEffect.SetUp(
  200. selectPlayer: card.Owner,
  201. canTargetCondition: CanSelectOpponentsPermanent,
  202. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  203. canEndSelectCondition: CanEndSelectCondition,
  204. maxCount: destroyCount,
  205. canNoSelect: false,
  206. canEndNotMax: true,
  207. selectPermanentCoroutine: null,
  208. afterSelectPermanentCoroutine: null,
  209. mode: SelectPermanentEffect.Mode.Destroy,
  210. cardEffect: activateClass);
  211. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  212. bool CanEndSelectCondition(List<Permanent> permanents)
  213. {
  214. if (permanents.Count <= 0)
  215. return false;
  216. int sumCost = 0;
  217. foreach (Permanent permanent1 in permanents)
  218. {
  219. sumCost += permanent1.TopCard.GetCostItself;
  220. }
  221. if (sumCost > maxCost)
  222. return false;
  223. return true;
  224. }
  225. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  226. {
  227. int sumCost = 0;
  228. foreach (Permanent permanent1 in permanents)
  229. {
  230. sumCost += permanent1.TopCard.GetCostItself;
  231. }
  232. sumCost += permanent.TopCard.GetCostItself;
  233. if (sumCost > maxCost)
  234. return false;
  235. return true;
  236. }
  237. }
  238. }
  239. }
  240. #endregion
  241. #region When Digivolving
  242. if (timing == EffectTiming.OnEnterFieldAnyone)
  243. {
  244. ActivateClass activateClass = new ActivateClass();
  245. activateClass.SetUpICardEffect("By placing 1 digivolution source, delete up to 7 play cost", CanUseCondition, card);
  246. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  247. cardEffects.Add(activateClass);
  248. string EffectDiscription()
  249. {
  250. return "[When Digivolving] By placing 1 card with the [Cyborg] or [SoC] trait from your trash as this Digimon's bottom digivolution card, delete up to 7 play cost worth of your opponent's Digimon.";
  251. }
  252. bool CanUseCondition(Hashtable hashtable)
  253. {
  254. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  255. {
  256. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  257. {
  258. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsCyborgOrSoC))
  259. return true;
  260. }
  261. }
  262. return false;
  263. }
  264. bool CanActivateCondition(Hashtable hashtable)
  265. {
  266. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  267. }
  268. IEnumerator ActivateCoroutine(Hashtable hashtable)
  269. {
  270. bool sourceAdded = false;
  271. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsCyborgOrSoC));
  272. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  273. selectCardEffect.SetUp(
  274. canTargetCondition: IsCyborgOrSoC,
  275. canTargetCondition_ByPreSelecetedList: null,
  276. canEndSelectCondition: null,
  277. canNoSelect: () => false,
  278. selectCardCoroutine: SelectCardCoroutine,
  279. afterSelectCardCoroutine: null,
  280. message: "Select 1 card to place at the bottom of digivolution cards.",
  281. maxCount: maxCount,
  282. canEndNotMax: false,
  283. isShowOpponent: true,
  284. mode: SelectCardEffect.Mode.Custom,
  285. root: SelectCardEffect.Root.Trash,
  286. customRootCardList: null,
  287. canLookReverseCard: true,
  288. selectPlayer: card.Owner,
  289. cardEffect: activateClass);
  290. selectCardEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  291. yield return StartCoroutine(selectCardEffect.Activate());
  292. IEnumerator SelectCardCoroutine(CardSource cardSource)
  293. {
  294. if (cardSource != null)
  295. {
  296. sourceAdded = true;
  297. }
  298. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource> { cardSource }, activateClass));
  299. }
  300. if (sourceAdded)
  301. {
  302. int destroyCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsPermanent);
  303. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  304. selectPermanentEffect.SetUp(
  305. selectPlayer: card.Owner,
  306. canTargetCondition: CanSelectOpponentsPermanent,
  307. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  308. canEndSelectCondition: CanEndSelectCondition,
  309. maxCount: destroyCount,
  310. canNoSelect: false,
  311. canEndNotMax: true,
  312. selectPermanentCoroutine: null,
  313. afterSelectPermanentCoroutine: null,
  314. mode: SelectPermanentEffect.Mode.Destroy,
  315. cardEffect: activateClass);
  316. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  317. bool CanEndSelectCondition(List<Permanent> permanents)
  318. {
  319. if (permanents.Count <= 0)
  320. return false;
  321. int sumCost = 0;
  322. foreach (Permanent permanent1 in permanents)
  323. {
  324. sumCost += permanent1.TopCard.GetCostItself;
  325. }
  326. if (sumCost > maxCost)
  327. return false;
  328. return true;
  329. }
  330. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  331. {
  332. int sumCost = 0;
  333. foreach (Permanent permanent1 in permanents)
  334. {
  335. sumCost += permanent1.TopCard.GetCostItself;
  336. }
  337. sumCost += permanent.TopCard.GetCostItself;
  338. if (sumCost > maxCost)
  339. return false;
  340. return true;
  341. }
  342. }
  343. }
  344. }
  345. #endregion
  346. #region All Turns
  347. if (timing == EffectTiming.WhenRemoveField)
  348. {
  349. ActivateClass activateClass = new ActivateClass();
  350. activateClass.SetUpICardEffect("Prevent this Digimon from leaving the battle area", CanUseCondition, card);
  351. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  352. activateClass.SetHashString("Substitute_BT17_057");
  353. cardEffects.Add(activateClass);
  354. string EffectDiscription()
  355. {
  356. return "[All Turns] When this Digimon would leave the battle area by one of your opponent's effects, by trashing 2 cards with the [Machine], [Cyborg] or [SoC] trait from this Digimon's digivolution cards, prevent it from leaving.";
  357. }
  358. bool CanSelectSourceCondition(CardSource cardSource)
  359. {
  360. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  361. {
  362. if (cardSource.ContainsTraits("Machine") || cardSource.ContainsTraits("Cyborg") || cardSource.HasSocTraits)
  363. {
  364. return true;
  365. }
  366. }
  367. return false;
  368. }
  369. bool CanUseCondition(Hashtable hashtable)
  370. {
  371. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  372. {
  373. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  374. {
  375. if(CardEffectCommons.IsByEffect(hashtable, effect => CardEffectCommons.IsOpponentEffect(effect, card)))
  376. return true;
  377. }
  378. }
  379. return false;
  380. }
  381. bool CanActivateCondition(Hashtable hashtable)
  382. {
  383. if (CardEffectCommons.IsExistOnBattleArea(card))
  384. {
  385. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCondition) >= 2)
  386. {
  387. return true;
  388. }
  389. }
  390. return false;
  391. }
  392. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  393. {
  394. if (CardEffectCommons.IsExistOnBattleArea(card))
  395. {
  396. Permanent selectedPermanent = card.PermanentOfThisCard();
  397. if (selectedPermanent.DigivolutionCards.Count(CanSelectSourceCondition) >= 2)
  398. {
  399. List<CardSource> selectedCards = new List<CardSource>();
  400. int maxCount = Math.Min(2, selectedPermanent.DigivolutionCards.Count(CanSelectSourceCondition));
  401. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  402. selectCardEffect.SetUp(
  403. canTargetCondition: CanSelectSourceCondition,
  404. canTargetCondition_ByPreSelecetedList: null,
  405. canEndSelectCondition: null,
  406. canNoSelect: () => true,
  407. selectCardCoroutine: SelectCardCoroutine,
  408. afterSelectCardCoroutine: null,
  409. message: "Select cards to discard.",
  410. maxCount: maxCount,
  411. canEndNotMax: false,
  412. isShowOpponent: true,
  413. mode: SelectCardEffect.Mode.Custom,
  414. root: SelectCardEffect.Root.Custom,
  415. customRootCardList: selectedPermanent.DigivolutionCards,
  416. canLookReverseCard: true,
  417. selectPlayer: card.Owner,
  418. cardEffect: activateClass);
  419. selectCardEffect.SetNotShowCard();
  420. yield return StartCoroutine(selectCardEffect.Activate());
  421. IEnumerator SelectCardCoroutine(CardSource cardSource)
  422. {
  423. selectedCards.Add(cardSource);
  424. yield return null;
  425. }
  426. if (selectedCards.Count >= 1)
  427. {
  428. if (selectedCards.Count == 2)
  429. {
  430. selectedPermanent.willBeRemoveField = false;
  431. selectedPermanent.HideDeleteEffect();
  432. selectedPermanent.HideHandBounceEffect();
  433. selectedPermanent.HideDeckBounceEffect();
  434. }
  435. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(selectedPermanent, selectedCards, activateClass).TrashDigivolutionCards());
  436. }
  437. }
  438. }
  439. }
  440. }
  441. #endregion
  442. return cardEffects;
  443. }
  444. }
  445. }