BT21_021.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //OmniShoutmon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_021 : 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 Cost
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.IsDigimon)
  18. {
  19. if (targetPermanent.TopCard.EqualsCardName("Shoutmon"))
  20. {
  21. return true;
  22. }
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  27. }
  28. if (timing == EffectTiming.None)
  29. {
  30. bool PermanentCondition(Permanent targetPermanent)
  31. {
  32. if (targetPermanent.IsDigimon)
  33. {
  34. if (targetPermanent.Level == 4)
  35. {
  36. if (targetPermanent.TopCard.EqualsTraits("Xros Heart") || targetPermanent.TopCard.EqualsTraits("Hero"))
  37. {
  38. return true;
  39. }
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  46. }
  47. #endregion
  48. #region DigiXros Name
  49. if (timing == EffectTiming.None)
  50. {
  51. ChangeCardNamesForDigiXrosClass changeCardNamesForDigiXrosClass = new ChangeCardNamesForDigiXrosClass();
  52. changeCardNamesForDigiXrosClass.SetUpICardEffect("Also treated as [Shoutmon] for a DigiXros", CanUseCondition, card);
  53. changeCardNamesForDigiXrosClass.SetUpChangeCardNamesForDigiXrosClass(changeCardNames: ChangeCardNames);
  54. cardEffects.Add(changeCardNamesForDigiXrosClass);
  55. bool CanUseCondition(Hashtable hashtable)
  56. {
  57. return true;
  58. }
  59. List<string> ChangeCardNames(CardSource cardSource, List<string> cardNames)
  60. {
  61. if (cardSource == card)
  62. {
  63. cardNames.Add("Shoutmon");
  64. }
  65. return cardNames;
  66. }
  67. }
  68. #endregion
  69. #region DigiXros
  70. if (timing == EffectTiming.None)
  71. {
  72. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  73. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  74. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  75. addDigiXrosConditionClass.SetNotShowUI(true);
  76. cardEffects.Add(addDigiXrosConditionClass);
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. return true;
  80. }
  81. DigiXrosCondition GetDigiXros(CardSource cardSource)
  82. {
  83. if (cardSource == card)
  84. {
  85. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "[Xros Heart] Digimon");
  86. bool CanSelectCardCondition(CardSource cardSource)
  87. {
  88. if (cardSource != null)
  89. {
  90. if (cardSource.Owner == card.Owner)
  91. {
  92. if (cardSource.IsDigimon)
  93. {
  94. if (cardSource.EqualsCardName("Shoutmon"))
  95. {
  96. return true;
  97. }
  98. }
  99. }
  100. }
  101. return false;
  102. }
  103. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element };
  104. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  105. return digiXrosCondition;
  106. }
  107. return null;
  108. }
  109. }
  110. #endregion
  111. #region On Deletion
  112. if (timing == EffectTiming.OnDestroyedAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Place 1 [Xros]/[Blue Flare] digimon under tamer, then <Save>", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  117. cardEffects.Add(activateClass);
  118. string EffectDiscription()
  119. => "[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>";
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  123. {
  124. if (CardEffectCommons.CanTriggerOnDeletion(hashtable, card))
  125. {
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanActivateCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  134. }
  135. bool CanSelectTamerCondition(Permanent permanent)
  136. {
  137. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  138. && permanent.IsTamer;
  139. }
  140. bool CanSelectCardCondition(CardSource cardSource)
  141. {
  142. if (cardSource.IsDigimon)
  143. {
  144. if (cardSource.EqualsTraits("Xros Heart") || cardSource.EqualsTraits("Blue Flare"))
  145. {
  146. return true;
  147. }
  148. }
  149. return false;
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectTamerCondition))
  154. {
  155. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  156. {
  157. SelectCardEffect.Root? rootmode = null!;
  158. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  159. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  160. if (canSelectHand && !canSelectTrash) rootmode = SelectCardEffect.Root.Hand;
  161. if (!canSelectHand && canSelectTrash) rootmode = SelectCardEffect.Root.Trash;
  162. if (canSelectHand && canSelectTrash)
  163. {
  164. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  165. {
  166. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  167. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  168. };
  169. string selectPlayerMessage = "From which area do you select a card?";
  170. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  171. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  172. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  173. rootmode = GManager.instance.userSelectionManager.SelectedBoolValue ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  174. }
  175. if (rootmode != null)
  176. {
  177. CardSource selectedCard = null;
  178. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  179. selectCardEffect.SetUp(
  180. canTargetCondition: CanSelectCardCondition,
  181. canTargetCondition_ByPreSelecetedList: null,
  182. canEndSelectCondition: null,
  183. canNoSelect: () => true,
  184. selectCardCoroutine: SelectCardCoroutine,
  185. afterSelectCardCoroutine: null,
  186. message: "Select 1 card to add as source.",
  187. maxCount: 1,
  188. canEndNotMax: false,
  189. isShowOpponent: true,
  190. mode: SelectCardEffect.Mode.Custom,
  191. root: (SelectCardEffect.Root)rootmode!,
  192. customRootCardList: null,
  193. canLookReverseCard: true,
  194. selectPlayer: card.Owner,
  195. cardEffect: activateClass);
  196. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  197. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  198. IEnumerator SelectCardCoroutine(CardSource cardSource)
  199. {
  200. selectedCard = cardSource;
  201. yield return null;
  202. }
  203. if (selectedCard != null)
  204. {
  205. Permanent selectedPermanent = null;
  206. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectTamerCondition));
  207. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  208. selectPermanentEffect.SetUp(
  209. selectPlayer: card.Owner,
  210. canTargetCondition: CanSelectTamerCondition,
  211. canTargetCondition_ByPreSelecetedList: null,
  212. canEndSelectCondition: null,
  213. maxCount: maxCount,
  214. canNoSelect: false,
  215. canEndNotMax: false,
  216. selectPermanentCoroutine: SelectPermanentCoroutine,
  217. afterSelectPermanentCoroutine: null,
  218. mode: SelectPermanentEffect.Mode.Custom,
  219. cardEffect: activateClass);
  220. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  221. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  222. {
  223. selectedPermanent = permanent;
  224. yield return null;
  225. }
  226. if (selectedPermanent != null)
  227. {
  228. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  229. }
  230. }
  231. }
  232. if (CardEffectCommons.CanActivateSave(hashtable, CanSelectTamerCondition))
  233. {
  234. yield return ContinuousController.instance.StartCoroutine(
  235. CardEffectCommons.SaveProcess(hashtable, activateClass, card, CanSelectTamerCondition));
  236. }
  237. }
  238. }
  239. }
  240. }
  241. #endregion
  242. #region End of Attack
  243. if (timing == EffectTiming.OnEndAttack)
  244. {
  245. ActivateClass activateClass = new ActivateClass();
  246. activateClass.SetUpICardEffect("Play 1 [Xros Heart]/[Blue Flare]/[Hero] Digimon", CanUseCondition, card);
  247. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  248. cardEffects.Add(activateClass);
  249. string EffectDiscription()
  250. {
  251. 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.";
  252. }
  253. bool CanUseCondition(Hashtable hashtable)
  254. {
  255. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  256. {
  257. if (CardEffectCommons.CanTriggerOnEndAttack(hashtable, card))
  258. {
  259. return true;
  260. }
  261. }
  262. return false;
  263. }
  264. bool CanActivateCondition(Hashtable hashtable)
  265. {
  266. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  267. {
  268. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  269. {
  270. return true;
  271. }
  272. }
  273. return false;
  274. }
  275. bool CanSelectCardCondition(CardSource cardSource)
  276. {
  277. if (cardSource.IsDigimon)
  278. {
  279. if (cardSource.EqualsTraits("Xros Heart") || cardSource.EqualsTraits("Blue Flare") || cardSource.EqualsTraits("Hero"))
  280. {
  281. return true;
  282. }
  283. }
  284. return false;
  285. }
  286. IEnumerator ActivateCoroutine(Hashtable hashtable)
  287. {
  288. CardSource selectedCard = null;
  289. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardCondition));
  290. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  291. selectHandEffect.SetUp(
  292. selectPlayer: card.Owner,
  293. canTargetCondition: CanSelectCardCondition,
  294. canTargetCondition_ByPreSelecetedList: null,
  295. canEndSelectCondition: null,
  296. maxCount: maxCount,
  297. canNoSelect: true,
  298. canEndNotMax: false,
  299. isShowOpponent: true,
  300. selectCardCoroutine: SelectCardCoroutine,
  301. afterSelectCardCoroutine: null,
  302. mode: SelectHandEffect.Mode.Custom,
  303. cardEffect: activateClass);
  304. yield return StartCoroutine(selectHandEffect.Activate());
  305. IEnumerator SelectCardCoroutine(CardSource cardSource)
  306. {
  307. selectedCard = cardSource;
  308. yield return null;
  309. }
  310. if (selectedCard != null)
  311. {
  312. bool isPlayed = false;
  313. var reducdedCost = selectedCard.BasePlayCostFromEntity - 5;
  314. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: true, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true, fixedCost: reducdedCost));
  315. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedCard.PermanentOfThisCard())) isPlayed = true;
  316. if (isPlayed)
  317. {
  318. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  319. selectPermanentEffect.SetUp(
  320. selectPlayer: card.Owner,
  321. canTargetCondition: permanent => permanent == card.PermanentOfThisCard(),
  322. canTargetCondition_ByPreSelecetedList: null,
  323. canEndSelectCondition: null,
  324. maxCount: 1,
  325. canNoSelect: false,
  326. canEndNotMax: false,
  327. selectPermanentCoroutine: null,
  328. afterSelectPermanentCoroutine: null,
  329. mode: SelectPermanentEffect.Mode.Destroy,
  330. cardEffect: activateClass);
  331. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  332. }
  333. }
  334. }
  335. }
  336. #endregion
  337. #region ESS
  338. if (timing == EffectTiming.None)
  339. {
  340. bool Condition()
  341. {
  342. return card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart");
  343. }
  344. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  345. }
  346. #endregion
  347. return cardEffects;
  348. }
  349. }
  350. }