BT17_027.cs 29 KB

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