ST22_06.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Sakuyamon: Maid Mode
  5. namespace DCGO.CardEffects.ST22
  6. {
  7. public class ST22_06 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent permanent)
  16. {
  17. return permanent.TopCard.EqualsCardName("Sakuyamon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 1, true, card, null));
  20. }
  21. #endregion
  22. #region OP/WD Shared
  23. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  24. {
  25. #region Use Option Card
  26. bool SelectSourceCard(CardSource source)
  27. {
  28. return source.IsOption
  29. && !source.CanNotPlayThisOption
  30. && (source.EqualsTraits("Onmyōjutsu") || source.EqualsTraits("Plug-In"));
  31. }
  32. bool CanSelectPermanent(Permanent permanent)
  33. {
  34. return permanent.IsTamer
  35. && permanent.DigivolutionCards.Exists(SelectSourceCard);
  36. }
  37. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, SelectSourceCard);
  38. bool canSelectTamer = CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent);
  39. if (canSelectHand || canSelectTamer)
  40. {
  41. if (canSelectHand && canSelectTamer)
  42. {
  43. List<SelectionElement<bool>> selectionElements2 = new List<SelectionElement<bool>>()
  44. {
  45. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  46. new SelectionElement<bool>(message: $"From tamer", value : false, spriteIndex: 1),
  47. };
  48. string selectPlayerMessage2 = "From which area do you select a card?";
  49. string notSelectPlayerMessage2 = "The opponent is choosing from which area to select a card.";
  50. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements2, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage2, notSelectPlayerMessage: notSelectPlayerMessage2);
  51. }
  52. else
  53. {
  54. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  55. }
  56. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  57. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  58. List<CardSource> selectedCards = new List<CardSource>();
  59. IEnumerator SelectCardCoroutine(CardSource cardSource)
  60. {
  61. selectedCards.Add(cardSource);
  62. yield return null;
  63. }
  64. Permanent selectedPermament = null;
  65. IEnumerator SelectPermamentCoroutine(Permanent permanent)
  66. {
  67. selectedPermament = permanent;
  68. yield return null;
  69. }
  70. if (fromHand)
  71. {
  72. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  73. selectHandEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: SelectSourceCard,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: 1,
  79. canNoSelect: true,
  80. canEndNotMax: false,
  81. isShowOpponent: true,
  82. selectCardCoroutine: SelectCardCoroutine,
  83. afterSelectCardCoroutine: null,
  84. mode: SelectHandEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectHandEffect.SetUpCustomMessage("Select 1 option card to use.", "The opponent is selecting 1 option card to use.");
  87. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  88. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  89. cardSources: selectedCards,
  90. activateClass: activateClass,
  91. payCost: false,
  92. root: SelectCardEffect.Root.Hand));
  93. }
  94. else
  95. {
  96. var selectablePermanents = CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent);
  97. if (selectablePermanents == 1) selectedPermament = card.Owner.GetBattleAreaPermanents().Find(CanSelectPermanent);
  98. else
  99. {
  100. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent));
  101. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  102. selectPermanentEffect.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: CanSelectPermanent,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. maxCount: maxCount,
  108. canNoSelect: true,
  109. canEndNotMax: false,
  110. selectPermanentCoroutine: SelectPermamentCoroutine,
  111. afterSelectPermanentCoroutine: null,
  112. mode: SelectPermanentEffect.Mode.Custom,
  113. cardEffect: activateClass);
  114. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  115. }
  116. if (selectedPermament != null)
  117. {
  118. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  119. selectCardEffect.SetUp(
  120. canTargetCondition: SelectSourceCard,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. canNoSelect: () => true,
  124. selectCardCoroutine: SelectCardCoroutine,
  125. afterSelectCardCoroutine: null,
  126. message: "Select 1 option card to use",
  127. maxCount: 1,
  128. canEndNotMax: false,
  129. isShowOpponent: true,
  130. mode: SelectCardEffect.Mode.Custom,
  131. root: SelectCardEffect.Root.DigivolutionCards,
  132. customRootCardList: selectedPermament.DigivolutionCards,
  133. canLookReverseCard: true,
  134. selectPlayer: card.Owner,
  135. cardEffect: activateClass);
  136. selectCardEffect.SetUpCustomMessage("Select 1 option card to use.", "The opponent is selecting 1 option card to use.");
  137. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  138. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  139. cardSources: selectedCards,
  140. activateClass: activateClass,
  141. payCost: false,
  142. root: SelectCardEffect.Root.DigivolutionCards));
  143. }
  144. }
  145. }
  146. #endregion
  147. }
  148. #endregion
  149. #region On Play - OPT
  150. if (timing == EffectTiming.OnEnterFieldAnyone)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect("You may use 1 [Onmyōjutsu] or [Plug-In] trait in hand or under a tamer", CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscription());
  155. cardEffects.Add(activateClass);
  156. string EffectDiscription()
  157. {
  158. return "[On Play] 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.";
  159. }
  160. bool CanUseCondition(Hashtable hashtable)
  161. {
  162. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  163. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  164. }
  165. bool CanActivateCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  168. }
  169. }
  170. #endregion
  171. #region When Digivolving - OPT
  172. if (timing == EffectTiming.OnEnterFieldAnyone)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect("You may use 1 [Onmyōjutsu] or [Plug-In] trait in hand or under a tamer", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscription());
  177. cardEffects.Add(activateClass);
  178. string EffectDiscription()
  179. {
  180. return "[When Digivolving] 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.";
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  185. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  190. }
  191. }
  192. #endregion
  193. #region All Turns - On Lose Security / On Use Option - OPT
  194. if (timing == EffectTiming.OnLoseSecurity || timing == EffectTiming.OnUseOption)
  195. {
  196. ActivateClass activateClass = new ActivateClass();
  197. activateClass.SetUpICardEffect("By placing 1 Digimon in Security, trash top Security", CanUseCondition, card);
  198. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  199. activateClass.SetHashString("ST22-06_AT");
  200. cardEffects.Add(activateClass);
  201. string EffectDescription()
  202. {
  203. return
  204. "[All Turns] [Once Per Turn] When you use Option cards or your security stack is removed from, by placing 1 of your opponent's Digimon with the lowest DP as the bottom security card, trash their top security card.";
  205. }
  206. bool CanUseCondition(Hashtable hashtable)
  207. {
  208. if (CardEffectCommons.IsExistOnBattleArea(card)
  209. && (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner)
  210. || CardEffectCommons.CanTriggerWhenOwnerUseOption(hashtable, null, null, card)))
  211. {
  212. return true;
  213. }
  214. return false;
  215. }
  216. bool CanActivateCondition(Hashtable hashtable)
  217. {
  218. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  219. && CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition) >= 1)
  220. {
  221. return true;
  222. }
  223. return false;
  224. }
  225. bool CanSelectPermanentCondition(Permanent permanent)
  226. {
  227. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  228. {
  229. if (permanent.IsDigimon)
  230. {
  231. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  232. {
  233. if (CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy))
  234. {
  235. return true;
  236. }
  237. }
  238. }
  239. }
  240. return false;
  241. }
  242. IEnumerator ActivateCoroutine(Hashtable hashtable)
  243. {
  244. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  245. {
  246. Permanent selectedPermanent = null;
  247. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  248. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  249. selectPermanentEffect.SetUp(
  250. selectPlayer: card.Owner,
  251. canTargetCondition: CanSelectPermanentCondition,
  252. canTargetCondition_ByPreSelecetedList: null,
  253. canEndSelectCondition: null,
  254. maxCount: maxCount,
  255. canNoSelect: true,
  256. canEndNotMax: false,
  257. selectPermanentCoroutine: SelectPermanentCoroutine,
  258. afterSelectPermanentCoroutine: null,
  259. mode: SelectPermanentEffect.Mode.Custom,
  260. cardEffect: activateClass);
  261. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in security", "The opponent is selecting 1 Digimon place in security.");
  262. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  263. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  264. {
  265. selectedPermanent = permanent;
  266. yield return null;
  267. }
  268. if (selectedPermanent != null)
  269. {
  270. if (selectedPermanent.TopCard.Owner.CanAddSecurity(activateClass))
  271. {
  272. CardSource topCard = selectedPermanent.TopCard;
  273. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlacePermanentInSecurityAndProcessAccordingToResult(
  274. targetPermanent: selectedPermanent,
  275. activateClass: activateClass,
  276. toTop: false,
  277. SuccessProcess));
  278. IEnumerator SuccessProcess(CardSource cardSource)
  279. {
  280. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  281. player: card.Owner.Enemy,
  282. destroySecurityCount: 1,
  283. cardEffect: activateClass,
  284. fromTop: true).DestroySecurity());
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. #endregion
  292. return cardEffects;
  293. }
  294. }
  295. }