BT19_090.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_090 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Main Effect
  12. if (timing == EffectTiming.OptionSkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return
  21. "[Main] Activate 1 of the following effects: - You may play 1 Digimon card with the [Xros Heart] trait and 4000 DP or less from under your Tamer without paying the cost. - By unsuspending 1 of your [Shoutmon EX6] and 1 of your [ShootingStarmon], attack a player with 1 of your Digimon.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  26. }
  27. bool HasXrosHeartTraitCondition(CardSource cardSource)
  28. {
  29. return cardSource.IsDigimon && cardSource.EqualsTraits("Xros Heart") &&
  30. cardSource.CardDP <= 4000 &&
  31. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  32. }
  33. bool TamerHasDigimonCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  36. permanent.IsTamer && permanent.DigivolutionCards.Count(HasXrosHeartTraitCondition) >= 1;
  37. }
  38. bool IsUnsuspendedShoutmonCondition(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsOwnerPermanent(permanent, card) &&
  41. permanent.TopCard.EqualsCardName("Shoutmon EX6") &&
  42. permanent.IsSuspended &&
  43. CardEffectCommons.CanUnsuspend(permanent);
  44. }
  45. bool IsUnsuspendedStarmonCondition(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsOwnerPermanent(permanent, card) &&
  48. permanent.TopCard.EqualsCardName("ShootingStarmon") &&
  49. permanent.IsSuspended &&
  50. CardEffectCommons.CanUnsuspend(permanent);
  51. }
  52. bool IsYourDigimon(Permanent permanent)
  53. {
  54. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  55. permanent.CanAttack(activateClass);
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable hashtable)
  58. {
  59. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  60. {
  61. new(message: "Play 1 Digimon card with the [Xros Heart] trait from under your Tamer", value: true, spriteIndex: 0),
  62. new(message: "Unsuspend 1 [Shoutmon EX6] and 1 [ShootingStarmon] to attack a player", value: false, spriteIndex: 1)
  63. };
  64. string selectPlayerMessage = "Choose which effect to activate";
  65. string notSelectPlayerMessage = "The opponent is choosing the effect.";
  66. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner,
  67. selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  68. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  69. bool isPlayDigimon = GManager.instance.userSelectionManager.SelectedBoolValue;
  70. if (isPlayDigimon)
  71. {
  72. Permanent selectedPermanent = null;
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: TamerHasDigimonCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  89. {
  90. selectedPermanent = permanent;
  91. yield return null;
  92. }
  93. if (selectedPermanent != null)
  94. {
  95. List<CardSource> selectedCards = new List<CardSource>();
  96. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  97. selectCardEffect.SetUp(
  98. canTargetCondition: HasXrosHeartTraitCondition,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. canNoSelect: () => true,
  102. selectCardCoroutine: SelectCardCoroutine,
  103. afterSelectCardCoroutine: null,
  104. message: "Select 1 digivolution card to play.",
  105. maxCount: 1,
  106. canEndNotMax: false,
  107. isShowOpponent: true,
  108. mode: SelectCardEffect.Mode.Custom,
  109. root: SelectCardEffect.Root.Custom,
  110. customRootCardList: selectedPermanent.DigivolutionCards,
  111. canLookReverseCard: true,
  112. selectPlayer: card.Owner,
  113. cardEffect: activateClass);
  114. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.",
  115. "The opponent is selecting 1 digivolution card to play.");
  116. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  117. yield return StartCoroutine(selectCardEffect.Activate());
  118. IEnumerator SelectCardCoroutine(CardSource cardSource)
  119. {
  120. selectedCards.Add(cardSource);
  121. yield return null;
  122. }
  123. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  124. cardSources: selectedCards,
  125. activateClass: activateClass,
  126. payCost: false,
  127. isTapped: false,
  128. root: SelectCardEffect.Root.DigivolutionCards,
  129. activateETB: true));
  130. }
  131. }
  132. else
  133. {
  134. // if only 0-1 of targets is on the field, effect ends here & we don't unsuspend anything
  135. var digimonPresent = card.Owner.GetBattleAreaDigimons().Filter(x => (IsUnsuspendedStarmonCondition(x) || IsUnsuspendedShoutmonCondition(x))).ToList();
  136. if (digimonPresent.Count <= 1) yield break;
  137. List<Permanent> selectedPermanents = new();
  138. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  139. {
  140. selectedPermanents.Add(permanent);
  141. yield return null;
  142. }
  143. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. selectPermanentEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: IsUnsuspendedShoutmonCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: 1,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. selectPermanentCoroutine: SelectPermanentCoroutine1,
  153. afterSelectPermanentCoroutine: null,
  154. mode: SelectPermanentEffect.Mode.UnTap,
  155. cardEffect: activateClass);
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. if (selectedPermanents.Count < 1) yield break;
  158. selectPermanentEffect.SetUp(
  159. selectPlayer: card.Owner,
  160. canTargetCondition: IsUnsuspendedStarmonCondition,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. maxCount: 1,
  164. canNoSelect: false,
  165. canEndNotMax: false,
  166. selectPermanentCoroutine: SelectPermanentCoroutine1,
  167. afterSelectPermanentCoroutine: null,
  168. mode: SelectPermanentEffect.Mode.UnTap,
  169. cardEffect: activateClass);
  170. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  171. bool unsuspended = selectedPermanents.Count == 2;
  172. if (unsuspended)
  173. {
  174. Permanent selectedPermanent = null;
  175. selectPermanentEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: IsYourDigimon,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: 1,
  181. canNoSelect: false,
  182. canEndNotMax: false,
  183. selectPermanentCoroutine: SelectPermanentCoroutine2,
  184. afterSelectPermanentCoroutine: null,
  185. mode: SelectPermanentEffect.Mode.Custom,
  186. cardEffect: activateClass);
  187. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.",
  188. "The opponent is selecting 1 Digimon that will attack.");
  189. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  190. IEnumerator SelectPermanentCoroutine2(Permanent permanent)
  191. {
  192. selectedPermanent = permanent;
  193. yield return null;
  194. }
  195. if (selectedPermanent != null)
  196. {
  197. SelectAttackEffect selectAttackEffect =
  198. GManager.instance.GetComponent<SelectAttackEffect>();
  199. selectAttackEffect.SetUp(
  200. attacker: selectedPermanent,
  201. canAttackPlayerCondition: () => true,
  202. defenderCondition: _ => false,
  203. cardEffect: activateClass);
  204. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  205. }
  206. }
  207. }
  208. }
  209. }
  210. #endregion
  211. #region Security Effect
  212. if (timing == EffectTiming.SecuritySkill)
  213. {
  214. ActivateClass activateClass = new ActivateClass();
  215. activateClass.SetUpICardEffect(
  216. $"Play 1 Digimon card with the [Xros Heart] trait from under your Tamer", CanUseCondition, card);
  217. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  218. activateClass.SetIsSecurityEffect(true);
  219. cardEffects.Add(activateClass);
  220. string EffectDescription()
  221. {
  222. return
  223. "[Security] You may play 1 Digimon card with the [Xros Heart] trait and 4000 DP or less from under your Tamer without paying the cost.";
  224. }
  225. bool CanUseCondition(Hashtable hashtable)
  226. {
  227. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  228. }
  229. bool HasXrosHeartTraitCondition(CardSource cardSource)
  230. {
  231. return cardSource.IsDigimon && cardSource.EqualsTraits("Xros Heart") &&
  232. cardSource.CardDP <= 4000 &&
  233. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  234. }
  235. bool TamerHasDigimonCondition(Permanent permanent)
  236. {
  237. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  238. permanent.IsTamer && permanent.DigivolutionCards.Count(HasXrosHeartTraitCondition) >= 1;
  239. }
  240. IEnumerator ActivateCoroutine(Hashtable hashtable)
  241. {
  242. Permanent selectedPermanent = null;
  243. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  244. selectPermanentEffect.SetUp(
  245. selectPlayer: card.Owner,
  246. canTargetCondition: TamerHasDigimonCondition,
  247. canTargetCondition_ByPreSelecetedList: null,
  248. canEndSelectCondition: null,
  249. maxCount: 1,
  250. canNoSelect: true,
  251. canEndNotMax: false,
  252. selectPermanentCoroutine: SelectPermanentCoroutine,
  253. afterSelectPermanentCoroutine: null,
  254. mode: SelectPermanentEffect.Mode.Custom,
  255. cardEffect: activateClass);
  256. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  257. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  258. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  259. {
  260. selectedPermanent = permanent;
  261. yield return null;
  262. }
  263. if (selectedPermanent != null)
  264. {
  265. List<CardSource> selectedCards = new List<CardSource>();
  266. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  267. selectCardEffect.SetUp(
  268. canTargetCondition: HasXrosHeartTraitCondition,
  269. canTargetCondition_ByPreSelecetedList: null,
  270. canEndSelectCondition: null,
  271. canNoSelect: () => true,
  272. selectCardCoroutine: SelectCardCoroutine,
  273. afterSelectCardCoroutine: null,
  274. message: "Select 1 digivolution card to play.",
  275. maxCount: 1,
  276. canEndNotMax: false,
  277. isShowOpponent: true,
  278. mode: SelectCardEffect.Mode.Custom,
  279. root: SelectCardEffect.Root.Custom,
  280. customRootCardList: selectedPermanent.DigivolutionCards,
  281. canLookReverseCard: true,
  282. selectPlayer: card.Owner,
  283. cardEffect: activateClass);
  284. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.",
  285. "The opponent is selecting 1 digivolution card to play.");
  286. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  287. yield return StartCoroutine(selectCardEffect.Activate());
  288. IEnumerator SelectCardCoroutine(CardSource cardSource)
  289. {
  290. selectedCards.Add(cardSource);
  291. yield return null;
  292. }
  293. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  294. cardSources: selectedCards,
  295. activateClass: activateClass,
  296. payCost: false,
  297. isTapped: false,
  298. root: SelectCardEffect.Root.DigivolutionCards,
  299. activateETB: true));
  300. }
  301. }
  302. }
  303. #endregion
  304. return cardEffects;
  305. }
  306. }
  307. }