BT17_041.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_041 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Requirements
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("ShineGreymon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Blast Digivolve
  23. if (timing == EffectTiming.OnCounterTiming)
  24. {
  25. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  26. }
  27. #endregion
  28. #region On Play
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Play 1 Tamer from hand, for each Tamer give and DP -5000", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[On Play] You may play 1 Tamer card from your hand without paying the cost. Then, for the turn, 1 of your opponent's Digimon gets -5000 DP for each of your Tamers.";
  38. }
  39. bool CanSelectCardCondition(CardSource cardSource)
  40. {
  41. if (cardSource.IsTamer)
  42. {
  43. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanSelectPermanentCondition(Permanent permanent)
  51. {
  52. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  65. {
  66. List<CardSource> selectedCards = new List<CardSource>();
  67. int maxCount = 1;
  68. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  69. selectHandEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectCardCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: true,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. selectCardCoroutine: SelectCardCoroutine,
  79. afterSelectCardCoroutine: null,
  80. mode: SelectHandEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectHandEffect.SetUpCustomMessage("Select 1 Tamer to play.", "The opponent is selecting 1 Tamer to play.");
  83. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  84. yield return StartCoroutine(selectHandEffect.Activate());
  85. IEnumerator SelectCardCoroutine(CardSource cardSource)
  86. {
  87. selectedCards.Add(cardSource);
  88. yield return null;
  89. }
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  91. }
  92. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  93. {
  94. int count = card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  95. if (count >= 1)
  96. {
  97. int minusDP = 5000 * count;
  98. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  99. {
  100. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  101. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  102. selectPermanentEffect.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: CanSelectPermanentCondition,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. maxCount: maxCount,
  108. canNoSelect: false,
  109. canEndNotMax: false,
  110. selectPermanentCoroutine: SelectPermanentCoroutine,
  111. afterSelectPermanentCoroutine: null,
  112. mode: SelectPermanentEffect.Mode.Custom,
  113. cardEffect: activateClass);
  114. selectPermanentEffect.SetUpCustomMessage(
  115. $"Select 1 Digimon that will get DP -{minusDP}.",
  116. $"The opponent is selecting 1 Digimon that will get DP -{minusDP}.");
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  119. {
  120. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -minusDP, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
  127. #endregion
  128. #region When Digivolving
  129. if (timing == EffectTiming.OnEnterFieldAnyone)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect("Play 1 Tamer from hand, for each Tamer give and DP -5000", CanUseCondition, card);
  133. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  134. cardEffects.Add(activateClass);
  135. string EffectDiscription()
  136. {
  137. return "[When Digivolving] You may play 1 Tamer card from your hand without paying the cost. Then, for the turn, 1 of your opponent's Digimon gets -5000 DP for each of your Tamers.";
  138. }
  139. bool CanSelectCardCondition(CardSource cardSource)
  140. {
  141. if (cardSource.IsTamer)
  142. {
  143. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. bool CanSelectPermanentCondition(Permanent permanent)
  151. {
  152. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  153. }
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  157. }
  158. bool CanActivateCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  163. {
  164. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  165. {
  166. List<CardSource> selectedCards = new List<CardSource>();
  167. int maxCount = 1;
  168. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  169. selectHandEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: CanSelectCardCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: maxCount,
  175. canNoSelect: true,
  176. canEndNotMax: false,
  177. isShowOpponent: true,
  178. selectCardCoroutine: SelectCardCoroutine,
  179. afterSelectCardCoroutine: null,
  180. mode: SelectHandEffect.Mode.Custom,
  181. cardEffect: activateClass);
  182. selectHandEffect.SetUpCustomMessage("Select 1 Tamer to play.", "The opponent is selecting 1 Tamer to play.");
  183. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  184. yield return StartCoroutine(selectHandEffect.Activate());
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. selectedCards.Add(cardSource);
  188. yield return null;
  189. }
  190. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  191. }
  192. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  193. {
  194. int count = card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  195. if (count >= 1)
  196. {
  197. int minusDP = 5000 * count;
  198. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  199. {
  200. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  201. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  202. selectPermanentEffect.SetUp(
  203. selectPlayer: card.Owner,
  204. canTargetCondition: CanSelectPermanentCondition,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. maxCount: maxCount,
  208. canNoSelect: false,
  209. canEndNotMax: false,
  210. selectPermanentCoroutine: SelectPermanentCoroutine,
  211. afterSelectPermanentCoroutine: null,
  212. mode: SelectPermanentEffect.Mode.Custom,
  213. cardEffect: activateClass);
  214. selectPermanentEffect.SetUpCustomMessage(
  215. $"Select 1 Digimon that will get DP -{minusDP}.",
  216. $"The opponent is selecting 1 Digimon that will get DP -{minusDP}.");
  217. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  218. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  219. {
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -minusDP, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. #endregion
  228. #region When Attacking
  229. if (timing == EffectTiming.OnAllyAttack)
  230. {
  231. ActivateClass activateClass = new ActivateClass();
  232. activateClass.SetUpICardEffect("Suspend up to 2 Tamers to get Security Attack +1 for each", CanUseCondition, card);
  233. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  234. cardEffects.Add(activateClass);
  235. string EffectDiscription()
  236. {
  237. return "[When Attacking] By suspending up to 2 of your yellow Tamers, for every Tamer this effect suspended, this Digimon gains Security Attack +1 for the turn.";
  238. }
  239. bool CanSelectPermanentCondition(Permanent permanent)
  240. {
  241. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  242. {
  243. if (permanent.IsTamer && permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  244. {
  245. if(!permanent.IsSuspended && permanent.CanSuspend)
  246. return true;
  247. }
  248. }
  249. return false;
  250. }
  251. bool CanUseCondition(Hashtable hashtable)
  252. {
  253. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  254. }
  255. bool CanActivateCondition(Hashtable hashtable)
  256. {
  257. return CardEffectCommons.IsExistOnBattleArea(card);
  258. }
  259. IEnumerator ActivateCoroutine(Hashtable hashtable)
  260. {
  261. List<Permanent> selectedPermanents = new List<Permanent>();
  262. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  263. {
  264. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  265. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  266. selectPermanentEffect.SetUp(
  267. selectPlayer: card.Owner,
  268. canTargetCondition: CanSelectPermanentCondition,
  269. canTargetCondition_ByPreSelecetedList: null,
  270. canEndSelectCondition: CanEndSelectCondition,
  271. maxCount: maxCount,
  272. canNoSelect: true,
  273. canEndNotMax: true,
  274. selectPermanentCoroutine: null,
  275. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  276. mode: SelectPermanentEffect.Mode.Custom,
  277. cardEffect: activateClass);
  278. selectPermanentEffect.SetUpCustomMessage("Select up to 2 of your Yellow Tamers to suspend.", "The opponent is selecting up to 2 Tamers to suspend.");
  279. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  280. bool CanEndSelectCondition(List<Permanent> permanents)
  281. {
  282. if (permanents.Count <= 0)
  283. {
  284. return false;
  285. }
  286. return true;
  287. }
  288. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  289. {
  290. if (permanents.Count >= 1)
  291. {
  292. foreach (Permanent permanent in permanents)
  293. {
  294. selectedPermanents.Add(permanent);
  295. }
  296. yield return null;
  297. }
  298. }
  299. List<Permanent> suspendedTargets = new List<Permanent>();
  300. foreach (Permanent selectedPermanent in selectedPermanents)
  301. {
  302. if (selectedPermanent != null)
  303. {
  304. if (selectedPermanent.TopCard != null)
  305. {
  306. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  307. {
  308. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  309. {
  310. suspendedTargets.Add(selectedPermanent);
  311. }
  312. }
  313. }
  314. }
  315. }
  316. if(suspendedTargets.Count > 0)
  317. {
  318. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(suspendedTargets, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  319. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  320. targetPermanent: card.PermanentOfThisCard(),
  321. changeValue: suspendedTargets.Count,
  322. effectDuration: EffectDuration.UntilEachTurnEnd,
  323. activateClass: activateClass));
  324. }
  325. }
  326. }
  327. }
  328. #endregion
  329. return cardEffects;
  330. }
  331. }
  332. }