ST22_04.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Taomon
  6. namespace DCGO.CardEffects.ST22
  7. {
  8. public class ST22_04 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region OP/WD Shared
  14. string EffectDiscriptionShared(string tag)
  15. {
  16. return $"[{tag}] Until your opponent's turn ends, 1 of their Digimon can't activate [When Digivolving] effects and gets -3000 DP.";
  17. }
  18. bool CanActivateConditionShared(Hashtable hashtable)
  19. {
  20. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  21. }
  22. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  23. {
  24. bool IsOpponentsDigimon(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  27. }
  28. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  29. {
  30. Permanent selectedPermanent = null;
  31. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  32. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  33. selectPermanentEffect.SetUp(
  34. selectPlayer: card.Owner,
  35. canTargetCondition: IsOpponentsDigimon,
  36. canTargetCondition_ByPreSelecetedList: null,
  37. canEndSelectCondition: null,
  38. maxCount: maxCount,
  39. canNoSelect: false,
  40. canEndNotMax: false,
  41. selectPermanentCoroutine: SelectedPermanent,
  42. afterSelectPermanentCoroutine: null,
  43. mode: SelectPermanentEffect.Mode.Custom,
  44. cardEffect: activateClass);
  45. IEnumerator SelectedPermanent(Permanent target)
  46. {
  47. selectedPermanent = target;
  48. yield return null;
  49. }
  50. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain cant activate [When Digivolving] effects & -3K DP.", "The opponent is selecting 1 Digimon that will gain cant activate [When Digivolving] effects & -3k DP.");
  51. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  52. if (selectedPermanent != null)
  53. {
  54. bool CanUseConditionDebuff(Hashtable hashtableDebuff)
  55. {
  56. return true;
  57. }
  58. bool InvalidateCondition(ICardEffect cardEffect)
  59. {
  60. if (selectedPermanent.TopCard != null)
  61. {
  62. if (cardEffect != null)
  63. {
  64. if (cardEffect.EffectSourceCard != null)
  65. {
  66. if (isExistOnField(cardEffect.EffectSourceCard))
  67. {
  68. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  69. {
  70. if (cardEffect.IsWhenDigivolving)
  71. {
  72. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  73. {
  74. return true;
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
  81. }
  82. return false;
  83. }
  84. DisableEffectClass invalidationClass = new DisableEffectClass();
  85. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseConditionDebuff, card);
  86. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  87. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => invalidationClass);
  88. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  89. targetPermanent: selectedPermanent,
  90. changeValue: -3000,
  91. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  92. activateClass: activateClass));
  93. }
  94. }
  95. }
  96. #endregion
  97. #region On Play
  98. if (timing == EffectTiming.OnEnterFieldAnyone)
  99. {
  100. ActivateClass activateClass = new ActivateClass();
  101. activateClass.SetUpICardEffect("1 digimon gains 'cant activate [When Digivolving] effects' and -3K DP", CanUseCondition, card);
  102. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscriptionShared("On Play"));
  103. cardEffects.Add(activateClass);
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  107. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  108. }
  109. }
  110. #endregion
  111. #region When Digivolving
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("1 digimon gains 'cant activate [When Digivolving] effects' and -3K DP", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscriptionShared("When Digivolving"));
  117. cardEffects.Add(activateClass);
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  121. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  122. }
  123. }
  124. #endregion
  125. #region When Attacking
  126. if (timing == EffectTiming.OnAllyAttack)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("Use 1 Option with [Onmyōjutsu]/[Plug-In] trait", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  131. activateClass.SetHashString("ST22_04_WA");
  132. cardEffects.Add(activateClass);
  133. string EffectDiscription()
  134. {
  135. return "[When Attacking] [Once Per Turn] You may use 1 Option card with the [Onmyōjutsu] or [Plug-In] trait from your hand or under your Tamers without paying the cost.";
  136. }
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  140. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  141. }
  142. bool CanActivateCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  145. }
  146. IEnumerator ActivateCoroutine(Hashtable hashtable)
  147. {
  148. #region Use Option Card
  149. bool SelectSourceCard(CardSource source)
  150. {
  151. return source.IsOption
  152. && !source.CanNotPlayThisOption
  153. && (source.EqualsTraits("Onmyōjutsu") || source.EqualsTraits("Plug-In"));
  154. }
  155. bool CanSelectPermanent(Permanent permanent)
  156. {
  157. return permanent.IsTamer
  158. && permanent.DigivolutionCards.Exists(SelectSourceCard);
  159. }
  160. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, SelectSourceCard);
  161. bool canSelectTamer = CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent);
  162. if (canSelectHand || canSelectTamer)
  163. {
  164. if (canSelectHand && canSelectTamer)
  165. {
  166. List<SelectionElement<bool>> selectionElements2 = new List<SelectionElement<bool>>()
  167. {
  168. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  169. new SelectionElement<bool>(message: $"From tamer", value : false, spriteIndex: 1),
  170. };
  171. string selectPlayerMessage2 = "From which area do you select a card?";
  172. string notSelectPlayerMessage2 = "The opponent is choosing from which area to select a card.";
  173. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements2, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage2, notSelectPlayerMessage: notSelectPlayerMessage2);
  174. }
  175. else
  176. {
  177. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  178. }
  179. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  180. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  181. List<CardSource> selectedCards = new List<CardSource>();
  182. IEnumerator SelectCardCoroutine(CardSource cardSource)
  183. {
  184. selectedCards.Add(cardSource);
  185. yield return null;
  186. }
  187. Permanent selectedPermament = null;
  188. IEnumerator SelectPermamentCoroutine(Permanent permanent)
  189. {
  190. selectedPermament = permanent;
  191. yield return null;
  192. }
  193. if (fromHand)
  194. {
  195. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  196. selectHandEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: SelectSourceCard,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: 1,
  202. canNoSelect: true,
  203. canEndNotMax: false,
  204. isShowOpponent: true,
  205. selectCardCoroutine: SelectCardCoroutine,
  206. afterSelectCardCoroutine: null,
  207. mode: SelectHandEffect.Mode.Custom,
  208. cardEffect: activateClass);
  209. selectHandEffect.SetUpCustomMessage("Select 1 option card to use.", "The opponent is selecting 1 option card to use.");
  210. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  211. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  212. cardSources: selectedCards,
  213. activateClass: activateClass,
  214. payCost: false,
  215. root: SelectCardEffect.Root.Hand));
  216. }
  217. else
  218. {
  219. var selectablePermanents = CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent);
  220. if (selectablePermanents == 1) selectedPermament = card.Owner.GetBattleAreaPermanents().Find(CanSelectPermanent);
  221. else
  222. {
  223. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent));
  224. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  225. selectPermanentEffect.SetUp(
  226. selectPlayer: card.Owner,
  227. canTargetCondition: CanSelectPermanent,
  228. canTargetCondition_ByPreSelecetedList: null,
  229. canEndSelectCondition: null,
  230. maxCount: maxCount,
  231. canNoSelect: true,
  232. canEndNotMax: false,
  233. selectPermanentCoroutine: SelectPermamentCoroutine,
  234. afterSelectPermanentCoroutine: null,
  235. mode: SelectPermanentEffect.Mode.Custom,
  236. cardEffect: activateClass);
  237. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  238. }
  239. if (selectedPermament != null)
  240. {
  241. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  242. selectCardEffect.SetUp(
  243. canTargetCondition: SelectSourceCard,
  244. canTargetCondition_ByPreSelecetedList: null,
  245. canEndSelectCondition: null,
  246. canNoSelect: () => true,
  247. selectCardCoroutine: SelectCardCoroutine,
  248. afterSelectCardCoroutine: null,
  249. message: "Select 1 option card to use",
  250. maxCount: 1,
  251. canEndNotMax: false,
  252. isShowOpponent: true,
  253. mode: SelectCardEffect.Mode.Custom,
  254. root: SelectCardEffect.Root.DigivolutionCards,
  255. customRootCardList: selectedPermament.DigivolutionCards,
  256. canLookReverseCard: true,
  257. selectPlayer: card.Owner,
  258. cardEffect: activateClass);
  259. selectCardEffect.SetUpCustomMessage("Select 1 option card to use.", "The opponent is selecting 1 option card to use.");
  260. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  261. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  262. cardSources: selectedCards,
  263. activateClass: activateClass,
  264. payCost: false,
  265. root: SelectCardEffect.Root.DigivolutionCards));
  266. }
  267. }
  268. }
  269. #endregion
  270. }
  271. }
  272. #endregion
  273. #region ESS EoA
  274. if (timing == EffectTiming.OnEndAttack)
  275. {
  276. ActivateClass activateClass = new ActivateClass();
  277. activateClass.SetUpICardEffect("Trash 1 security to unsuspend 1 Digimon", CanUseCondition, card);
  278. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  279. activateClass.SetHashString("ST22_04_EoA");
  280. activateClass.SetIsInheritedEffect(true);
  281. cardEffects.Add(activateClass);
  282. string EffectDiscription()
  283. {
  284. return "[End of Attack] [Once Per Turn] By trashing your top security card, 1 of your Digimon with [Sakuyamon] in its name unsuspends.";
  285. }
  286. bool CanUseCondition(Hashtable hashtable)
  287. {
  288. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  289. CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  290. }
  291. bool CanActivateCondition(Hashtable hashtable)
  292. {
  293. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  294. (card.Owner.SecurityCards.Count >= 1);
  295. }
  296. bool CanSelectPermanentCondition(Permanent permanent)
  297. {
  298. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  299. permanent.TopCard.ContainsCardName("Sakuyamon");
  300. }
  301. IEnumerator ActivateCoroutine(Hashtable hashtable)
  302. {
  303. if (card.Owner.SecurityCards.Count >= 1)
  304. {
  305. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  306. player: card.Owner,
  307. destroySecurityCount: 1,
  308. cardEffect: activateClass,
  309. fromTop: true).DestroySecurity());
  310. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  311. {
  312. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  313. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  314. selectPermanentEffect.SetUp(
  315. selectPlayer: card.Owner,
  316. canTargetCondition: CanSelectPermanentCondition,
  317. canTargetCondition_ByPreSelecetedList: null,
  318. canEndSelectCondition: null,
  319. maxCount: maxCount,
  320. canNoSelect: false,
  321. canEndNotMax: false,
  322. selectPermanentCoroutine: null,
  323. afterSelectPermanentCoroutine: null,
  324. mode: SelectPermanentEffect.Mode.UnTap,
  325. cardEffect: activateClass);
  326. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  327. }
  328. }
  329. }
  330. }
  331. #endregion
  332. return cardEffects;
  333. }
  334. }
  335. }