ST22_05.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Sakuyamon ACE
  5. namespace DCGO.CardEffects.ST22
  6. {
  7. public class ST22_05 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Alt Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.EqualsCardName("Sakuyamon: Maid Mode");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 1, true, card, null));
  21. }
  22. #endregion
  23. #region Blast Digivolve
  24. if (timing == EffectTiming.OnCounterTiming)
  25. {
  26. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  27. }
  28. #endregion
  29. #region Alliance
  30. if (timing == EffectTiming.OnAllyAttack)
  31. {
  32. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #endregion
  36. #region OP/WD/WA Shared
  37. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  38. {
  39. #region Play Pipe Fox Token
  40. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  41. {
  42. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  43. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  44. };
  45. string selectPlayerMessage = "Will you play a [Pipe Fox] token?";
  46. string notSelectPlayerMessage = "The opponent is choosing to play a token";
  47. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  48. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  49. bool summonToken = GManager.instance.userSelectionManager.SelectedBoolValue;
  50. if (summonToken) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPipeFox(activateClass));
  51. #endregion
  52. #region Use Option Card
  53. bool SelectSourceCard(CardSource source)
  54. {
  55. return source.IsOption
  56. && !source.CanNotPlayThisOption
  57. && (source.EqualsTraits("Onmyōjutsu") || source.EqualsTraits("Plug-In"));
  58. }
  59. bool CanSelectPermanent(Permanent permanent)
  60. {
  61. return permanent.IsTamer
  62. && permanent.DigivolutionCards.Exists(SelectSourceCard);
  63. }
  64. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, SelectSourceCard);
  65. bool canSelectTamer = CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent);
  66. if (canSelectHand || canSelectTamer)
  67. {
  68. if (canSelectHand && canSelectTamer)
  69. {
  70. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  71. {
  72. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  73. new SelectionElement<bool>(message: $"From tamer", value : false, spriteIndex: 1),
  74. };
  75. string selectPlayerMessage1 = "From which area do you select a card?";
  76. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  77. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  78. }
  79. else
  80. {
  81. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  82. }
  83. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  84. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  85. List<CardSource> selectedCards = new List<CardSource>();
  86. IEnumerator SelectCardCoroutine(CardSource cardSource)
  87. {
  88. selectedCards.Add(cardSource);
  89. yield return null;
  90. }
  91. Permanent selectedPermament = null;
  92. IEnumerator SelectPermamentCoroutine(Permanent permanent)
  93. {
  94. selectedPermament = permanent;
  95. yield return null;
  96. }
  97. if (fromHand)
  98. {
  99. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  100. selectHandEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: SelectSourceCard,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: 1,
  106. canNoSelect: true,
  107. canEndNotMax: false,
  108. isShowOpponent: true,
  109. selectCardCoroutine: SelectCardCoroutine,
  110. afterSelectCardCoroutine: null,
  111. mode: SelectHandEffect.Mode.Custom,
  112. cardEffect: activateClass);
  113. selectHandEffect.SetUpCustomMessage("Select 1 option to use.", "The opponent is selecting 1 option to use.");
  114. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  115. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  116. cardSources: selectedCards,
  117. activateClass: activateClass,
  118. payCost: false,
  119. root: SelectCardEffect.Root.Hand));
  120. }
  121. else
  122. {
  123. var selectablePermanents = CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent);
  124. if (selectablePermanents == 1) selectedPermament = card.Owner.GetBattleAreaPermanents().Find(CanSelectPermanent);
  125. else
  126. {
  127. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent));
  128. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  129. selectPermanentEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: CanSelectPermanent,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount,
  135. canNoSelect: true,
  136. canEndNotMax: false,
  137. selectPermanentCoroutine: SelectPermamentCoroutine,
  138. afterSelectPermanentCoroutine: null,
  139. mode: SelectPermanentEffect.Mode.Custom,
  140. cardEffect: activateClass);
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. }
  143. if (selectedPermament != null)
  144. {
  145. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  146. selectCardEffect.SetUp(
  147. canTargetCondition: SelectSourceCard,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. canNoSelect: () => true,
  151. selectCardCoroutine: SelectCardCoroutine,
  152. afterSelectCardCoroutine: null,
  153. message: "Select 1 option card to use",
  154. maxCount: 1,
  155. canEndNotMax: false,
  156. isShowOpponent: true,
  157. mode: SelectCardEffect.Mode.Custom,
  158. root: SelectCardEffect.Root.DigivolutionCards,
  159. customRootCardList: selectedPermament.DigivolutionCards,
  160. canLookReverseCard: true,
  161. selectPlayer: card.Owner,
  162. cardEffect: activateClass);
  163. selectCardEffect.SetUpCustomMessage("Select 1 option card to use.", "The opponent is selecting 1 option card to use.");
  164. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  165. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  166. cardSources: selectedCards,
  167. activateClass: activateClass,
  168. payCost: false,
  169. root: SelectCardEffect.Root.DigivolutionCards));
  170. }
  171. }
  172. }
  173. #endregion
  174. }
  175. #endregion
  176. #region On Play - OPT
  177. if (timing == EffectTiming.OnEnterFieldAnyone)
  178. {
  179. ActivateClass activateClass = new ActivateClass();
  180. activateClass.SetUpICardEffect("You may then 1 [Pipe Fox] Token, then you may use 1 [Onmyōjutsu] or [Plug-In] trait in hand or under a tamer", CanUseCondition, card);
  181. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, EffectDiscription());
  182. activateClass.SetHashString("ST22-005");
  183. cardEffects.Add(activateClass);
  184. string EffectDiscription()
  185. {
  186. return "[On Play] [Once Per Turn] You may play 1 [Pipe Fox] Token. Then, 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.";
  187. }
  188. bool CanUseCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  191. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  192. }
  193. bool CanActivateCondition(Hashtable hashtable)
  194. {
  195. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  196. }
  197. }
  198. #endregion
  199. #region When Digivolving - OPT
  200. if (timing == EffectTiming.OnEnterFieldAnyone)
  201. {
  202. ActivateClass activateClass = new ActivateClass();
  203. activateClass.SetUpICardEffect("You may then 1 [Pipe Fox] Token, then you may use 1 [Onmyōjutsu] or [Plug-In] trait in hand or under a tamer", CanUseCondition, card);
  204. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, EffectDiscription());
  205. activateClass.SetHashString("ST22-005");
  206. cardEffects.Add(activateClass);
  207. string EffectDiscription()
  208. {
  209. return "[When Digivolving] [Once Per Turn] You may play 1 [Pipe Fox] Token. Then, 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.";
  210. }
  211. bool CanUseCondition(Hashtable hashtable)
  212. {
  213. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  214. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  215. }
  216. bool CanActivateCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  219. }
  220. }
  221. #endregion
  222. #region When Attacking - OPT
  223. if (timing == EffectTiming.OnAllyAttack)
  224. {
  225. ActivateClass activateClass = new ActivateClass();
  226. activateClass.SetUpICardEffect("You may then 1 [Pipe Fox] Token, then you may use 1 [Onmyōjutsu] or [Plug-In] trait in hand or under a tamer", CanUseCondition, card);
  227. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, EffectDiscription());
  228. activateClass.SetHashString("ST22-005");
  229. cardEffects.Add(activateClass);
  230. string EffectDiscription()
  231. {
  232. return "[When Attacking] [Once Per Turn] You may play 1 [Pipe Fox] Token. Then, 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.";
  233. }
  234. bool CanUseCondition(Hashtable hashtable)
  235. {
  236. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  237. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  238. }
  239. bool CanActivateCondition(Hashtable hashtable)
  240. {
  241. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  242. }
  243. }
  244. #endregion
  245. return cardEffects;
  246. }
  247. }
  248. }