ST24_10.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Lilamon
  6. namespace DCGO.CardEffects.ST24
  7. {
  8. public class ST24_10 : 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.EqualsTraits("DATA SQUAD");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Shared OP/WD/WA
  24. string SharedEffectName = "Suspend 1 enemy Digimon/Tamer, by trashing 2 bottom face-down cards from your Tamers, may digivolve into a [DATA SQUAD] in the hand for free";
  25. string SharedEffectHash = "ST24_10_SharedEffect";
  26. CardEffectFactory.ActivateClassesForSharedEffects
  27. (ref cardEffects, timing, card,
  28. SharedEffectName,
  29. SharedActivateCoroutine,
  30. SharedEffectDescription,
  31. optional: false,
  32. maxCountPerTurn: 1,
  33. hashValue: SharedEffectHash,
  34. onPlay: true,
  35. whenDigivolving: true,
  36. whenAttacking: true);
  37. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] Suspend 1 of your opponent's Digimon or Tamers. It can't unsuspend until their turn ends. Then, by trashing 2 bottom face-down cards from under any of your Tamers, this Digimon may digivolve into a [DATA SQUAD] trait Digimon card in the hand without paying the cost.";
  38. bool CanSelectPermanentConditionForSuspend(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  41. && (permanent.IsDigimon
  42. || permanent.IsTamer);
  43. }
  44. bool TamerWithOneFaceDownSource(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  47. && permanent.DigivolutionCards.Any(CanSelectTrashSourceCardCondition);
  48. }
  49. bool TamerWith2OrMoreFaceDownSources(Permanent permanent)
  50. {
  51. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  52. && permanent.DigivolutionCards.Count(CanSelectTrashSourceCardCondition) > 1;
  53. }
  54. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  55. {
  56. return cardSource.IsFlipped;
  57. }
  58. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  59. {
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionForSuspend));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentConditionForSuspend,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer to suspend and give can't unsuspend", "The opponent is selecting 1 Digimon/Tamer to suspend and give can't unsuspend");
  75. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  76. {
  77. List<Permanent> _targetPermanents = new List<Permanent>();
  78. Permanent selectedPermanent = permanent;
  79. _targetPermanents.Add(selectedPermanent);
  80. if (selectedPermanent != null)
  81. {
  82. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(_targetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  83. CanNotUnsuspendClass canNotUnsuspendClass = new CanNotUnsuspendClass();
  84. canNotUnsuspendClass.SetUpICardEffect("Can't Unsuspend", CanUseCondition1, card);
  85. canNotUnsuspendClass.SetUpCanNotUntapClass(PermanentCondition: PermanentCondition);
  86. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotUnsuspendClass);
  87. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  90. }
  91. bool CanUseCondition1(Hashtable hashtable)
  92. {
  93. return selectedPermanent.TopCard != null
  94. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  95. }
  96. bool PermanentCondition(Permanent permanent)
  97. {
  98. return permanent == selectedPermanent;
  99. }
  100. }
  101. }
  102. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  103. if (CardEffectCommons.HasMatchConditionPermanent(TamerWith2OrMoreFaceDownSources) || CardEffectCommons.MatchConditionPermanentCount(TamerWithOneFaceDownSource) > 1)
  104. {
  105. bool trashed = false;
  106. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. int maxCount1 = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(TamerWithOneFaceDownSource));
  108. selectPermanentEffect1.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: TamerWithOneFaceDownSource,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: CanEndSelectCondition,
  113. maxCount: maxCount1,
  114. canNoSelect: true,
  115. canEndNotMax: true,
  116. selectPermanentCoroutine: null,
  117. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  118. mode: SelectPermanentEffect.Mode.Custom,
  119. cardEffect: activateClass);
  120. 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");
  121. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  122. bool CanEndSelectCondition(List<Permanent> permanents)
  123. {
  124. return permanents.Count == 2
  125. || (permanents.Count > 0
  126. && permanents[0].DigivolutionCards.Count(CanSelectTrashSourceCardCondition) >= 2);
  127. }
  128. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  129. {
  130. if (permanents.Count == 1)
  131. {
  132. trashed = true;
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 2, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  134. }
  135. else if (permanents.Count == 2)
  136. {
  137. trashed = true;
  138. foreach (Permanent selectedPermanent in permanents)
  139. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  140. }
  141. }
  142. if (trashed)
  143. {
  144. bool CanSelectCardCondition(CardSource cardSource)
  145. {
  146. return cardSource.EqualsTraits("DATA SQUAD");
  147. }
  148. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  149. targetPermanent: card.PermanentOfThisCard(),
  150. cardCondition: CanSelectCardCondition,
  151. payCost: false,
  152. reduceCostTuple: null,
  153. fixedCostTuple: null,
  154. ignoreDigivolutionRequirementFixedCost: -1,
  155. isHand: true, activateClass: activateClass,
  156. successProcess: null));
  157. }
  158. }
  159. }
  160. #endregion
  161. #region Inherited
  162. if (timing == EffectTiming.WhenRemoveField)
  163. {
  164. ActivateClass activateClass = new ActivateClass();
  165. activateClass.SetUpICardEffect("Trash the bottom face-down card from 1 Tamer to not leave", CanUseCondition, card);
  166. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  167. activateClass.SetHashString("ST24_10_Inherited");
  168. activateClass.SetIsInheritedEffect(true);
  169. cardEffects.Add(activateClass);
  170. string EffectDescription()
  171. {
  172. return "[All Turns] [Once Per Turn] When this Digimon with [Rosemon] 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.";
  173. }
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  177. && (card.PermanentOfThisCard().TopCard.ContainsCardName("Rosemon")
  178. || card.PermanentOfThisCard().TopCard.EqualsTraits("DATA SQUAD"))
  179. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  180. }
  181. bool CanActivateCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  184. && CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource);
  185. }
  186. IEnumerator ActivateCoroutine(Hashtable hashtable)
  187. {
  188. if (CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource))
  189. {
  190. Permanent thisCardPermanent = card.PermanentOfThisCard();
  191. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  192. selectPermanentEffect.SetUp(
  193. selectPlayer: card.Owner,
  194. canTargetCondition: TamerWithOneFaceDownSource,
  195. canTargetCondition_ByPreSelecetedList: null,
  196. canEndSelectCondition: null,
  197. maxCount: 1,
  198. canNoSelect: true,
  199. canEndNotMax: false,
  200. selectPermanentCoroutine: SelectPermanentCoroutine,
  201. afterSelectPermanentCoroutine: null,
  202. mode: SelectPermanentEffect.Mode.Custom,
  203. cardEffect: activateClass);
  204. 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");
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  206. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  207. {
  208. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: new List<Permanent>() { permanent }[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  209. thisCardPermanent.willBeRemoveField = false;
  210. thisCardPermanent.HideDeleteEffect();
  211. thisCardPermanent.HideHandBounceEffect();
  212. thisCardPermanent.HideDeckBounceEffect();
  213. thisCardPermanent.HideWillRemoveFieldEffect();
  214. yield return null;
  215. }
  216. }
  217. }
  218. }
  219. #endregion
  220. return cardEffects;
  221. }
  222. }
  223. }