ST24_06.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // RizeGreymon
  6. namespace DCGO.CardEffects.ST24
  7. {
  8. public class ST24_06 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("GeoGreymon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. if (timing == EffectTiming.None)
  23. {
  24. static bool PermanentCondition(Permanent targetPermanent)
  25. {
  26. return targetPermanent.TopCard.EqualsTraits("DATA SQUAD");
  27. }
  28. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  29. }
  30. #endregion
  31. #region Shared OP/WD/WA
  32. string SharedEffectName = "- 5K DP to 1 enemy Digimon for turn, by trashing 2 bottom face-down cards from your Tamers, may play/use 1 [DATA SQUAD] card with a play/use cost of 5 or less from hand for free";
  33. string SharedEffectHash = "ST24_06_SharedEffect";
  34. CardEffectFactory.ActivateClassesForSharedEffects
  35. (ref cardEffects, timing, card,
  36. SharedEffectName,
  37. SharedActivateCoroutine,
  38. SharedEffectDescription,
  39. optional: false,
  40. maxCountPerTurn: 1,
  41. hashValue: SharedEffectHash,
  42. onPlay: true,
  43. whenDigivolving: true,
  44. whenAttacking: true);
  45. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] 1 of your opponent's Digimon gets -5000 DP for the turn. Then, by trashing 2 bottom face-down cards from under any of your Tamers, you may play or use 1 [DATA SQUAD] trait card with a play cost or use cost of 5 or less from your hand without paying the cost.";
  46. bool CanSelectPermanentConditionForDPMinus(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  49. }
  50. bool TamerWithOneFaceDownSource(Permanent permanent)
  51. {
  52. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  53. && permanent.DigivolutionCards.Any(CanSelectTrashSourceCardCondition);
  54. }
  55. bool TamerWith2OrMoreFaceDownSources(Permanent permanent)
  56. {
  57. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  58. && permanent.DigivolutionCards.Count(CanSelectTrashSourceCardCondition) > 1;
  59. }
  60. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  61. {
  62. return cardSource.IsFlipped;
  63. }
  64. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  65. {
  66. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionForDPMinus));
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectPermanentConditionForDPMinus,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get -5000 DP", "The opponent is selecting 1 Digimon that will get -5000 DP");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -5000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  85. }
  86. if (CardEffectCommons.MatchConditionPermanentCount(TamerWithOneFaceDownSource) > 1 || CardEffectCommons.MatchConditionPermanentCount(TamerWith2OrMoreFaceDownSources) > 0)
  87. {
  88. string selectPlayerMessage = "Will you trash 2 bottom face-down cards from under any of your Tamers?";
  89. string notSelectPlayerMessage = "The opponent is choosing if they will trash 2 bottom face-down cards from under any of your Tamers.";
  90. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  91. {
  92. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  93. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  94. };
  95. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  96. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  97. bool trash = GManager.instance.userSelectionManager.SelectedBoolValue;
  98. if (trash)
  99. {
  100. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  101. int maxCount1 = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(TamerWithOneFaceDownSource));
  102. selectPermanentEffect1.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: TamerWithOneFaceDownSource,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: CanEndSelectCondition,
  107. maxCount: maxCount1,
  108. canNoSelect: false,
  109. canEndNotMax: true,
  110. selectPermanentCoroutine: null,
  111. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  112. mode: SelectPermanentEffect.Mode.Custom,
  113. cardEffect: activateClass);
  114. selectPermanentEffect1.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  115. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  116. bool CanEndSelectCondition(List<Permanent> permanents)
  117. {
  118. return permanents.Count == 2 || (permanents.Count > 0 && permanents[0].DigivolutionCards.Count(CanSelectTrashSourceCardCondition) >= 2);
  119. }
  120. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  121. {
  122. if (permanents.Count == 1)
  123. {
  124. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 2, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  125. }
  126. else
  127. {
  128. foreach (Permanent selectedPermanent in permanents)
  129. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  130. }
  131. }
  132. bool CanSelectCardCondition(CardSource cardSource)
  133. {
  134. return cardSource.EqualsTraits("DATA SQUAD")
  135. && cardSource.GetCostItself <= 5
  136. && ((cardSource.IsOption
  137. && !cardSource.CanNotPlayThisOption)
  138. || (cardSource.HasPlayCost
  139. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass)));
  140. }
  141. CardSource selectCard = null;
  142. List<CardSource> selectedCards = null;
  143. int maxCount2 = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
  144. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  145. selectHandEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanSelectCardCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: maxCount2,
  151. canNoSelect: true,
  152. canEndNotMax: false,
  153. isShowOpponent: true,
  154. selectCardCoroutine: SelectCardCoroutine,
  155. afterSelectCardCoroutine: null,
  156. mode: SelectHandEffect.Mode.Custom,
  157. cardEffect: activateClass);
  158. selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
  159. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  160. yield return StartCoroutine(selectHandEffect.Activate());
  161. IEnumerator SelectCardCoroutine(CardSource cardSource)
  162. {
  163. selectCard = cardSource;
  164. yield return null;
  165. }
  166. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  167. if (selectCard != null)
  168. {
  169. if (selectCard.IsOption)
  170. {
  171. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  172. cardSources: selectedCards,
  173. activateClass: activateClass,
  174. payCost: false,
  175. root: SelectCardEffect.Root.Hand));
  176. }
  177. else
  178. {
  179. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  180. new List<CardSource>() { selectCard },
  181. activateClass: activateClass,
  182. payCost: false,
  183. isTapped: false,
  184. root: SelectCardEffect.Root.Hand,
  185. activateETB: true));
  186. }
  187. }
  188. }
  189. }
  190. }
  191. #endregion
  192. #region Inherited
  193. if (timing == EffectTiming.WhenRemoveField)
  194. {
  195. ActivateClass activateClass = new ActivateClass();
  196. activateClass.SetUpICardEffect("Trash the bottom face-down card from 1 Tamer to not leave", CanUseCondition, card);
  197. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  198. activateClass.SetHashString("ST24_06_Inherited");
  199. activateClass.SetIsInheritedEffect(true);
  200. cardEffects.Add(activateClass);
  201. string EffectDescription()
  202. {
  203. return "[All Turns] [Once Per Turn] When this Digimon with [ShineGreymon] in its name or the [DATA SQUAD] trait would leave the battle area, by trashing the bottom face-down card from under any of your Tamers, it doesn't leave";
  204. }
  205. bool CanUseCondition(Hashtable hashtable)
  206. {
  207. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  208. && (card.PermanentOfThisCard().TopCard.ContainsCardName("ShineGreymon")
  209. || card.PermanentOfThisCard().TopCard.EqualsTraits("DATA SQUAD"))
  210. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  211. }
  212. bool CanActivateCondition(Hashtable hashtable)
  213. {
  214. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  215. && CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource);
  216. }
  217. IEnumerator ActivateCoroutine(Hashtable hashtable)
  218. {
  219. if (CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource))
  220. {
  221. Permanent thisCardPermanent = card.PermanentOfThisCard();
  222. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  223. selectPermanentEffect.SetUp(
  224. selectPlayer: card.Owner,
  225. canTargetCondition: TamerWithOneFaceDownSource,
  226. canTargetCondition_ByPreSelecetedList: null,
  227. canEndSelectCondition: null,
  228. maxCount: 1,
  229. canNoSelect: true,
  230. canEndNotMax: false,
  231. selectPermanentCoroutine: SelectPermanentCoroutine,
  232. afterSelectPermanentCoroutine: null,
  233. mode: SelectPermanentEffect.Mode.Custom,
  234. cardEffect: activateClass);
  235. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  236. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  237. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  238. {
  239. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: new List<Permanent>() { permanent }[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  240. thisCardPermanent.willBeRemoveField = false;
  241. thisCardPermanent.HideDeleteEffect();
  242. thisCardPermanent.HideHandBounceEffect();
  243. thisCardPermanent.HideDeckBounceEffect();
  244. thisCardPermanent.HideWillRemoveFieldEffect();
  245. yield return null;
  246. }
  247. }
  248. }
  249. }
  250. #endregion
  251. return cardEffects;
  252. }
  253. }
  254. }