EX2_072.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_072 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  15. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  16. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  17. cardEffects.Add(ignoreColorConditionClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. if (card.Owner.GetBattleAreaPermanents().Count((permanet) => permanet.IsTamer) >= 1)
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. bool CardCondition(CardSource cardSource)
  27. {
  28. if (cardSource == card)
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. }
  35. if (timing == EffectTiming.OptionSkill)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  39. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. {
  43. return "[Main] Reveal the top 5 cards of your deck. You may digivolve 1 of your Digimon into 1 non-white Digimon card among them without paying its memory cost. If you don't, add 1 Digimon card among them to your hand. Place the remaining cards at the bottom of your deck in any order.";
  44. }
  45. bool CanSelectCardCondition(CardSource cardSource)
  46. {
  47. if (cardSource.IsDigimon)
  48. {
  49. if (!cardSource.HasCardColor(CardColor.White))
  50. {
  51. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  52. {
  53. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  54. {
  55. return true;
  56. }
  57. }
  58. }
  59. }
  60. return false;
  61. }
  62. bool CanSelectCardCondition1(CardSource cardSource)
  63. {
  64. return cardSource.IsDigimon;
  65. }
  66. bool CanUseCondition(Hashtable hashtable)
  67. {
  68. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  71. {
  72. if (card.Owner.LibraryCards.Count >= 1)
  73. {
  74. bool digivolved = false;
  75. List<CardSource> selectedCards = new List<CardSource>();
  76. RevealLibraryClass revealLibrary = new RevealLibraryClass(card.Owner, 5);
  77. yield return ContinuousController.instance.StartCoroutine(revealLibrary.RevealLibrary());
  78. List<CardSource> libraryCards = new List<CardSource>();
  79. int maxCount = Math.Min(1, revealLibrary.RevealedCards.Count(CanSelectCardCondition));
  80. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  81. selectCardEffect.SetUseFaceDown();
  82. if (maxCount >= 1)
  83. {
  84. selectCardEffect.SetUp(
  85. canTargetCondition: CanSelectCardCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. canNoSelect: () => true,
  89. selectCardCoroutine: SelectCardCoroutine,
  90. afterSelectCardCoroutine: null,
  91. message: "Select 1 card to digivolve.",
  92. maxCount: maxCount,
  93. canEndNotMax: false,
  94. isShowOpponent: true,
  95. mode: SelectCardEffect.Mode.Custom,
  96. root: SelectCardEffect.Root.Custom,
  97. customRootCardList: revealLibrary.RevealedCards,
  98. canLookReverseCard: true,
  99. selectPlayer: card.Owner,
  100. cardEffect: activateClass);
  101. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  102. IEnumerator SelectCardCoroutine(CardSource cardSource)
  103. {
  104. selectedCards.Add(cardSource);
  105. yield return null;
  106. }
  107. }
  108. if (selectedCards.Count >= 1)
  109. {
  110. CardSource selectedCard = selectedCards[0];
  111. if (selectedCard != null)
  112. {
  113. List<Permanent> candidatePermanents = new List<Permanent>();
  114. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  115. {
  116. if (selectedCard.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  117. {
  118. candidatePermanents.Add(permanent);
  119. }
  120. }
  121. bool CanSelectPermanentCondition(Permanent permanent)
  122. {
  123. if (permanent != null)
  124. {
  125. if (candidatePermanents.Contains(permanent))
  126. {
  127. return true;
  128. }
  129. }
  130. return false;
  131. }
  132. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  133. {
  134. Permanent selectedPermanent = null;
  135. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  136. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  137. selectPermanentEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: CanSelectPermanentCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: maxCount,
  143. canNoSelect: true,
  144. canEndNotMax: false,
  145. selectPermanentCoroutine: SelectPermanentCoroutine,
  146. afterSelectPermanentCoroutine: null,
  147. mode: SelectPermanentEffect.Mode.Custom,
  148. cardEffect: activateClass);
  149. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will Digivolve.", "The opponent is selecting 1 Digimon that will Digivolve.");
  150. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  151. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  152. {
  153. selectedPermanent = permanent;
  154. yield return null;
  155. }
  156. if (selectedPermanent != null)
  157. {
  158. if (selectedCard != null)
  159. {
  160. if (selectedCard.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClass))
  161. {
  162. digivolved = true;
  163. foreach (CardSource cardSource in revealLibrary.RevealedCards)
  164. {
  165. if (!selectedCards.Contains(cardSource))
  166. {
  167. libraryCards.Add(cardSource);
  168. }
  169. }
  170. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ReturnRevealedCardsToLibraryBottom(libraryCards, activateClass));
  171. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  172. cardSources: new List<CardSource>() { selectedCard },
  173. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  174. payCost: false,
  175. targetPermanent: selectedPermanent,
  176. isTapped: false,
  177. root: SelectCardEffect.Root.Library,
  178. activateETB: true).PlayCard());
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. if (!digivolved)
  186. {
  187. maxCount = Math.Min(1, revealLibrary.RevealedCards.Count(CanSelectCardCondition1));
  188. selectCardEffect.SetUp(
  189. canTargetCondition: CanSelectCardCondition1,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. canNoSelect: () => false,
  193. selectCardCoroutine: null,
  194. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  195. message: "Select 1 card to add to your hand.",
  196. maxCount: maxCount,
  197. canEndNotMax: false,
  198. isShowOpponent: true,
  199. mode: SelectCardEffect.Mode.AddHand,
  200. root: SelectCardEffect.Root.Custom,
  201. customRootCardList: revealLibrary.RevealedCards,
  202. canLookReverseCard: true,
  203. selectPlayer: card.Owner,
  204. cardEffect: activateClass);
  205. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  206. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  207. {
  208. foreach (CardSource cardSource in revealLibrary.RevealedCards)
  209. {
  210. if (!cardSources.Contains(cardSource))
  211. {
  212. libraryCards.Add(cardSource);
  213. }
  214. }
  215. yield return null;
  216. }
  217. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ReturnRevealedCardsToLibraryBottom(libraryCards, activateClass));
  218. }
  219. }
  220. }
  221. }
  222. if (timing == EffectTiming.SecuritySkill)
  223. {
  224. ActivateClass activateClass = new ActivateClass();
  225. activateClass.SetUpICardEffect($"Play 1 Tamer from hand", CanUseCondition, card);
  226. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  227. activateClass.SetIsSecurityEffect(true);
  228. cardEffects.Add(activateClass);
  229. string EffectDiscription()
  230. {
  231. return "[Security] You may play 1 Tamer card from your hand without paying its memory cost.";
  232. }
  233. bool CanSelectCardCondition(CardSource cardSource)
  234. {
  235. if (cardSource.IsTamer)
  236. {
  237. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  238. {
  239. return true;
  240. }
  241. }
  242. return false;
  243. }
  244. bool CanUseCondition(Hashtable hashtable)
  245. {
  246. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  247. }
  248. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  249. {
  250. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  251. {
  252. List<CardSource> selectedCards = new List<CardSource>();
  253. int maxCount = 1;
  254. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  255. selectHandEffect.SetUp(
  256. selectPlayer: card.Owner,
  257. canTargetCondition: CanSelectCardCondition,
  258. canTargetCondition_ByPreSelecetedList: null,
  259. canEndSelectCondition: null,
  260. maxCount: maxCount,
  261. canNoSelect: true,
  262. canEndNotMax: false,
  263. isShowOpponent: true,
  264. selectCardCoroutine: SelectCardCoroutine,
  265. afterSelectCardCoroutine: null,
  266. mode: SelectHandEffect.Mode.Custom,
  267. cardEffect: activateClass);
  268. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  269. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  270. yield return StartCoroutine(selectHandEffect.Activate());
  271. IEnumerator SelectCardCoroutine(CardSource cardSource)
  272. {
  273. selectedCards.Add(cardSource);
  274. yield return null;
  275. }
  276. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  277. }
  278. }
  279. }
  280. return cardEffects;
  281. }
  282. }
  283. }