BT21_092.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Can't Turn My Back!
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_092 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region ignoring colours
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. => CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.IsDigimon && permanent.TopCard.EqualsTraits("Xros Heart"));
  21. bool CardCondition(CardSource cardSource)
  22. => cardSource == card;
  23. }
  24. #endregion
  25. #region Main
  26. if (timing == EffectTiming.OptionSkill)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Place all sources from 1 [Xros Heart] under a tamer", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "[Main] Place all Digimon cards in 1 of your [Xros Heart] trait Digimon's digivolution cards under 1 of your Tamers. Then, you may play 1 Digimon card with the [Xros Heart] trait from your hand with the play cost reduced by 1 for each card this effect placed.";
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  39. }
  40. bool CanSelectCardCondiition(CardSource cardSource)
  41. {
  42. if (cardSource.IsDigimon)
  43. {
  44. if (cardSource.EqualsTraits("Xros Heart"))
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanSelectDigimonCondition(Permanent permanent)
  52. {
  53. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  54. {
  55. if (permanent.TopCard.EqualsTraits("Xros Heart"))
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. bool CanSelectTamerCondition(Permanent permanent)
  63. {
  64. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  65. {
  66. if (permanent.IsTamer)
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable hashtable)
  74. {
  75. int cardsMoved = 0;
  76. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimonCondition) && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectTamerCondition))
  77. {
  78. Permanent selectedDigimon = null;
  79. Permanent selectedTamer = null;
  80. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigimonCondition));
  81. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectDigimonCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: maxCount,
  88. canNoSelect: false,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: SelectPermanentCoroutine,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place sources under a tamer.", "The opponent is selecting 1 Digimon to place sources under a tamer.");
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  97. {
  98. selectedDigimon = permanent;
  99. yield return null;
  100. }
  101. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectTamerCondition));
  102. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect1.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: CanSelectTamerCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: maxCount1,
  109. canNoSelect: false,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: SelectPermanentCoroutine1,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectPermanentEffect1.SetUpCustomMessage("Select 1 Tamer to place sources under.", "The opponent is selecting 1 Tamer to place sources under.");
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  118. {
  119. selectedTamer = permanent;
  120. yield return null;
  121. }
  122. var cards = selectedDigimon.DigivolutionCards;
  123. cardsMoved = cards.Count;
  124. yield return ContinuousController.instance.StartCoroutine(selectedTamer.AddDigivolutionCardsBottom(cards, activateClass));
  125. }
  126. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondiition))
  127. {
  128. CardSource selectedCard = null;
  129. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  130. selectHandEffect.SetUp(
  131. selectPlayer: card.Owner,
  132. canTargetCondition: CanSelectCardCondiition,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. maxCount: 1,
  136. canNoSelect: true,
  137. canEndNotMax: false,
  138. isShowOpponent: true,
  139. selectCardCoroutine: SelectCardCoroutine,
  140. afterSelectCardCoroutine: null,
  141. mode: SelectHandEffect.Mode.Custom,
  142. cardEffect: activateClass);
  143. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  144. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  145. yield return StartCoroutine(selectHandEffect.Activate());
  146. IEnumerator SelectCardCoroutine(CardSource cardSource)
  147. {
  148. selectedCard = cardSource;
  149. yield return null;
  150. }
  151. if (selectedCard)
  152. {
  153. var cost = selectedCard.BasePlayCostFromEntity - cardsMoved;
  154. if (cost < 0) cost = 0;
  155. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  156. cardSources: new List<CardSource>() { selectedCard },
  157. activateClass: activateClass,
  158. payCost: true,
  159. isTapped: false,
  160. root: SelectCardEffect.Root.Hand,
  161. activateETB: true,
  162. fixedCost: cost));
  163. }
  164. }
  165. }
  166. }
  167. #endregion
  168. #region Secuity
  169. if (timing == EffectTiming.SecuritySkill)
  170. {
  171. ActivateClass activateClass = new ActivateClass();
  172. activateClass.SetUpICardEffect("Play 1 [Xros Heart] trait card with a play cost of 5 or less", CanUseCondition, card);
  173. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  174. activateClass.SetIsSecurityEffect(true);
  175. cardEffects.Add(activateClass);
  176. string EffectDiscription()
  177. {
  178. return "[Security] You may play 1 [Xros Heart] trait card with a play cost of 5 or less from your hand or trash without paying the cost.";
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. if (CardEffectCommons.CanTriggerSecurityEffect(hashtable, card))
  183. {
  184. return true;
  185. }
  186. return false;
  187. }
  188. bool CanActivateCondition(Hashtable hashtable)
  189. {
  190. if (CardEffectCommons.CanTriggerSecurityEffect(hashtable, card))
  191. {
  192. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)))
  193. {
  194. return true;
  195. }
  196. }
  197. return false;
  198. }
  199. bool CanSelectCardCondition(CardSource cardSource)
  200. {
  201. if (cardSource.HasPlayCost)
  202. {
  203. if (cardSource.BasePlayCostFromEntity <= 5)
  204. {
  205. if (cardSource.EqualsTraits("Xros Heart"))
  206. {
  207. return true;
  208. }
  209. }
  210. }
  211. return false;
  212. }
  213. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  214. {
  215. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  216. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  217. if (canSelectHand && canSelectTrash)
  218. {
  219. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  220. {
  221. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  222. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  223. };
  224. string selectPlayerMessage = "From which area do you select a card?";
  225. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  226. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  227. }
  228. else
  229. {
  230. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  231. }
  232. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  233. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  234. CardSource selectedCard = null;
  235. if (fromHand)
  236. {
  237. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  238. selectHandEffect.SetUp(
  239. selectPlayer: card.Owner,
  240. canTargetCondition: CanSelectCardCondition,
  241. canTargetCondition_ByPreSelecetedList: null,
  242. canEndSelectCondition: null,
  243. maxCount: 1,
  244. canNoSelect: true,
  245. canEndNotMax: false,
  246. isShowOpponent: true,
  247. selectCardCoroutine: SelectCardCoroutine,
  248. afterSelectCardCoroutine: null,
  249. mode: SelectHandEffect.Mode.Custom,
  250. cardEffect: activateClass);
  251. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  252. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  253. yield return StartCoroutine(selectHandEffect.Activate());
  254. }
  255. else
  256. {
  257. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  258. selectCardEffect.SetUp(
  259. canTargetCondition: CanSelectCardCondition,
  260. canTargetCondition_ByPreSelecetedList: null,
  261. canEndSelectCondition: null,
  262. canNoSelect: () => true,
  263. selectCardCoroutine: SelectCardCoroutine,
  264. afterSelectCardCoroutine: null,
  265. message: "Select 1 card to play.",
  266. maxCount: 1,
  267. canEndNotMax: false,
  268. isShowOpponent: true,
  269. mode: SelectCardEffect.Mode.Custom,
  270. root: SelectCardEffect.Root.Trash,
  271. customRootCardList: null,
  272. canLookReverseCard: true,
  273. selectPlayer: card.Owner,
  274. cardEffect: activateClass);
  275. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  276. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  277. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  278. }
  279. IEnumerator SelectCardCoroutine(CardSource cardSource)
  280. {
  281. selectedCard = cardSource;
  282. yield return null;
  283. }
  284. if (selectedCard != null)
  285. {
  286. var selectedRoot = fromHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  287. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: selectedRoot, activateETB: true));
  288. }
  289. }
  290. }
  291. #endregion
  292. return cardEffects;
  293. }
  294. }
  295. }