ST24_10.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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, hashtable).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.MatchConditionPermanentCount(TamerWithOneFaceDownSource) > 1 || CardEffectCommons.MatchConditionPermanentCount(TamerWith2OrMoreFaceDownSources) > 0)
  104. {
  105. string selectPlayerMessage = "Will you trash 2 bottom face-down cards from under any of your Tamers?";
  106. string notSelectPlayerMessage = "The opponent is choosing if they will trash 2 bottom face-down cards from under any of your Tamers.";
  107. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  108. {
  109. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  110. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  111. };
  112. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  113. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  114. bool trash = GManager.instance.userSelectionManager.SelectedBoolValue;
  115. if (trash)
  116. {
  117. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  118. int maxCount1 = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(TamerWithOneFaceDownSource));
  119. selectPermanentEffect1.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: TamerWithOneFaceDownSource,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: CanEndSelectCondition,
  124. maxCount: maxCount1,
  125. canNoSelect: false,
  126. canEndNotMax: true,
  127. selectPermanentCoroutine: null,
  128. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  129. mode: SelectPermanentEffect.Mode.Custom,
  130. cardEffect: activateClass);
  131. 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");
  132. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  133. bool CanEndSelectCondition(List<Permanent> permanents)
  134. {
  135. return permanents.Count == 2 || (permanents.Count > 0 && permanents[0].DigivolutionCards.Count(CanSelectTrashSourceCardCondition) >= 2);
  136. }
  137. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  138. {
  139. if (permanents.Count == 1)
  140. {
  141. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 2, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  142. }
  143. else
  144. {
  145. foreach (Permanent selectedPermanent in permanents)
  146. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  147. }
  148. }
  149. bool CanSelectCardCondition(CardSource cardSource)
  150. {
  151. return cardSource.EqualsTraits("DATA SQUAD");
  152. }
  153. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  154. targetPermanent: card.PermanentOfThisCard(),
  155. cardCondition: CanSelectCardCondition,
  156. payCost: false,
  157. reduceCostTuple: null,
  158. fixedCostTuple: null,
  159. ignoreDigivolutionRequirementFixedCost: -1,
  160. isHand: true, activateClass: activateClass,
  161. successProcess: null));
  162. }
  163. }
  164. }
  165. #endregion
  166. #region Inherited
  167. if (timing == EffectTiming.WhenRemoveField)
  168. {
  169. ActivateClass activateClass = new ActivateClass();
  170. activateClass.SetUpICardEffect("Trash the bottom face-down card from 1 Tamer to not leave", CanUseCondition, card);
  171. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  172. activateClass.SetHashString("ST24_10_Inherited");
  173. activateClass.SetIsInheritedEffect(true);
  174. cardEffects.Add(activateClass);
  175. string EffectDescription()
  176. {
  177. 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.";
  178. }
  179. bool CanUseCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  182. && (card.PermanentOfThisCard().TopCard.ContainsCardName("Rosemon")
  183. || card.PermanentOfThisCard().TopCard.EqualsTraits("DATA SQUAD"))
  184. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  185. }
  186. bool CanActivateCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  189. && CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource);
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. if (CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource))
  194. {
  195. Permanent thisCardPermanent = card.PermanentOfThisCard();
  196. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  197. selectPermanentEffect.SetUp(
  198. selectPlayer: card.Owner,
  199. canTargetCondition: TamerWithOneFaceDownSource,
  200. canTargetCondition_ByPreSelecetedList: null,
  201. canEndSelectCondition: null,
  202. maxCount: 1,
  203. canNoSelect: true,
  204. canEndNotMax: false,
  205. selectPermanentCoroutine: SelectPermanentCoroutine,
  206. afterSelectPermanentCoroutine: null,
  207. mode: SelectPermanentEffect.Mode.Custom,
  208. cardEffect: activateClass);
  209. 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");
  210. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  211. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  212. {
  213. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: new List<Permanent>() { permanent }[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  214. thisCardPermanent.willBeRemoveField = false;
  215. thisCardPermanent.HideDeleteEffect();
  216. thisCardPermanent.HideHandBounceEffect();
  217. thisCardPermanent.HideDeckBounceEffect();
  218. thisCardPermanent.HideWillRemoveFieldEffect();
  219. yield return null;
  220. }
  221. }
  222. }
  223. }
  224. #endregion
  225. return cardEffects;
  226. }
  227. }
  228. }