EX3_023.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX3
  6. {
  7. public class EX3_023 : 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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play 1 digivolution card and place a card to digivolution cards", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] You may play 1 blue level 3 Digimon card or 1 level 4 or lower Digimon card with [Aqua] or [Sea Animal] in one of its traits from one of your blue Digimon's digivolution cards without paying its memory cost. Then, you may place 1 blue Digimon card from your hand under this Digimon as its bottom digivolution card.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  27. {
  28. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. if (cardSource.IsDigimon)
  39. {
  40. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  41. {
  42. if (cardSource.Level == 3)
  43. {
  44. if (cardSource.HasLevel)
  45. {
  46. if (cardSource.CardColors.Contains(CardColor.Blue))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. if (cardSource.Level <= 4)
  53. {
  54. if (cardSource.HasLevel)
  55. {
  56. if (cardSource.HasAquaTraits)
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanSelectCardCondition1(CardSource cardSource)
  67. {
  68. if (cardSource.IsDigimon)
  69. {
  70. if (cardSource.CardColors.Contains(CardColor.Blue))
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  80. }
  81. bool CanActivateCondition(Hashtable hashtable)
  82. {
  83. if (CardEffectCommons.IsExistOnBattleArea(card))
  84. {
  85. return true;
  86. }
  87. return false;
  88. }
  89. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  90. {
  91. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  92. {
  93. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  94. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  95. selectPermanentEffect.SetUp(
  96. selectPlayer: card.Owner,
  97. canTargetCondition: CanSelectPermanentCondition,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: maxCount,
  101. canNoSelect: true,
  102. canEndNotMax: false,
  103. selectPermanentCoroutine: SelectPermanentCoroutine,
  104. afterSelectPermanentCoroutine: null,
  105. mode: SelectPermanentEffect.Mode.Custom,
  106. cardEffect: activateClass);
  107. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon which has digivolution cards.", "The opponent is selecting 1 Digimon which has digivolution cards.");
  108. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  109. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  110. {
  111. Permanent selectedPermanent = permanent;
  112. if (selectedPermanent != null)
  113. {
  114. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  115. {
  116. maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  117. List<CardSource> selectedCards = new List<CardSource>();
  118. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  119. selectCardEffect.SetUp(
  120. canTargetCondition: CanSelectCardCondition,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. canNoSelect: () => true,
  124. selectCardCoroutine: SelectCardCoroutine,
  125. afterSelectCardCoroutine: null,
  126. message: "Select 1 digivolution card to play.",
  127. maxCount: maxCount,
  128. canEndNotMax: false,
  129. isShowOpponent: true,
  130. mode: SelectCardEffect.Mode.Custom,
  131. root: SelectCardEffect.Root.Custom,
  132. customRootCardList: selectedPermanent.DigivolutionCards,
  133. canLookReverseCard: true,
  134. selectPlayer: card.Owner,
  135. cardEffect: activateClass);
  136. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  137. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  138. yield return StartCoroutine(selectCardEffect.Activate());
  139. IEnumerator SelectCardCoroutine(CardSource cardSource)
  140. {
  141. selectedCards.Add(cardSource);
  142. yield return null;
  143. }
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.DigivolutionCards, activateETB: true));
  145. }
  146. }
  147. }
  148. }
  149. if (CardEffectCommons.IsExistOnBattleArea(card))
  150. {
  151. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  152. {
  153. List<CardSource> selectedCards = new List<CardSource>();
  154. int maxCount = 1;
  155. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  156. selectHandEffect.SetUp(
  157. selectPlayer: card.Owner,
  158. canTargetCondition: CanSelectCardCondition1,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. maxCount: maxCount,
  162. canNoSelect: true,
  163. canEndNotMax: false,
  164. isShowOpponent: true,
  165. selectCardCoroutine: SelectCardCoroutine,
  166. afterSelectCardCoroutine: null,
  167. mode: SelectHandEffect.Mode.Custom,
  168. cardEffect: activateClass);
  169. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  170. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  171. yield return StartCoroutine(selectHandEffect.Activate());
  172. IEnumerator SelectCardCoroutine(CardSource cardSource)
  173. {
  174. selectedCards.Add(cardSource);
  175. yield return null;
  176. }
  177. if (selectedCards.Count >= 1)
  178. {
  179. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  180. }
  181. }
  182. }
  183. }
  184. }
  185. if (timing == EffectTiming.OnEnterFieldAnyone)
  186. {
  187. ActivateClass activateClass = new ActivateClass();
  188. activateClass.SetUpICardEffect("Return 1 Digimon to the bottom of deck", CanUseCondition, card);
  189. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  190. activateClass.SetIsInheritedEffect(true);
  191. activateClass.SetHashString("ReturnaDigimonToTheBottomOfDeck_EX3_023");
  192. cardEffects.Add(activateClass);
  193. string EffectDiscription()
  194. {
  195. return "[All Turns] [Once Per Turn] When you play a Digimon from digivolution cards, you may return 1 of your opponent's Digimon of the same level to the bottom of its owner's deck.";
  196. }
  197. bool PermanentCondition(Permanent permanent)
  198. {
  199. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  200. }
  201. bool RootCondition(SelectCardEffect.Root root)
  202. {
  203. return root == SelectCardEffect.Root.DigivolutionCards;
  204. }
  205. bool CanUseCondition(Hashtable hashtable)
  206. {
  207. if (CardEffectCommons.IsExistOnBattleArea(card))
  208. {
  209. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition, RootCondition))
  210. {
  211. return true;
  212. }
  213. }
  214. return false;
  215. }
  216. bool CanActivateCondition(Hashtable hashtable)
  217. {
  218. if (CardEffectCommons.IsExistOnBattleArea(card))
  219. {
  220. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  221. hashtable: hashtable,
  222. rootCondition: RootCondition);
  223. if (permanents != null)
  224. {
  225. List<int> levels = permanents
  226. .Filter(permanent => permanent != null && permanent.LevelJustAfterPlayed >= 0)
  227. .Map(permanent => permanent.LevelJustAfterPlayed);
  228. bool CanSelectPermanentCondition(Permanent permanent)
  229. {
  230. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  231. {
  232. if (permanent.TopCard.HasLevel)
  233. {
  234. if (levels.Count(level => permanent.Level == level) >= 1)
  235. {
  236. return true;
  237. }
  238. }
  239. }
  240. return false;
  241. }
  242. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  243. {
  244. return true;
  245. }
  246. }
  247. }
  248. return false;
  249. }
  250. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  251. {
  252. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  253. hashtable: _hashtable,
  254. rootCondition: RootCondition);
  255. if (permanents != null)
  256. {
  257. List<int> levels = permanents
  258. .Filter(permanent => permanent != null && permanent.LevelJustAfterPlayed >= 0)
  259. .Map(permanent => permanent.LevelJustAfterPlayed);
  260. bool CanSelectPermanentCondition(Permanent permanent)
  261. {
  262. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  263. {
  264. if (permanent.TopCard.HasLevel)
  265. {
  266. if (levels.Count(level => permanent.Level == level) >= 1)
  267. {
  268. return true;
  269. }
  270. }
  271. }
  272. return false;
  273. }
  274. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  275. {
  276. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  277. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  278. selectPermanentEffect.SetUp(
  279. selectPlayer: card.Owner,
  280. canTargetCondition: CanSelectPermanentCondition,
  281. canTargetCondition_ByPreSelecetedList: null,
  282. canEndSelectCondition: null,
  283. maxCount: maxCount,
  284. canNoSelect: false,
  285. canEndNotMax: false,
  286. selectPermanentCoroutine: null,
  287. afterSelectPermanentCoroutine: null,
  288. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  289. cardEffect: activateClass);
  290. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  291. }
  292. }
  293. }
  294. }
  295. return cardEffects;
  296. }
  297. }
  298. }