BT11_107.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT11
  6. {
  7. public class BT11_107 : 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. ChangeCostClass changeCostClass = new ChangeCostClass();
  15. changeCostClass.SetUpICardEffect($"Play Cost -2", CanUseCondition, card);
  16. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  17. cardEffects.Add(changeCostClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("XAntibody") || cardSource.CardNames.Contains("X Antibody")) >= 1);
  21. }
  22. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  23. {
  24. if (CardSourceCondition(cardSource))
  25. {
  26. if (RootCondition(root))
  27. {
  28. if (PermanentsCondition(targetPermanents))
  29. {
  30. Cost -= 2;
  31. }
  32. }
  33. }
  34. return Cost;
  35. }
  36. bool PermanentsCondition(List<Permanent> targetPermanents)
  37. {
  38. return true;
  39. }
  40. bool CardSourceCondition(CardSource cardSource)
  41. {
  42. return cardSource == card;
  43. }
  44. bool RootCondition(SelectCardEffect.Root root)
  45. {
  46. return true;
  47. }
  48. bool isUpDown()
  49. {
  50. return true;
  51. }
  52. }
  53. if (timing == EffectTiming.OptionSkill)
  54. {
  55. ActivateClass activateClass = new ActivateClass();
  56. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  57. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  58. cardEffects.Add(activateClass);
  59. string EffectDiscription()
  60. {
  61. return "[Main] Choose any number of your opponent's Digimon and Tamers whose combined play costs are less than or equal to the play cost of 1 of your Digimon with [Greymon] in its name, and delete all of the chosen cards. Then, 1 of your Digimon with [Greymon] in its name may attack a player.";
  62. }
  63. bool CanSelectPermanentCondition(Permanent permanent)
  64. {
  65. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  66. {
  67. if (permanent.TopCard.HasGreymonName)
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. bool CanSelectPermanentCondition1(Permanent permanent)
  75. {
  76. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  77. {
  78. if (permanent.TopCard.HasGreymonName)
  79. {
  80. if (permanent.CanAttack(activateClass))
  81. {
  82. if (permanent.CanAttackTargetDigimon(null, activateClass))
  83. {
  84. return true;
  85. }
  86. }
  87. }
  88. }
  89. return false;
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  96. {
  97. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  98. {
  99. Permanent selectedPermanent = null;
  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("Select 1 Digimon with [Greymon] in its name.", "The opponent is selecting 1 Digimon with [Greymon] in its name.");
  115. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  116. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  117. {
  118. selectedPermanent = permanent;
  119. yield return null;
  120. }
  121. if (selectedPermanent != null)
  122. {
  123. int maxSumCost = selectedPermanent.TopCard.GetCostItself;
  124. bool CanSelectPermanentCondition1(Permanent permanent)
  125. {
  126. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  127. {
  128. if (permanent.IsDigimon || permanent.IsTamer)
  129. {
  130. if (permanent.TopCard.GetCostItself <= maxSumCost)
  131. {
  132. if (permanent.TopCard.HasPlayCost)
  133. {
  134. return true;
  135. }
  136. }
  137. }
  138. }
  139. return false;
  140. }
  141. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  142. {
  143. maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1);
  144. selectPermanentEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: CanSelectPermanentCondition1,
  147. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  148. canEndSelectCondition: CanEndSelectCondition1,
  149. maxCount: maxCount,
  150. canNoSelect: false,
  151. canEndNotMax: true,
  152. selectPermanentCoroutine: null,
  153. afterSelectPermanentCoroutine: null,
  154. mode: SelectPermanentEffect.Mode.Destroy,
  155. cardEffect: activateClass);
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. bool CanEndSelectCondition1(List<Permanent> permanents)
  158. {
  159. if (permanents.Count <= 0)
  160. {
  161. return false;
  162. }
  163. int sumCost = 0;
  164. foreach (Permanent permanent1 in permanents)
  165. {
  166. sumCost += permanent1.TopCard.GetCostItself;
  167. }
  168. if (sumCost > maxSumCost)
  169. {
  170. return false;
  171. }
  172. return true;
  173. }
  174. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  175. {
  176. int sumCost = 0;
  177. foreach (Permanent permanent1 in permanents)
  178. {
  179. sumCost += permanent1.TopCard.GetCostItself;
  180. }
  181. sumCost += permanent.TopCard.GetCostItself;
  182. if (sumCost > maxSumCost)
  183. {
  184. return false;
  185. }
  186. return true;
  187. }
  188. }
  189. }
  190. }
  191. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  192. {
  193. Permanent selectedPermanent = null;
  194. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  195. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  196. selectPermanentEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: CanSelectPermanentCondition1,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: maxCount,
  202. canNoSelect: true,
  203. canEndNotMax: false,
  204. selectPermanentCoroutine: SelectPermanentCoroutine,
  205. afterSelectPermanentCoroutine: null,
  206. mode: SelectPermanentEffect.Mode.Custom,
  207. cardEffect: activateClass);
  208. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.", "The opponent is selecting 1 Digimon that will attack.");
  209. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  210. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  211. {
  212. selectedPermanent = permanent;
  213. yield return null;
  214. }
  215. if (selectedPermanent != null)
  216. {
  217. if (selectedPermanent.CanAttack(activateClass))
  218. {
  219. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  220. selectAttackEffect.SetUp(
  221. attacker: selectedPermanent,
  222. canAttackPlayerCondition: () => true,
  223. defenderCondition: (permanent) => false,
  224. cardEffect: activateClass);
  225. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  226. }
  227. }
  228. }
  229. }
  230. }
  231. if (timing == EffectTiming.SecuritySkill)
  232. {
  233. ActivateClass activateClass = new ActivateClass();
  234. activateClass.SetUpICardEffect($"Delete 1 Digimon with the highest play cost", CanUseCondition, card);
  235. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  236. activateClass.SetIsSecurityEffect(true);
  237. cardEffects.Add(activateClass);
  238. string EffectDiscription()
  239. {
  240. return "[Security] Delete 1 of your opponent's Digimon with the highest play cost.";
  241. }
  242. bool CanSelectPermanentCondition(Permanent permanent)
  243. {
  244. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  245. CardEffectCommons.IsMaxCost(permanent, card.Owner.Enemy, true);
  246. }
  247. bool CanUseCondition(Hashtable hashtable)
  248. {
  249. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  250. }
  251. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  252. {
  253. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  254. {
  255. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  256. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  257. selectPermanentEffect.SetUp(
  258. selectPlayer: card.Owner,
  259. canTargetCondition: CanSelectPermanentCondition,
  260. canTargetCondition_ByPreSelecetedList: null,
  261. canEndSelectCondition: null,
  262. maxCount: maxCount,
  263. canNoSelect: false,
  264. canEndNotMax: false,
  265. selectPermanentCoroutine: null,
  266. afterSelectPermanentCoroutine: null,
  267. mode: SelectPermanentEffect.Mode.Destroy,
  268. cardEffect: activateClass);
  269. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  270. }
  271. }
  272. }
  273. return cardEffects;
  274. }
  275. }
  276. }