EX11_066.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Xeno
  6. namespace DCGO.CardEffects.EX11
  7. {
  8. public class EX11_066 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Name Rule
  14. if (timing == EffectTiming.None)
  15. {
  16. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  17. changeCardNamesClass.SetUpICardEffect("Also treated as [Zenith]", CanUseCondition, card);
  18. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  19. cardEffects.Add(changeCardNamesClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  25. {
  26. if (cardSource == card)
  27. {
  28. CardNames.Add("Zenith");
  29. }
  30. return CardNames;
  31. }
  32. }
  33. #endregion
  34. #region Shared OP / SOYMP
  35. string SharedEffectName = "Trash 1 [Vemmon] in text to <Draw 1> and gain 1 memory";
  36. CardEffectFactory.ActivateClassesForSharedEffects
  37. (ref cardEffects, timing, card,
  38. SharedEffectName,
  39. SharedActivateCoroutine,
  40. SharedEffectDescription,
  41. additionalActivateCondition: AdditionalActivateCondition,
  42. optional: false,
  43. isSkippable: true,
  44. maxCountPerTurn: -1,
  45. onPlay: true,
  46. startOfYourMainPhase: true);
  47. string SharedEffectDescription(string tag) => $"[{tag}] By trashing 1 card with [Vemmon] in its text from your hand, <Draw 1> and gain 1 memory.";
  48. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  49. {
  50. return card.Owner.HandCards.Count(HasVemmonArchetype) >= 1;
  51. }
  52. bool HasVemmonArchetype(CardSource cardSource) => cardSource.HasText("Vemmon");
  53. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  54. {
  55. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  56. selectHandEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: HasVemmonArchetype,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: 1,
  62. canNoSelect: true,
  63. canEndNotMax: false,
  64. isShowOpponent: true,
  65. selectCardCoroutine: null,
  66. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  67. mode: SelectHandEffect.Mode.Discard,
  68. cardEffect: activateClass);
  69. selectHandEffect.SetUpCustomMessage("Select 1 Card to trash.", "The opponent is selecting 1 card to trash from their hand.");
  70. yield return StartCoroutine(selectHandEffect.Activate());
  71. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  72. {
  73. if (cardSources.Count >= 1)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  76. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  77. }
  78. }
  79. }
  80. #endregion
  81. #region All Turns
  82. if (timing == EffectTiming.OnEnterFieldAnyone)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Reveal 2. Place all [Vemmon] under played or digivolved digimon, trash the rest.", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  87. cardEffects.Add(activateClass);
  88. string EffectDescription() => "[All Turns] When your Digimon are played or digivolve, if any of them have [Vemmon] in their texts, by suspending this Tamer, reveal the top 2 cards of your deck. Place all [Vemmon] among them as any of those Digimon's bottom digivolution card. Trash the rest.";
  89. bool CanUseCondition(Hashtable hashtable)
  90. {
  91. return CardEffectCommons.IsExistOnBattleArea(card)
  92. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)
  93. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition));
  94. }
  95. bool CanActivateCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.IsExistOnBattleArea(card)
  98. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  99. }
  100. bool PermanentCondition(Permanent permanent)
  101. {
  102. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  103. && permanent.TopCard.HasText("Vemmon");
  104. }
  105. IEnumerator ActivateCoroutine(Hashtable hashtable)
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent> { card.PermanentOfThisCard() }, hashtable).Tap());
  108. if (card.Owner.LibraryCards.Count >= 1)
  109. {
  110. List<Permanent> playedPermanents = new List<Permanent>();
  111. foreach (Hashtable hash in CardEffectCommons.GetHashtablesFromHashtable(hashtable))
  112. {
  113. playedPermanents.Add(CardEffectCommons.GetPermanentFromHashtable(hash));
  114. }
  115. List<Permanent> targetPermanents = playedPermanents.Filter(PermanentCondition);
  116. List<CardSource> selectedCards = new List<CardSource>();
  117. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, targetPermanents.Contains))
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.RevealDeckTopCardsAndProcessForAll(
  120. revealCount: 2,
  121. simplifiedSelectCardCondition:
  122. new SimplifiedSelectCardConditionClass(
  123. canTargetCondition: cardSource => cardSource.EqualsCardName("Vemmon"),
  124. message: "",
  125. mode: SelectCardEffect.Mode.Custom,
  126. maxCount: -1,
  127. selectCardCoroutine: SelectCardCoroutine),
  128. remainingCardsPlace: RemainingCardsPlace.Trash,
  129. activateClass: activateClass
  130. ));
  131. IEnumerator SelectCardCoroutine(CardSource cardSource)
  132. {
  133. if (cardSource != null) selectedCards.Add(cardSource);
  134. yield return null;
  135. }
  136. if (selectedCards.Count > 0)
  137. {
  138. while (selectedCards.Any())
  139. {
  140. Permanent selectedPermament = null;
  141. if (targetPermanents.Count > 1)
  142. {
  143. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, targetPermanents.Contains));
  145. selectPermanentEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: permanent => targetPermanents.Contains(permanent),
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: maxCount,
  151. canNoSelect: false,
  152. canEndNotMax: false,
  153. selectPermanentCoroutine: SelectPermanentCoroutine,
  154. afterSelectPermanentCoroutine: null,
  155. mode: SelectPermanentEffect.Mode.Custom,
  156. cardEffect: activateClass);
  157. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  158. {
  159. selectedPermament = permanent;
  160. yield return null;
  161. }
  162. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get the digivolution cards.", "The opponent is selecting 1 Digimon that will get the digivolution cards.");
  163. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  164. }
  165. else selectedPermament = targetPermanents[0];
  166. if (selectedPermament != null)
  167. {
  168. List<CardSource> digivolutionCards_fixed = new List<CardSource>();
  169. if (selectedCards.Count > 1)
  170. {
  171. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  172. selectCardEffect.SetUp(
  173. canTargetCondition: (cardSource) => true,
  174. canTargetCondition_ByPreSelecetedList: null,
  175. canEndSelectCondition: CanEndSelectCondition,
  176. canNoSelect: () => false,
  177. selectCardCoroutine: null,
  178. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  179. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  180. maxCount: selectedCards.Count,
  181. canEndNotMax: true,
  182. isShowOpponent: true,
  183. mode: SelectCardEffect.Mode.Custom,
  184. root: SelectCardEffect.Root.Custom,
  185. customRootCardList: selectedCards,
  186. canLookReverseCard: true,
  187. selectPlayer: card.Owner,
  188. cardEffect: activateClass);
  189. selectCardEffect.SetUseFaceDown(); // This seems to have fixed soft lock issue where sometimes some revealed vemmon were not selectable
  190. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  191. bool CanEndSelectCondition(List<CardSource> cardSources)
  192. {
  193. return !CardEffectCommons.HasNoElement(cardSources);
  194. }
  195. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  196. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  197. {
  198. digivolutionCards_fixed.AddRange(cardSources);
  199. selectedCards.RemoveAll(cardSources.Contains);
  200. yield return null;
  201. }
  202. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(digivolutionCards_fixed, "Digivolution Cards", true, true));
  203. yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddDigivolutionCardsBottom(digivolutionCards_fixed, activateClass));
  204. }
  205. else
  206. {
  207. digivolutionCards_fixed.AddRange(selectedCards);
  208. selectedCards.Clear();
  209. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(digivolutionCards_fixed, "Digivolution Cards", true, true));
  210. yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddDigivolutionCardsBottom(digivolutionCards_fixed, activateClass));
  211. }
  212. }
  213. }
  214. }
  215. }
  216. else
  217. {
  218. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.RevealDeckTopCardsAndProcessForAll(
  219. revealCount: 2,
  220. simplifiedSelectCardCondition:
  221. new SimplifiedSelectCardConditionClass(
  222. canTargetCondition: _ => false,
  223. message: "",
  224. mode: SelectCardEffect.Mode.Custom,
  225. maxCount: -1,
  226. selectCardCoroutine: null),
  227. remainingCardsPlace: RemainingCardsPlace.Trash,
  228. activateClass: activateClass
  229. ));
  230. }
  231. }
  232. }
  233. }
  234. #endregion
  235. #region Security
  236. if (timing == EffectTiming.SecuritySkill)
  237. {
  238. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  239. }
  240. #endregion
  241. return cardEffects;
  242. }
  243. }
  244. }