BT17_015.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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_015 : 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. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.ContainsCardName("Greymon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Play Cost Reduction
  29. if (timing == EffectTiming.None)
  30. {
  31. ChangeCostClass changeCostClass = new ChangeCostClass();
  32. changeCostClass.SetUpICardEffect($"Play Cost -3", CanUseCondition, card);
  33. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost,
  34. cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: IsUpDown,
  35. isCheckAvailability: () => false, isChangePayingCost: () => true);
  36. cardEffects.Add(changeCostClass);
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. if (card.Owner.HandCards.Contains(card))
  40. {
  41. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCorrectTamer))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool IsCorrectTamer(Permanent permanent)
  49. {
  50. return permanent.IsTamer && (permanent.TopCard.ContainsCardName("Tai Kamiya") ||
  51. permanent.TopCard.ContainsCardName("TaiKamiya"));
  52. }
  53. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  54. List<Permanent> targetPermanents)
  55. {
  56. if (CardSourceCondition(cardSource))
  57. {
  58. if (RootCondition(root))
  59. {
  60. if (PermanentsCondition(targetPermanents))
  61. {
  62. cost -= 3;
  63. }
  64. }
  65. }
  66. return cost;
  67. }
  68. bool PermanentsCondition(List<Permanent> targetPermanents)
  69. {
  70. if (targetPermanents == null)
  71. {
  72. return true;
  73. }
  74. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  75. {
  76. return true;
  77. }
  78. return false;
  79. }
  80. bool CardSourceCondition(CardSource cardSource)
  81. {
  82. return cardSource == card;
  83. }
  84. bool RootCondition(SelectCardEffect.Root root)
  85. {
  86. return true;
  87. }
  88. bool IsUpDown()
  89. {
  90. return true;
  91. }
  92. }
  93. #endregion
  94. #region On Play/ When Digivolving Shared
  95. bool CanSelectOwnPermanentSharedCondition(Permanent permanent)
  96. {
  97. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  98. {
  99. if (permanent.TopCard.EqualsCardName("Gabumon"))
  100. {
  101. return true;
  102. }
  103. }
  104. return false;
  105. }
  106. bool CanSelectHandCardSharedCondition(CardSource cardSource)
  107. {
  108. return cardSource.IsDigimon && cardSource.EqualsCardName("MetalGarurumon");
  109. }
  110. #endregion
  111. #region On Play
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Choose 1 effect", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  117. cardEffects.Add(activateClass);
  118. string EffectDescription()
  119. {
  120. return
  121. "[On Play] Activate 1 of the effects below: ・Delete 1 of your opponent's Digimon with 8000 DP or less. ・1 of your [Gabumon] may digivolve into [MetalGarurumon] in your hand, ignoring its digivolution requirements and without paying the cost.";
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  126. }
  127. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  128. {
  129. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  130. {
  131. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  132. {
  133. return true;
  134. }
  135. }
  136. return false;
  137. }
  138. bool CanActivateCondition(Hashtable hashtable)
  139. {
  140. if (CardEffectCommons.IsExistOnBattleArea(card))
  141. {
  142. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  143. {
  144. return true;
  145. }
  146. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentSharedCondition) &&
  147. card.Owner.HandCards.Count(CanSelectHandCardSharedCondition) >= 1)
  148. {
  149. return true;
  150. }
  151. }
  152. return CardEffectCommons.IsExistOnBattleArea(card);
  153. }
  154. IEnumerator ActivateCoroutine(Hashtable hashtable)
  155. {
  156. if (CardEffectCommons.IsExistOnBattleArea(card))
  157. {
  158. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  159. {
  160. new(message: "Delete 1 of your opponent's Digimon with 8000 DP or less",
  161. value: 0, spriteIndex: 0),
  162. new(
  163. message: "1 of your [Gabumon] may digivolve into [MetalGarurumon] in your hand",
  164. value: 1, spriteIndex: 0),
  165. };
  166. string selectPlayerMessage = "Which effect will you activate?";
  167. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  168. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  169. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  170. notSelectPlayerMessage: notSelectPlayerMessage);
  171. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  172. .WaitForEndSelect());
  173. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  174. switch (actionID)
  175. {
  176. case 0:
  177. {
  178. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  179. {
  180. int maxCount = Math.Min(1,
  181. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  182. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  183. selectPermanentEffect.SetUp(
  184. selectPlayer: card.Owner,
  185. canTargetCondition: CanSelectOpponentPermanentCondition,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. maxCount: maxCount,
  189. canNoSelect: false,
  190. canEndNotMax: false,
  191. selectPermanentCoroutine: null,
  192. afterSelectPermanentCoroutine: null,
  193. mode: SelectPermanentEffect.Mode.Destroy,
  194. cardEffect: activateClass);
  195. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  196. }
  197. break;
  198. }
  199. case 1:
  200. {
  201. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentSharedCondition) &&
  202. card.Owner.HandCards.Count(CanSelectHandCardSharedCondition) >= 1)
  203. {
  204. Permanent selectedPermanent = null;
  205. int maxCount = Math.Min(1,
  206. CardEffectCommons.MatchConditionPermanentCount(CanSelectOwnPermanentSharedCondition));
  207. SelectPermanentEffect selectPermanentEffect =
  208. GManager.instance.GetComponent<SelectPermanentEffect>();
  209. selectPermanentEffect.SetUp(
  210. selectPlayer: card.Owner,
  211. canTargetCondition: CanSelectOwnPermanentSharedCondition,
  212. canTargetCondition_ByPreSelecetedList: null,
  213. canEndSelectCondition: null,
  214. maxCount: maxCount,
  215. canNoSelect: true,
  216. canEndNotMax: false,
  217. selectPermanentCoroutine: SelectPermanentCoroutine,
  218. afterSelectPermanentCoroutine: null,
  219. mode: SelectPermanentEffect.Mode.Custom,
  220. cardEffect: activateClass);
  221. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  222. "The opponent is selecting 1 Digimon that will digivolve.");
  223. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  224. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  225. {
  226. selectedPermanent = permanent;
  227. yield return null;
  228. }
  229. if (selectedPermanent != null)
  230. {
  231. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  232. targetPermanent: selectedPermanent,
  233. cardCondition: CanSelectHandCardSharedCondition,
  234. payCost: false,
  235. reduceCostTuple: null,
  236. fixedCostTuple: null,
  237. ignoreDigivolutionRequirementFixedCost: 0,
  238. isHand: true,
  239. activateClass: activateClass,
  240. successProcess: null));
  241. }
  242. }
  243. break;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. #endregion
  250. #region When Digivolving
  251. if (timing == EffectTiming.OnEnterFieldAnyone)
  252. {
  253. ActivateClass activateClass = new ActivateClass();
  254. activateClass.SetUpICardEffect("Choose 1 effect", CanUseCondition, card);
  255. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  256. cardEffects.Add(activateClass);
  257. string EffectDescription()
  258. {
  259. return
  260. "[When Digivolving] Activate 1 of the effects below: ・Delete 1 of your opponent's Digimon with 8000 DP or less. ・1 of your [Gabumon] may digivolve into [MetalGarurumon] in your hand, ignoring its digivolution requirements and without paying the cost.";
  261. }
  262. bool CanUseCondition(Hashtable hashtable)
  263. {
  264. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  265. }
  266. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  267. {
  268. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  269. {
  270. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  271. {
  272. return true;
  273. }
  274. }
  275. return false;
  276. }
  277. bool CanActivateCondition(Hashtable hashtable)
  278. {
  279. if (CardEffectCommons.IsExistOnBattleArea(card))
  280. {
  281. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  282. {
  283. return true;
  284. }
  285. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentSharedCondition) &&
  286. card.Owner.HandCards.Count(CanSelectHandCardSharedCondition) >= 1)
  287. {
  288. return true;
  289. }
  290. }
  291. return CardEffectCommons.IsExistOnBattleArea(card);
  292. }
  293. IEnumerator ActivateCoroutine(Hashtable hashtable)
  294. {
  295. if (CardEffectCommons.IsExistOnBattleArea(card))
  296. {
  297. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  298. {
  299. new(message: "Delete 1 of your opponent's Digimon with 8000 DP or less",
  300. value: 0, spriteIndex: 0),
  301. new(
  302. message: "1 of your [Gabumon] may digivolve into [MetalGarurumon] in your hand",
  303. value: 1, spriteIndex: 0),
  304. };
  305. string selectPlayerMessage = "Which effect will you activate?";
  306. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  307. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  308. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  309. notSelectPlayerMessage: notSelectPlayerMessage);
  310. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  311. .WaitForEndSelect());
  312. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  313. switch (actionID)
  314. {
  315. case 0:
  316. {
  317. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  318. {
  319. int maxCount = Math.Min(1,
  320. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  321. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  322. selectPermanentEffect.SetUp(
  323. selectPlayer: card.Owner,
  324. canTargetCondition: CanSelectOpponentPermanentCondition,
  325. canTargetCondition_ByPreSelecetedList: null,
  326. canEndSelectCondition: null,
  327. maxCount: maxCount,
  328. canNoSelect: false,
  329. canEndNotMax: false,
  330. selectPermanentCoroutine: null,
  331. afterSelectPermanentCoroutine: null,
  332. mode: SelectPermanentEffect.Mode.Destroy,
  333. cardEffect: activateClass);
  334. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  335. }
  336. break;
  337. }
  338. case 1:
  339. {
  340. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentSharedCondition) &&
  341. card.Owner.HandCards.Count(CanSelectHandCardSharedCondition) >= 1)
  342. {
  343. Permanent selectedPermanent = null;
  344. int maxCount = Math.Min(1,
  345. CardEffectCommons.MatchConditionPermanentCount(CanSelectOwnPermanentSharedCondition));
  346. SelectPermanentEffect selectPermanentEffect =
  347. GManager.instance.GetComponent<SelectPermanentEffect>();
  348. selectPermanentEffect.SetUp(
  349. selectPlayer: card.Owner,
  350. canTargetCondition: CanSelectOwnPermanentSharedCondition,
  351. canTargetCondition_ByPreSelecetedList: null,
  352. canEndSelectCondition: null,
  353. maxCount: maxCount,
  354. canNoSelect: true,
  355. canEndNotMax: false,
  356. selectPermanentCoroutine: SelectPermanentCoroutine,
  357. afterSelectPermanentCoroutine: null,
  358. mode: SelectPermanentEffect.Mode.Custom,
  359. cardEffect: activateClass);
  360. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  361. "The opponent is selecting 1 Digimon that will digivolve.");
  362. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  363. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  364. {
  365. selectedPermanent = permanent;
  366. yield return null;
  367. }
  368. if (selectedPermanent != null)
  369. {
  370. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  371. targetPermanent: selectedPermanent,
  372. cardCondition: CanSelectHandCardSharedCondition,
  373. payCost: false,
  374. reduceCostTuple: null,
  375. fixedCostTuple: null,
  376. ignoreDigivolutionRequirementFixedCost: 0,
  377. isHand: true,
  378. activateClass: activateClass,
  379. successProcess: null));
  380. }
  381. }
  382. break;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. #endregion
  389. #region When Attacking - ESS
  390. if (timing == EffectTiming.OnAllyAttack)
  391. {
  392. ActivateClass activateClass = new ActivateClass();
  393. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  394. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  395. activateClass.SetIsInheritedEffect(true);
  396. activateClass.SetHashString("ESS_BT17_015");
  397. cardEffects.Add(activateClass);
  398. string EffectDescription()
  399. {
  400. return
  401. "[When Attacking][Once Per Turn] If this Digimon has [Omnimon] in its name, trash the top card of your opponent's security stack.";
  402. }
  403. bool CanUseCondition(Hashtable hashtable)
  404. {
  405. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  406. }
  407. bool CanActivateCondition(Hashtable hashtable)
  408. {
  409. if (CardEffectCommons.IsExistOnBattleArea(card))
  410. {
  411. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"))
  412. {
  413. return true;
  414. }
  415. }
  416. return false;
  417. }
  418. IEnumerator ActivateCoroutine(Hashtable hashtable)
  419. {
  420. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  421. player: card.Owner.Enemy,
  422. destroySecurityCount: 1,
  423. cardEffect: activateClass,
  424. fromTop: true).DestroySecurity());
  425. }
  426. }
  427. #endregion
  428. return cardEffects;
  429. }
  430. }
  431. }