BT19_038.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT19
  4. {
  5. public class BT19_038 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alternate Digivolution
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4 &&
  16. targetPermanent.TopCard.EqualsTraits("Xros Heart");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  19. digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region DigiXros name
  23. if (timing == EffectTiming.None)
  24. {
  25. ChangeCardNamesForDigiXrosClass changeCardNamesForDigiXrosClass = new ChangeCardNamesForDigiXrosClass();
  26. changeCardNamesForDigiXrosClass.SetUpICardEffect("Also treated as [Dorulumon] for a DigiXros", CanUseCondition, card);
  27. changeCardNamesForDigiXrosClass.SetUpChangeCardNamesForDigiXrosClass(changeCardNames: ChangeCardNames);
  28. cardEffects.Add(changeCardNamesForDigiXrosClass);
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return true;
  32. }
  33. List<string> ChangeCardNames(CardSource cardSource, List<string> cardNames)
  34. {
  35. if (cardSource == card)
  36. {
  37. cardNames.Add("Dorulumon");
  38. }
  39. return cardNames;
  40. }
  41. }
  42. #endregion
  43. #region On Play/ When Digivolving Shared
  44. bool CanSelectPermanentConditionShared(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  47. }
  48. bool CanActivateConditionShared(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  51. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared);
  52. }
  53. #endregion
  54. #region On Play
  55. if (timing == EffectTiming.OnEnterFieldAnyone)
  56. {
  57. ActivateClass activateClass = new ActivateClass();
  58. activateClass.SetUpICardEffect("Suspend 1 Digimon and 1 Digimon cannot activate [When Digivolving] effects or unsuspend",
  59. CanUseCondition, card);
  60. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, 1, false, EffectDescription());
  61. cardEffects.Add(activateClass);
  62. string EffectDescription()
  63. {
  64. return
  65. "[On Play] Suspend 1 of your opponent's Digimon. Then, 1 of their Digimon can't activate [When Digivolving] effects or unsuspend until the end of their turn.";
  66. }
  67. bool CanUseCondition(Hashtable hashtable)
  68. {
  69. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable hashtable)
  72. {
  73. Permanent selectedPermanent = null;
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentConditionShared,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: 1,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: null,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Tap,
  86. cardEffect: activateClass);
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentConditionShared,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: 1,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: SelectPermanentCoroutine,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Custom,
  99. cardEffect: activateClass);
  100. selectPermanentEffect.SetUpCustomMessage(
  101. "Select 1 Digimon that will be unable to activate [When Digivolving] effects or unsuspend.",
  102. "The opponent is selecting 1 Digimon that will be unable to activate [When Digivolving] effects or unsuspend.");
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  105. {
  106. selectedPermanent = permanent;
  107. yield return null;
  108. }
  109. if (selectedPermanent != null)
  110. {
  111. DisableEffectClass invalidationClass = new DisableEffectClass();
  112. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseConditionDebuff, card);
  113. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  114. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => invalidationClass);
  115. bool CanUseConditionDebuff(Hashtable hashtableDebuff)
  116. {
  117. return true;
  118. }
  119. bool InvalidateCondition(ICardEffect cardEffect)
  120. {
  121. if (selectedPermanent.TopCard != null)
  122. {
  123. if (cardEffect != null)
  124. {
  125. if (cardEffect.EffectSourceCard != null)
  126. {
  127. if (isExistOnField(cardEffect.EffectSourceCard))
  128. {
  129. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  130. {
  131. if (cardEffect.IsWhenDigivolving)
  132. {
  133. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  134. {
  135. return true;
  136. }
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. return false;
  144. }
  145. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  146. targetPermanent: selectedPermanent,
  147. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  148. activateClass: activateClass,
  149. condition: null,
  150. effectName: "Can't unsuspend"
  151. ));
  152. }
  153. }
  154. }
  155. #endregion
  156. #region When Digivolving
  157. if (timing == EffectTiming.OnEnterFieldAnyone)
  158. {
  159. ActivateClass activateClass = new ActivateClass();
  160. activateClass.SetUpICardEffect("Suspend 1 Digimon and 1 Digimon cannot activate [When Digivolving] effects or unsuspend",
  161. CanUseCondition, card);
  162. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, 1, false, EffectDescription());
  163. cardEffects.Add(activateClass);
  164. string EffectDescription()
  165. {
  166. return
  167. "[When Digivolving] Suspend 1 of your opponent's Digimon. Then, 1 of their Digimon can't activate [When Digivolving] effects or unsuspend until the end of their turn.";
  168. }
  169. bool CanUseCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  172. }
  173. IEnumerator ActivateCoroutine(Hashtable hashtable)
  174. {
  175. Permanent selectedPermanent = null;
  176. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  177. selectPermanentEffect.SetUp(
  178. selectPlayer: card.Owner,
  179. canTargetCondition: CanSelectPermanentConditionShared,
  180. canTargetCondition_ByPreSelecetedList: null,
  181. canEndSelectCondition: null,
  182. maxCount: 1,
  183. canNoSelect: false,
  184. canEndNotMax: false,
  185. selectPermanentCoroutine: null,
  186. afterSelectPermanentCoroutine: null,
  187. mode: SelectPermanentEffect.Mode.Tap,
  188. cardEffect: activateClass);
  189. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  190. selectPermanentEffect.SetUp(
  191. selectPlayer: card.Owner,
  192. canTargetCondition: CanSelectPermanentConditionShared,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. maxCount: 1,
  196. canNoSelect: false,
  197. canEndNotMax: false,
  198. selectPermanentCoroutine: SelectPermanentCoroutine,
  199. afterSelectPermanentCoroutine: null,
  200. mode: SelectPermanentEffect.Mode.Custom,
  201. cardEffect: activateClass);
  202. selectPermanentEffect.SetUpCustomMessage(
  203. "Select 1 Digimon that will be unable to activate [When Digivolving] effects or unsuspend.",
  204. "The opponent is selecting 1 Digimon that will be unable to activate [When Digivolving] effects or unsuspend.");
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  206. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  207. {
  208. selectedPermanent = permanent;
  209. yield return null;
  210. }
  211. if (selectedPermanent != null)
  212. {
  213. DisableEffectClass invalidationClass = new DisableEffectClass();
  214. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseConditionDebuff, card);
  215. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  216. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => invalidationClass);
  217. bool CanUseConditionDebuff(Hashtable hashtableDebuff)
  218. {
  219. return true;
  220. }
  221. bool InvalidateCondition(ICardEffect cardEffect)
  222. {
  223. if (selectedPermanent.TopCard != null)
  224. {
  225. if (cardEffect != null)
  226. {
  227. if (cardEffect.EffectSourceCard != null)
  228. {
  229. if (isExistOnField(cardEffect.EffectSourceCard))
  230. {
  231. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  232. {
  233. if (cardEffect.IsWhenDigivolving)
  234. {
  235. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  236. {
  237. return true;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. return false;
  246. }
  247. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  248. targetPermanent: selectedPermanent,
  249. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  250. activateClass: activateClass,
  251. condition: null,
  252. effectName: "Can't unsuspend"
  253. ));
  254. }
  255. }
  256. }
  257. #endregion
  258. #region On Deletion
  259. if (timing == EffectTiming.OnDestroyedAnyone)
  260. {
  261. ActivateClass activateClass = new ActivateClass();
  262. activateClass.SetUpICardEffect("Place 1 [Xros Heart]/[Blue Flare] card from trash under 1 of your Tamers, then <Save>",
  263. CanUseCondition,
  264. card);
  265. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  266. cardEffects.Add(activateClass);
  267. string EffectDescription()
  268. {
  269. return
  270. "[On Deletion] Place 1 Digimon card with the [Xros Heart]/[Blue Flare] trait from your hand or trash under your Tamers.";
  271. }
  272. bool CanUseCondition(Hashtable hashtable)
  273. {
  274. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  275. }
  276. bool IsOwnTamerCondition(Permanent permanent)
  277. {
  278. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  279. && permanent.IsTamer;
  280. }
  281. bool HasTraitCondition(CardSource cardSource)
  282. {
  283. return cardSource.IsDigimon && (cardSource.EqualsTraits("Xros Heart") || cardSource.EqualsTraits("Blue Flare"));
  284. }
  285. bool CanActivateCondition(Hashtable hashtable)
  286. {
  287. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  288. CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsOwnTamerCondition) &&
  289. (CardEffectCommons.HasMatchConditionOwnersHand(card, HasTraitCondition) ||
  290. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasTraitCondition));
  291. }
  292. IEnumerator ActivateCoroutine(Hashtable hashtable)
  293. {
  294. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, HasTraitCondition);
  295. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasTraitCondition);
  296. if (canSelectHand || canSelectTrash)
  297. {
  298. if (canSelectHand && canSelectTrash)
  299. {
  300. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  301. {
  302. new(message: "From hand", value: true, spriteIndex: 0),
  303. new(message: "From trash", value: false, spriteIndex: 1),
  304. };
  305. string selectPlayerMessage = "From which area do you play a card?";
  306. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  307. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  308. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  309. notSelectPlayerMessage: notSelectPlayerMessage);
  310. }
  311. else
  312. {
  313. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  314. }
  315. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  316. .WaitForEndSelect());
  317. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  318. List<CardSource> selectedCards = new List<CardSource>();
  319. IEnumerator SelectCardCoroutine(CardSource cardSource)
  320. {
  321. selectedCards.Add(cardSource);
  322. yield return null;
  323. }
  324. if (fromHand)
  325. {
  326. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  327. selectHandEffect.SetUp(
  328. selectPlayer: card.Owner,
  329. canTargetCondition: HasTraitCondition,
  330. canTargetCondition_ByPreSelecetedList: null,
  331. canEndSelectCondition: null,
  332. maxCount: 1,
  333. canNoSelect: false,
  334. canEndNotMax: false,
  335. isShowOpponent: true,
  336. selectCardCoroutine: SelectCardCoroutine,
  337. afterSelectCardCoroutine: null,
  338. mode: SelectHandEffect.Mode.Custom,
  339. cardEffect: activateClass);
  340. selectHandEffect.SetUpCustomMessage("Select 1 card to place under a tamer.",
  341. "The opponent is selecting 1 card to play.");
  342. selectHandEffect.SetUpCustomMessage_ShowCard("Placed card");
  343. yield return StartCoroutine(selectHandEffect.Activate());
  344. }
  345. else
  346. {
  347. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  348. selectCardEffect.SetUp(
  349. canTargetCondition: HasTraitCondition,
  350. canTargetCondition_ByPreSelecetedList: null,
  351. canEndSelectCondition: null,
  352. canNoSelect: () => false,
  353. selectCardCoroutine: SelectCardCoroutine,
  354. afterSelectCardCoroutine: null,
  355. message: "Select 1 card to place under a tamer.",
  356. maxCount: 1,
  357. canEndNotMax: false,
  358. isShowOpponent: true,
  359. mode: SelectCardEffect.Mode.Custom,
  360. root: SelectCardEffect.Root.Trash,
  361. customRootCardList: null,
  362. canLookReverseCard: true,
  363. selectPlayer: card.Owner,
  364. cardEffect: activateClass);
  365. selectCardEffect.SetUpCustomMessage("Select 1 card to place under a tamer.",
  366. "The opponent is selecting 1 card to place under a tamer.");
  367. yield return StartCoroutine(selectCardEffect.Activate());
  368. }
  369. if (selectedCards.Count >= 1)
  370. {
  371. Permanent selectedPermanent = null;
  372. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  373. selectPermanentEffect.SetUp(
  374. selectPlayer: card.Owner,
  375. canTargetCondition: IsOwnTamerCondition,
  376. canTargetCondition_ByPreSelecetedList: null,
  377. canEndSelectCondition: null,
  378. maxCount: 1,
  379. canNoSelect: true,
  380. canEndNotMax: false,
  381. selectPermanentCoroutine: SelectPermanentCoroutine,
  382. afterSelectPermanentCoroutine: null,
  383. mode: SelectPermanentEffect.Mode.Custom,
  384. cardEffect: activateClass);
  385. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to place the chosen card under.",
  386. "The opponent is selecting 1 Tamer to place the chosen card under.");
  387. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  388. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  389. {
  390. selectedPermanent = permanent;
  391. yield return null;
  392. }
  393. if (selectedPermanent != null)
  394. {
  395. yield return ContinuousController.instance.StartCoroutine(
  396. selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  397. }
  398. }
  399. }
  400. }
  401. }
  402. #endregion
  403. #region Your Turn - ESS
  404. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  405. {
  406. bool Condition()
  407. {
  408. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOwnerTurn(card) &&
  409. card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart");
  410. }
  411. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  412. }
  413. #endregion
  414. return cardEffects;
  415. }
  416. }
  417. }