BT20_077.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT20
  6. {
  7. public class BT20_077 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ace - Blast Digivolve
  13. if (timing == EffectTiming.OnCounterTiming)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  16. }
  17. #endregion
  18. #region Digivolution Condition
  19. if (timing == EffectTiming.None)
  20. {
  21. static bool PermanentCondition(Permanent targetPermanent)
  22. {
  23. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5)
  24. {
  25. if (targetPermanent.TopCard.EqualsTraits("Dark Dragon") || targetPermanent.TopCard.EqualsTraits("Evil Dragon"))
  26. {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region On Play/When Digivolving Shared
  36. bool CardTrashed(CardSource source)
  37. {
  38. return true;
  39. }
  40. #endregion
  41. #region On Play
  42. if (timing == EffectTiming.OnEnterFieldAnyone)
  43. {
  44. ActivateClass activateClass = new ActivateClass();
  45. activateClass.SetUpICardEffect("Trash until 4 left and play a Digimon", CanUseCondition, card);
  46. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  47. cardEffects.Add(activateClass);
  48. string EffectDiscription()
  49. {
  50. return "[On Play] Trash cards in your hand until it has 4 left. Then, play 1 8000 DP or lower Digimon card from your trash without paying the cost. For each card this effect trashed, remove 2000 from this effect's DP maximum.";
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  55. {
  56. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  57. }
  58. return false;
  59. }
  60. bool CanActivateCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. List<CardSource> trashed = new List<CardSource>();
  67. if (card.Owner.HandCards.Count > 4)
  68. {
  69. int maxCount = card.Owner.HandCards.Count - 4;
  70. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  71. selectHandEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CardTrashed,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: maxCount,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. isShowOpponent: true,
  80. selectCardCoroutine: null,
  81. afterSelectCardCoroutine: AllSelectedCards,
  82. mode: SelectHandEffect.Mode.Discard,
  83. cardEffect: activateClass);
  84. selectHandEffect.SetUpCustomMessage($"Select {maxCount} card(s) to trash.", $"The opponent is selecting {maxCount} card(s) to trash.");
  85. yield return StartCoroutine(selectHandEffect.Activate());
  86. IEnumerator AllSelectedCards(List<CardSource> sources)
  87. {
  88. trashed = sources;
  89. yield return null;
  90. }
  91. }
  92. bool CanSelectCardInTrash(CardSource cardSource)
  93. {
  94. int maxDP = 8000 - (trashed.Count() * 2000);
  95. if (cardSource.IsDigimon && cardSource.HasDP)
  96. {
  97. if (cardSource.CardDP <= maxDP)
  98. {
  99. return true;
  100. }
  101. }
  102. return false;
  103. }
  104. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  105. {
  106. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  107. List<CardSource> selectedCards = new List<CardSource>();
  108. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  109. selectCardEffect.SetUp(
  110. canTargetCondition: CanSelectCardInTrash,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. canNoSelect: () => true,
  114. selectCardCoroutine: SelectCardCoroutine,
  115. afterSelectCardCoroutine: null,
  116. message: "Select 1 card to play.",
  117. maxCount: maxCount,
  118. canEndNotMax: false,
  119. isShowOpponent: true,
  120. mode: SelectCardEffect.Mode.Custom,
  121. root: SelectCardEffect.Root.Trash,
  122. customRootCardList: null,
  123. canLookReverseCard: true,
  124. selectPlayer: card.Owner,
  125. cardEffect: activateClass);
  126. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  127. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  128. yield return StartCoroutine(selectCardEffect.Activate());
  129. IEnumerator SelectCardCoroutine(CardSource cardSource)
  130. {
  131. selectedCards.Add(cardSource);
  132. yield return null;
  133. }
  134. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  135. cardSources: selectedCards,
  136. activateClass: activateClass,
  137. payCost: false,
  138. isTapped: false,
  139. root: SelectCardEffect.Root.Trash,
  140. activateETB: true));
  141. }
  142. }
  143. }
  144. #endregion
  145. #region When Digivolving
  146. if (timing == EffectTiming.OnEnterFieldAnyone)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect("Trash until 4 left and play a Digimon", CanUseCondition, card);
  150. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  151. cardEffects.Add(activateClass);
  152. string EffectDiscription()
  153. {
  154. return "[When Digivolving] Trash cards in your hand until it has 4 left. Then, play 1 8000 DP or lower Digimon card from your trash without paying the cost. For each card this effect trashed, remove 2000 from this effect's DP maximum.";
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  159. {
  160. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  161. }
  162. return false;
  163. }
  164. bool CanActivateCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable hashtable)
  169. {
  170. List<CardSource> trashed = new List<CardSource>();
  171. if (card.Owner.HandCards.Count > 4)
  172. {
  173. int maxCount = card.Owner.HandCards.Count - 4;
  174. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  175. selectHandEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: CardTrashed,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: maxCount,
  181. canNoSelect: false,
  182. canEndNotMax: false,
  183. isShowOpponent: true,
  184. selectCardCoroutine: null,
  185. afterSelectCardCoroutine: AllSelectedCards,
  186. mode: SelectHandEffect.Mode.Discard,
  187. cardEffect: activateClass);
  188. selectHandEffect.SetUpCustomMessage($"Select {maxCount} card(s) to trash.", $"The opponent is selecting {maxCount} card(s) to trash.");
  189. yield return StartCoroutine(selectHandEffect.Activate());
  190. IEnumerator AllSelectedCards(List<CardSource> sources)
  191. {
  192. trashed = sources;
  193. yield return null;
  194. }
  195. }
  196. bool CanSelectCardInTrash(CardSource cardSource)
  197. {
  198. int maxDP = 8000 - (trashed.Count() * 2000);
  199. if (cardSource.IsDigimon && cardSource.HasDP)
  200. {
  201. if (cardSource.CardDP <= maxDP)
  202. {
  203. return true;
  204. }
  205. }
  206. return false;
  207. }
  208. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  209. {
  210. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  211. List<CardSource> selectedCards = new List<CardSource>();
  212. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  213. selectCardEffect.SetUp(
  214. canTargetCondition: CanSelectCardInTrash,
  215. canTargetCondition_ByPreSelecetedList: null,
  216. canEndSelectCondition: null,
  217. canNoSelect: () => true,
  218. selectCardCoroutine: SelectCardCoroutine,
  219. afterSelectCardCoroutine: null,
  220. message: "Select 1 card to play.",
  221. maxCount: maxCount,
  222. canEndNotMax: false,
  223. isShowOpponent: true,
  224. mode: SelectCardEffect.Mode.Custom,
  225. root: SelectCardEffect.Root.Trash,
  226. customRootCardList: null,
  227. canLookReverseCard: true,
  228. selectPlayer: card.Owner,
  229. cardEffect: activateClass);
  230. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  231. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  232. yield return StartCoroutine(selectCardEffect.Activate());
  233. IEnumerator SelectCardCoroutine(CardSource cardSource)
  234. {
  235. selectedCards.Add(cardSource);
  236. yield return null;
  237. }
  238. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  239. cardSources: selectedCards,
  240. activateClass: activateClass,
  241. payCost: false,
  242. isTapped: false,
  243. root: SelectCardEffect.Root.Trash,
  244. activateETB: true));
  245. }
  246. }
  247. }
  248. #endregion
  249. #region All Turns
  250. if (timing == EffectTiming.None)
  251. {
  252. bool CanUseCondition()
  253. {
  254. if (CardEffectCommons.IsExistOnBattleArea(card))
  255. {
  256. return true;
  257. }
  258. return false;
  259. }
  260. bool PermanentCondition(Permanent permanent)
  261. {
  262. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  263. {
  264. if (permanent.TopCard.EqualsTraits("Dark Dragon") || permanent.TopCard.EqualsTraits("Evil Dragon"))
  265. {
  266. return true;
  267. }
  268. }
  269. return false;
  270. }
  271. cardEffects.Add(CardEffectFactory.RushStaticEffect(
  272. permanentCondition: PermanentCondition,
  273. isInheritedEffect: false,
  274. card: card,
  275. condition: CanUseCondition));
  276. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(
  277. permanentCondition: PermanentCondition,
  278. isInheritedEffect: false,
  279. card: card,
  280. condition: CanUseCondition));
  281. cardEffects.Add(CardEffectFactory.ChangeDPStaticEffect(
  282. permanentCondition: PermanentCondition,
  283. changeValue: 2000,
  284. isInheritedEffect: false,
  285. card: card,
  286. condition: CanUseCondition,
  287. effectName: () => "Your Digimon with [Dark Dragon] or [Evil Dragon] traits gain DP +2000"));
  288. }
  289. #endregion
  290. return cardEffects;
  291. }
  292. }
  293. }