BT21_021.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //OmniShoutmon
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_021 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Cost
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if (targetPermanent.IsDigimon)
  19. {
  20. if (targetPermanent.TopCard.EqualsCardName("Shoutmon"))
  21. {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  28. }
  29. if (timing == EffectTiming.None)
  30. {
  31. bool PermanentCondition(Permanent targetPermanent)
  32. {
  33. if (targetPermanent.IsDigimon)
  34. {
  35. if (targetPermanent.Level == 4)
  36. {
  37. if (targetPermanent.TopCard.EqualsTraits("Xros Heart") || targetPermanent.TopCard.EqualsTraits("Hero"))
  38. {
  39. return true;
  40. }
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  47. }
  48. #endregion
  49. #region DigiXros Name
  50. if (timing == EffectTiming.None)
  51. {
  52. ChangeCardNamesForDigiXrosClass changeCardNamesForDigiXrosClass = new ChangeCardNamesForDigiXrosClass();
  53. changeCardNamesForDigiXrosClass.SetUpICardEffect("Also treated as [Shoutmon] for a DigiXros", CanUseCondition, card);
  54. changeCardNamesForDigiXrosClass.SetUpChangeCardNamesForDigiXrosClass(changeCardNames: ChangeCardNames);
  55. cardEffects.Add(changeCardNamesForDigiXrosClass);
  56. bool CanUseCondition(Hashtable hashtable)
  57. {
  58. return true;
  59. }
  60. List<string> ChangeCardNames(CardSource cardSource, List<string> cardNames)
  61. {
  62. if (cardSource == card)
  63. {
  64. cardNames.Add("Shoutmon");
  65. }
  66. return cardNames;
  67. }
  68. }
  69. #endregion
  70. #region DigiXros
  71. if (timing == EffectTiming.None)
  72. {
  73. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  74. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  75. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  76. addDigiXrosConditionClass.SetNotShowUI(true);
  77. cardEffects.Add(addDigiXrosConditionClass);
  78. bool CanUseCondition(Hashtable hashtable)
  79. {
  80. return true;
  81. }
  82. DigiXrosCondition GetDigiXros(CardSource cardSource)
  83. {
  84. if (cardSource == card)
  85. {
  86. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "[Xros Heart] Digimon");
  87. bool CanSelectCardCondition(CardSource cardSource)
  88. {
  89. if (cardSource != null)
  90. {
  91. if (cardSource.Owner == card.Owner)
  92. {
  93. if (cardSource.IsDigimon)
  94. {
  95. if (cardSource.EqualsCardNameDigiXros("Shoutmon"))
  96. {
  97. return true;
  98. }
  99. }
  100. }
  101. }
  102. return false;
  103. }
  104. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element };
  105. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  106. return digiXrosCondition;
  107. }
  108. return null;
  109. }
  110. }
  111. #endregion
  112. #region On Deletion
  113. if (timing == EffectTiming.OnDestroyedAnyone)
  114. {
  115. ActivateClass activateClass = new ActivateClass();
  116. activateClass.SetUpICardEffect("Place 1 [Xros]/[Blue Flare] digimon under tamer, then <Save>", CanUseCondition, card);
  117. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  118. cardEffects.Add(activateClass);
  119. string EffectDiscription()
  120. => "[On Deletion] You may place 1 Digimon card with the [Xros Heart]/[Blue Flare] trait from your hand or trash under any of your Tamers. Then,<Save>";
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.CanActivateOnDeletion(card);
  128. }
  129. bool CanSelectTamerCondition(Permanent permanent)
  130. {
  131. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  132. && permanent.IsTamer;
  133. }
  134. bool CanSelectCardCondition(CardSource cardSource)
  135. {
  136. if (cardSource.IsDigimon)
  137. {
  138. if (cardSource.EqualsTraits("Xros Heart") || cardSource.EqualsTraits("Blue Flare"))
  139. {
  140. return true;
  141. }
  142. }
  143. return false;
  144. }
  145. IEnumerator ActivateCoroutine(Hashtable hashtable)
  146. {
  147. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectTamerCondition))
  148. {
  149. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  150. {
  151. bool fromHand = false;
  152. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  153. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  154. CardSource selectedCard = null;
  155. if (canSelectHand || canSelectTrash)
  156. {
  157. if (canSelectHand && canSelectTrash)
  158. {
  159. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  160. {
  161. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  162. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  163. };
  164. string selectPlayerMessage = "From which area do you select a card?";
  165. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  166. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  167. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  168. fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  169. }
  170. else
  171. {
  172. fromHand = canSelectHand;
  173. }
  174. IEnumerator SelectCardCoroutine(CardSource cardSource)
  175. {
  176. selectedCard = cardSource;
  177. yield return null;
  178. }
  179. if (fromHand)
  180. {
  181. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  182. selectHandEffect.SetUp(
  183. selectPlayer: card.Owner,
  184. canTargetCondition: CanSelectCardCondition,
  185. canTargetCondition_ByPreSelecetedList: null,
  186. canEndSelectCondition: null,
  187. maxCount: 1,
  188. canNoSelect: true,
  189. canEndNotMax: false,
  190. isShowOpponent: true,
  191. selectCardCoroutine: SelectCardCoroutine,
  192. afterSelectCardCoroutine: null,
  193. mode: SelectHandEffect.Mode.Custom,
  194. cardEffect: activateClass);
  195. selectHandEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  196. yield return StartCoroutine(selectHandEffect.Activate());
  197. }
  198. else
  199. {
  200. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  201. selectCardEffect.SetUp(
  202. canTargetCondition: CanSelectCardCondition,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. canNoSelect: () => true,
  206. selectCardCoroutine: SelectCardCoroutine,
  207. afterSelectCardCoroutine: null,
  208. message: "Select 1 card to add as source.",
  209. maxCount: 1,
  210. canEndNotMax: false,
  211. isShowOpponent: true,
  212. mode: SelectCardEffect.Mode.Custom,
  213. root: SelectCardEffect.Root.Trash,
  214. customRootCardList: null,
  215. canLookReverseCard: true,
  216. selectPlayer: card.Owner,
  217. cardEffect: activateClass);
  218. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  219. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  220. }
  221. }
  222. if (selectedCard != null)
  223. {
  224. Permanent selectedPermanent = null;
  225. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectTamerCondition));
  226. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  227. selectPermanentEffect.SetUp(
  228. selectPlayer: card.Owner,
  229. canTargetCondition: CanSelectTamerCondition,
  230. canTargetCondition_ByPreSelecetedList: null,
  231. canEndSelectCondition: null,
  232. maxCount: maxCount,
  233. canNoSelect: false,
  234. canEndNotMax: false,
  235. selectPermanentCoroutine: SelectPermanentCoroutine,
  236. afterSelectPermanentCoroutine: null,
  237. mode: SelectPermanentEffect.Mode.Custom,
  238. cardEffect: activateClass);
  239. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  240. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  241. {
  242. selectedPermanent = permanent;
  243. yield return null;
  244. }
  245. if (selectedPermanent != null)
  246. {
  247. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  248. }
  249. }
  250. if (CardEffectCommons.CanActivateSave(hashtable, CanSelectTamerCondition))
  251. {
  252. yield return ContinuousController.instance.StartCoroutine(
  253. CardEffectCommons.SaveProcess(hashtable, activateClass, card, CanSelectTamerCondition));
  254. }
  255. }
  256. }
  257. }
  258. }
  259. #endregion
  260. #region End of Attack
  261. if (timing == EffectTiming.OnEndAttack)
  262. {
  263. ActivateClass activateClass = new ActivateClass();
  264. activateClass.SetUpICardEffect("Play 1 [Xros Heart]/[Blue Flare]/[Hero] Digimon", CanUseCondition, card);
  265. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  266. cardEffects.Add(activateClass);
  267. string EffectDiscription()
  268. {
  269. return "[End of Attack] You may play 1 card with the [Xros Heart]/[Blue Flare]/[Hero] trait from your hand with the play cost reduced by 5. If you did, delete this Digimon.";
  270. }
  271. bool CanUseCondition(Hashtable hashtable)
  272. {
  273. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  274. {
  275. if (CardEffectCommons.CanTriggerOnEndAttack(hashtable, card))
  276. {
  277. return true;
  278. }
  279. }
  280. return false;
  281. }
  282. bool CanActivateCondition(Hashtable hashtable)
  283. {
  284. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  285. {
  286. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  287. {
  288. return true;
  289. }
  290. }
  291. return false;
  292. }
  293. bool CanSelectCardCondition(CardSource cardSource)
  294. {
  295. if (cardSource.IsDigimon || cardSource.IsTamer)
  296. {
  297. if (cardSource.EqualsTraits("Xros Heart") || cardSource.EqualsTraits("Blue Flare") || cardSource.EqualsTraits("Hero"))
  298. {
  299. return true;
  300. }
  301. }
  302. return false;
  303. }
  304. IEnumerator ActivateCoroutine(Hashtable hashtable)
  305. {
  306. CardSource selectedCard = null;
  307. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardCondition));
  308. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  309. selectHandEffect.SetUp(
  310. selectPlayer: card.Owner,
  311. canTargetCondition: CanSelectCardCondition,
  312. canTargetCondition_ByPreSelecetedList: null,
  313. canEndSelectCondition: null,
  314. maxCount: maxCount,
  315. canNoSelect: true,
  316. canEndNotMax: false,
  317. isShowOpponent: true,
  318. selectCardCoroutine: SelectCardCoroutine,
  319. afterSelectCardCoroutine: null,
  320. mode: SelectHandEffect.Mode.Custom,
  321. cardEffect: activateClass);
  322. yield return StartCoroutine(selectHandEffect.Activate());
  323. IEnumerator SelectCardCoroutine(CardSource cardSource)
  324. {
  325. selectedCard = cardSource;
  326. yield return null;
  327. }
  328. if (selectedCard != null)
  329. {
  330. #region reduce play cost
  331. ChangeCostClass changeCostClass = new ChangeCostClass();
  332. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition1, card);
  333. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  334. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  335. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  336. ICardEffect GetCardEffect(EffectTiming _timing)
  337. {
  338. if (_timing == EffectTiming.None)
  339. {
  340. return changeCostClass;
  341. }
  342. return null;
  343. }
  344. bool CanUseCondition1(Hashtable hashtable)
  345. {
  346. return true;
  347. }
  348. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  349. {
  350. if (CardSourceCondition(cardSource))
  351. {
  352. if (RootCondition(root))
  353. {
  354. if (PermanentsCondition(targetPermanents))
  355. {
  356. Cost -= 5;
  357. }
  358. }
  359. }
  360. return Cost;
  361. }
  362. bool PermanentsCondition(List<Permanent> targetPermanents)
  363. {
  364. if (targetPermanents == null)
  365. {
  366. return true;
  367. }
  368. else
  369. {
  370. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  371. {
  372. return true;
  373. }
  374. }
  375. return false;
  376. }
  377. bool CardSourceCondition(CardSource cardSource)
  378. {
  379. if (cardSource != null)
  380. {
  381. if (cardSource.Owner == card.Owner)
  382. {
  383. return CanSelectCardCondition(cardSource);
  384. }
  385. }
  386. return false;
  387. }
  388. bool RootCondition(SelectCardEffect.Root root)
  389. {
  390. return true;
  391. }
  392. bool isUpDown()
  393. {
  394. return true;
  395. }
  396. #endregion
  397. bool isPlayed = false;
  398. Permanent thisPermanent = card.PermanentOfThisCard();
  399. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  400. cardSources: new List<CardSource>() { selectedCard },
  401. activateClass: activateClass,
  402. payCost: true,
  403. isTapped: false,
  404. root: SelectCardEffect.Root.Hand,
  405. activateETB: true));
  406. #region release reducing play cost
  407. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  408. #endregion
  409. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedCard.PermanentOfThisCard())) isPlayed = true;
  410. if (isPlayed)
  411. {
  412. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  413. selectPermanentEffect.SetUp(
  414. selectPlayer: card.Owner,
  415. canTargetCondition: permanent => permanent == thisPermanent,
  416. canTargetCondition_ByPreSelecetedList: null,
  417. canEndSelectCondition: null,
  418. maxCount: 1,
  419. canNoSelect: false,
  420. canEndNotMax: false,
  421. selectPermanentCoroutine: null,
  422. afterSelectPermanentCoroutine: null,
  423. mode: SelectPermanentEffect.Mode.Destroy,
  424. cardEffect: activateClass);
  425. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  426. }
  427. }
  428. }
  429. }
  430. #endregion
  431. #region ESS
  432. if (timing == EffectTiming.None)
  433. {
  434. bool Condition()
  435. {
  436. return card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart");
  437. }
  438. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  439. }
  440. #endregion
  441. return cardEffects;
  442. }
  443. }
  444. }