BT17_027.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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_027 : 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("Garurumon");
  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("Matt Ishida") ||
  51. permanent.TopCard.ContainsCardName("MattIshida"));
  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("Agumon"))
  100. {
  101. return true;
  102. }
  103. }
  104. return false;
  105. }
  106. bool CanSelectHandCardSharedCondition(CardSource cardSource)
  107. {
  108. return cardSource.IsDigimon && cardSource.EqualsCardName("WarGreymon");
  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: ・1 of your opponent's Digimon or Tamers can't suspend until the end of their turn. ・1 of your [Agumon] may digivolve into [WarGreymon] 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.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  130. {
  131. return permanent.IsDigimon || permanent.IsTamer;
  132. }
  133. return false;
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.IsExistOnBattleArea(card))
  138. {
  139. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  140. {
  141. return true;
  142. }
  143. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentSharedCondition) &&
  144. card.Owner.HandCards.Count(CanSelectHandCardSharedCondition) >= 1)
  145. {
  146. return true;
  147. }
  148. }
  149. return CardEffectCommons.IsExistOnBattleArea(card);
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.IsExistOnBattleArea(card))
  154. {
  155. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  156. {
  157. new(message: "1 of your opponent's Digimon or Tamers can't suspend until the end of their turn. ",
  158. value: 0, spriteIndex: 0),
  159. new(
  160. message: "1 of your [Agumon] may digivolve into [WarGreymon] in your hand",
  161. value: 1, spriteIndex: 0),
  162. };
  163. string selectPlayerMessage = "Which effect will you activate?";
  164. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  165. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  166. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  167. notSelectPlayerMessage: notSelectPlayerMessage);
  168. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  169. .WaitForEndSelect());
  170. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  171. switch (actionID)
  172. {
  173. case 0:
  174. {
  175. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentPermanentCondition))
  176. {
  177. int maxCount = Math.Min(1,
  178. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  179. SelectPermanentEffect selectPermanentEffect =
  180. GManager.instance.GetComponent<SelectPermanentEffect>();
  181. selectPermanentEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canTargetCondition: CanSelectOpponentPermanentCondition,
  185. canEndSelectCondition: null,
  186. maxCount: maxCount,
  187. canNoSelect: false,
  188. canEndNotMax: false,
  189. selectPermanentCoroutine: SelectPermanentCoroutine,
  190. afterSelectPermanentCoroutine: null,
  191. mode: SelectPermanentEffect.Mode.Custom,
  192. cardEffect: activateClass);
  193. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer that will be unable to suspend.",
  194. "The opponent is selecting 1 Digimon/Tamer that will be unable to suspend.");
  195. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  196. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  197. {
  198. Permanent selectedPermanent = permanent;
  199. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  200. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCanNotSuspendCondition, card);
  201. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCanNotSuspendCondition);
  202. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => canNotSuspendClass);
  203. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  204. {
  205. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  206. .GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  207. }
  208. bool CanUseCanNotSuspendCondition(Hashtable hashtableCanNotSuspend)
  209. {
  210. if (selectedPermanent.TopCard != null)
  211. {
  212. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  213. {
  214. return true;
  215. }
  216. }
  217. return false;
  218. }
  219. bool PermanentCanNotSuspendCondition(Permanent permanentCanNotSuspend)
  220. {
  221. if (permanentCanNotSuspend == selectedPermanent)
  222. {
  223. return true;
  224. }
  225. return false;
  226. }
  227. }
  228. }
  229. break;
  230. }
  231. case 1:
  232. {
  233. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentSharedCondition) &&
  234. card.Owner.HandCards.Count(CanSelectHandCardSharedCondition) >= 1)
  235. {
  236. Permanent selectedPermanent = null;
  237. int maxCount = Math.Min(1,
  238. CardEffectCommons.MatchConditionPermanentCount(CanSelectOwnPermanentSharedCondition));
  239. SelectPermanentEffect selectPermanentEffect =
  240. GManager.instance.GetComponent<SelectPermanentEffect>();
  241. selectPermanentEffect.SetUp(
  242. selectPlayer: card.Owner,
  243. canTargetCondition: CanSelectOwnPermanentSharedCondition,
  244. canTargetCondition_ByPreSelecetedList: null,
  245. canEndSelectCondition: null,
  246. maxCount: maxCount,
  247. canNoSelect: true,
  248. canEndNotMax: false,
  249. selectPermanentCoroutine: SelectPermanentCoroutine,
  250. afterSelectPermanentCoroutine: null,
  251. mode: SelectPermanentEffect.Mode.Custom,
  252. cardEffect: activateClass);
  253. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  254. "The opponent is selecting 1 Digimon that will digivolve.");
  255. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  256. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  257. {
  258. selectedPermanent = permanent;
  259. yield return null;
  260. }
  261. if (selectedPermanent != null)
  262. {
  263. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  264. targetPermanent: selectedPermanent,
  265. cardCondition: CanSelectHandCardSharedCondition,
  266. payCost: false,
  267. reduceCostTuple: null,
  268. fixedCostTuple: null,
  269. ignoreDigivolutionRequirementFixedCost: 0,
  270. isHand: true,
  271. activateClass: activateClass,
  272. successProcess: null));
  273. }
  274. }
  275. break;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. #endregion
  282. #region When Digivolving
  283. if (timing == EffectTiming.OnEnterFieldAnyone)
  284. {
  285. ActivateClass activateClass = new ActivateClass();
  286. activateClass.SetUpICardEffect("Choose 1 effect", CanUseCondition, card);
  287. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  288. cardEffects.Add(activateClass);
  289. string EffectDescription()
  290. {
  291. return
  292. "[When Digivolving] Activate 1 of the effects below: ・1 of your opponent's Digimon or Tamers can't suspend until the end of their turn. ・1 of your [Agumon] may digivolve into [WarGreymon] in your hand, ignoring its digivolution requirements and without paying the cost.";
  293. }
  294. bool CanUseCondition(Hashtable hashtable)
  295. {
  296. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  297. }
  298. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  299. {
  300. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  301. {
  302. return permanent.IsDigimon || permanent.IsTamer;
  303. }
  304. return false;
  305. }
  306. bool CanActivateCondition(Hashtable hashtable)
  307. {
  308. if (CardEffectCommons.IsExistOnBattleArea(card))
  309. {
  310. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  311. {
  312. return true;
  313. }
  314. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentSharedCondition) &&
  315. card.Owner.HandCards.Count(CanSelectHandCardSharedCondition) >= 1)
  316. {
  317. return true;
  318. }
  319. }
  320. return CardEffectCommons.IsExistOnBattleArea(card);
  321. }
  322. IEnumerator ActivateCoroutine(Hashtable hashtable)
  323. {
  324. if (CardEffectCommons.IsExistOnBattleArea(card))
  325. {
  326. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  327. {
  328. new(message: "1 of your opponent's Digimon or Tamers can't suspend until the end of their turn. ",
  329. value: 0, spriteIndex: 0),
  330. new(
  331. message: "1 of your [Agumon] may digivolve into [WarGreymon] in your hand",
  332. value: 1, spriteIndex: 0),
  333. };
  334. string selectPlayerMessage = "Which effect will you activate?";
  335. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  336. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  337. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  338. notSelectPlayerMessage: notSelectPlayerMessage);
  339. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  340. .WaitForEndSelect());
  341. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  342. switch (actionID)
  343. {
  344. case 0:
  345. {
  346. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentPermanentCondition))
  347. {
  348. int maxCount = Math.Min(1,
  349. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  350. SelectPermanentEffect selectPermanentEffect =
  351. GManager.instance.GetComponent<SelectPermanentEffect>();
  352. selectPermanentEffect.SetUp(
  353. selectPlayer: card.Owner,
  354. canTargetCondition_ByPreSelecetedList: null,
  355. canTargetCondition: CanSelectOpponentPermanentCondition,
  356. canEndSelectCondition: null,
  357. maxCount: maxCount,
  358. canNoSelect: false,
  359. canEndNotMax: false,
  360. selectPermanentCoroutine: SelectPermanentCoroutine,
  361. afterSelectPermanentCoroutine: null,
  362. mode: SelectPermanentEffect.Mode.Custom,
  363. cardEffect: activateClass);
  364. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer that will be unable to suspend.",
  365. "The opponent is selecting 1 Digimon/Tamer that will be unable to suspend.");
  366. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  367. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  368. {
  369. Permanent selectedPermanent = permanent;
  370. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  371. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCanNotSuspendCondition, card);
  372. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCanNotSuspendCondition);
  373. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => canNotSuspendClass);
  374. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  375. {
  376. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  377. .GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  378. }
  379. bool CanUseCanNotSuspendCondition(Hashtable hashtableCanNotSuspend)
  380. {
  381. if (selectedPermanent.TopCard != null)
  382. {
  383. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  384. {
  385. return true;
  386. }
  387. }
  388. return false;
  389. }
  390. bool PermanentCanNotSuspendCondition(Permanent permanentCanNotSuspend)
  391. {
  392. if (permanentCanNotSuspend == selectedPermanent)
  393. {
  394. return true;
  395. }
  396. return false;
  397. }
  398. }
  399. }
  400. break;
  401. }
  402. case 1:
  403. {
  404. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentSharedCondition) &&
  405. card.Owner.HandCards.Count(CanSelectHandCardSharedCondition) >= 1)
  406. {
  407. Permanent selectedPermanent = null;
  408. int maxCount = Math.Min(1,
  409. CardEffectCommons.MatchConditionPermanentCount(CanSelectOwnPermanentSharedCondition));
  410. SelectPermanentEffect selectPermanentEffect =
  411. GManager.instance.GetComponent<SelectPermanentEffect>();
  412. selectPermanentEffect.SetUp(
  413. selectPlayer: card.Owner,
  414. canTargetCondition: CanSelectOwnPermanentSharedCondition,
  415. canTargetCondition_ByPreSelecetedList: null,
  416. canEndSelectCondition: null,
  417. maxCount: maxCount,
  418. canNoSelect: true,
  419. canEndNotMax: false,
  420. selectPermanentCoroutine: SelectPermanentCoroutine,
  421. afterSelectPermanentCoroutine: null,
  422. mode: SelectPermanentEffect.Mode.Custom,
  423. cardEffect: activateClass);
  424. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  425. "The opponent is selecting 1 Digimon that will digivolve.");
  426. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  427. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  428. {
  429. selectedPermanent = permanent;
  430. yield return null;
  431. }
  432. if (selectedPermanent != null)
  433. {
  434. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  435. targetPermanent: selectedPermanent,
  436. cardCondition: CanSelectHandCardSharedCondition,
  437. payCost: false,
  438. reduceCostTuple: null,
  439. fixedCostTuple: null,
  440. ignoreDigivolutionRequirementFixedCost: 0,
  441. isHand: true,
  442. activateClass: activateClass,
  443. successProcess: null));
  444. }
  445. }
  446. break;
  447. }
  448. }
  449. }
  450. }
  451. }
  452. #endregion
  453. #region When Attacking - ESS
  454. if (timing == EffectTiming.OnAllyAttack)
  455. {
  456. ActivateClass activateClass = new ActivateClass();
  457. activateClass.SetUpICardEffect("Unsuspend", CanUseCondition, card);
  458. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  459. activateClass.SetIsInheritedEffect(true);
  460. activateClass.SetHashString("Unsuspend_BT17-027");
  461. cardEffects.Add(activateClass);
  462. string EffectDescription()
  463. {
  464. return
  465. "[When Attacking][Once Per Turn] If this Digimon has [Omnimon] in its name, unsuspend this Digimon.";
  466. }
  467. bool CanUseCondition(Hashtable hashtable)
  468. {
  469. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  470. }
  471. bool CanActivateCondition(Hashtable hashtable)
  472. {
  473. if (CardEffectCommons.IsExistOnBattleArea(card))
  474. {
  475. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"))
  476. {
  477. return true;
  478. }
  479. }
  480. return false;
  481. }
  482. IEnumerator ActivateCoroutine(Hashtable hashtable)
  483. {
  484. yield return ContinuousController.instance.StartCoroutine(
  485. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() },
  486. activateClass).Unsuspend());
  487. }
  488. }
  489. #endregion
  490. return cardEffects;
  491. }
  492. }
  493. }