ST24_06.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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.HasMatchConditionPermanent(TamerWith2OrMoreFaceDownSources) || CardEffectCommons.MatchConditionPermanentCount(TamerWithOneFaceDownSource) > 1)
  87. {
  88. bool trashed = false;
  89. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  90. int maxCount1 = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(TamerWithOneFaceDownSource));
  91. selectPermanentEffect1.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: TamerWithOneFaceDownSource,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: CanEndSelectCondition,
  96. maxCount: maxCount1,
  97. canNoSelect: true,
  98. canEndNotMax: true,
  99. selectPermanentCoroutine: null,
  100. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  101. mode: SelectPermanentEffect.Mode.Custom,
  102. cardEffect: activateClass);
  103. selectPermanentEffect1.SetUpCustomMessage("Select all Tamer(s) to trash bottom face-down cards from", "The opponent is selecting Tamer(s) to trash bottom face-down cards from");
  104. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  105. bool CanEndSelectCondition(List<Permanent> permanents)
  106. {
  107. return permanents.Count == 2
  108. || (permanents.Count > 0
  109. && permanents[0].DigivolutionCards.Count(CanSelectTrashSourceCardCondition) >= 2);
  110. }
  111. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  112. {
  113. if (permanents.Count == 1)
  114. {
  115. trashed = true;
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 2, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  117. }
  118. else if (permanents.Count == 2)
  119. {
  120. trashed = true;
  121. foreach (Permanent selectedPermanent in permanents)
  122. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  123. }
  124. }
  125. if (trashed)
  126. {
  127. bool CanSelectCardCondition(CardSource cardSource)
  128. {
  129. return cardSource.EqualsTraits("DATA SQUAD")
  130. && cardSource.GetCostItself <= 5
  131. && ((cardSource.IsOption
  132. && !cardSource.CanNotPlayThisOption)
  133. || (cardSource.HasPlayCost
  134. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass)));
  135. }
  136. CardSource selectedCard = null;
  137. List<CardSource> selectedCards = new List<CardSource>();
  138. int maxCount2 = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
  139. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  140. selectHandEffect.SetUp(
  141. selectPlayer: card.Owner,
  142. canTargetCondition: CanSelectCardCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. maxCount: maxCount2,
  146. canNoSelect: true,
  147. canEndNotMax: false,
  148. isShowOpponent: true,
  149. selectCardCoroutine: SelectCardCoroutine,
  150. afterSelectCardCoroutine: null,
  151. mode: SelectHandEffect.Mode.Custom,
  152. cardEffect: activateClass);
  153. selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
  154. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  155. IEnumerator SelectCardCoroutine(CardSource cardSource)
  156. {;
  157. selectedCard = cardSource;
  158. yield return null;
  159. }
  160. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  161. if (selectedCard != null)
  162. {
  163. if (selectedCard.IsOption)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  166. cardSources: new List<CardSource> { selectedCard },
  167. activateClass: activateClass,
  168. payCost: false,
  169. root: SelectCardEffect.Root.Hand));
  170. }
  171. else
  172. {
  173. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  174. cardSources: new List<CardSource> { selectedCard },
  175. activateClass: activateClass,
  176. payCost: false,
  177. isTapped: false,
  178. root: SelectCardEffect.Root.Hand,
  179. activateETB: true));
  180. }
  181. }
  182. }
  183. }
  184. }
  185. #endregion
  186. #region Inherited
  187. if (timing == EffectTiming.WhenRemoveField)
  188. {
  189. ActivateClass activateClass = new ActivateClass();
  190. activateClass.SetUpICardEffect("Trash the bottom face-down card from 1 Tamer to not leave", CanUseCondition, card);
  191. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  192. activateClass.SetHashString("ST24_06_Inherited");
  193. activateClass.SetIsInheritedEffect(true);
  194. cardEffects.Add(activateClass);
  195. string EffectDescription()
  196. {
  197. 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";
  198. }
  199. bool CanUseCondition(Hashtable hashtable)
  200. {
  201. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  202. && (card.PermanentOfThisCard().TopCard.ContainsCardName("ShineGreymon")
  203. || card.PermanentOfThisCard().TopCard.EqualsTraits("DATA SQUAD"))
  204. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  209. && CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource);
  210. }
  211. IEnumerator ActivateCoroutine(Hashtable hashtable)
  212. {
  213. if (CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource))
  214. {
  215. Permanent thisCardPermanent = card.PermanentOfThisCard();
  216. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  217. selectPermanentEffect.SetUp(
  218. selectPlayer: card.Owner,
  219. canTargetCondition: TamerWithOneFaceDownSource,
  220. canTargetCondition_ByPreSelecetedList: null,
  221. canEndSelectCondition: null,
  222. maxCount: 1,
  223. canNoSelect: true,
  224. canEndNotMax: false,
  225. selectPermanentCoroutine: SelectPermanentCoroutine,
  226. afterSelectPermanentCoroutine: null,
  227. mode: SelectPermanentEffect.Mode.Custom,
  228. cardEffect: activateClass);
  229. 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");
  230. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  231. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  232. {
  233. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: new List<Permanent>() { permanent }[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  234. thisCardPermanent.willBeRemoveField = false;
  235. thisCardPermanent.HideDeleteEffect();
  236. thisCardPermanent.HideHandBounceEffect();
  237. thisCardPermanent.HideDeckBounceEffect();
  238. thisCardPermanent.HideWillRemoveFieldEffect();
  239. yield return null;
  240. }
  241. }
  242. }
  243. }
  244. #endregion
  245. return cardEffects;
  246. }
  247. }
  248. }