BT13_096.cs 16 KB

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