BT12_108.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_108 : 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. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  15. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  16. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  17. cardEffects.Add(ignoreColorConditionClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.Level == 6 && permanent.TopCard.HasLevel && permanent.TopCard.CardTraits.Contains("Machine")))
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. bool CardCondition(CardSource cardSource)
  27. {
  28. if (cardSource == card)
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. }
  35. if (timing == EffectTiming.OptionSkill)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  39. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. {
  43. return "[Main] Choose 1 of your Digimon with a [Machine] or [Cyborg] trait. Delete 1 of your opponent's Digimon with DP less than or equal to that Digimon and delete your chosen Digimon.";
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent)
  46. {
  47. if (permanent != null)
  48. {
  49. if (permanent.TopCard != null)
  50. {
  51. if (permanent.IsDigimon)
  52. {
  53. if (permanent.TopCard.Owner == card.Owner)
  54. {
  55. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  56. {
  57. if (permanent.TopCard.CardTraits.Contains("Machine"))
  58. {
  59. return true;
  60. }
  61. if (permanent.TopCard.CardTraits.Contains("Cyborg"))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. return false;
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. Permanent selectedPermanent = null;
  81. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon with [Machine] or [Cyborg] in its traits.", "The opponent is selecting 1 Digimon with [Machine] or [Cyborg] in its traits.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. selectedPermanent = permanent;
  100. yield return null;
  101. }
  102. if (selectedPermanent != null)
  103. {
  104. int maxDP = selectedPermanent.DP;
  105. bool CanSelectPermanentCondition1(Permanent permanent)
  106. {
  107. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  108. {
  109. if (permanent.DP <= maxDP)
  110. {
  111. return true;
  112. }
  113. }
  114. return false;
  115. }
  116. List<Permanent> deletePermanents = new List<Permanent>() { selectedPermanent };
  117. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  118. {
  119. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: CanSelectPermanentCondition1,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: CanEndSelectCondition1,
  125. maxCount: maxCount,
  126. canNoSelect: false,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: SelectPermanentCoroutine1,
  129. afterSelectPermanentCoroutine: null,
  130. mode: SelectPermanentEffect.Mode.Custom,
  131. cardEffect: activateClass);
  132. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  135. {
  136. deletePermanents.Add(permanent);
  137. yield return null;
  138. }
  139. bool CanEndSelectCondition1(List<Permanent> permanents)
  140. {
  141. if (permanents.Count <= 0)
  142. {
  143. return false;
  144. }
  145. return true;
  146. }
  147. }
  148. if (deletePermanents.Count >= 1)
  149. {
  150. Hashtable hashtable = new Hashtable();
  151. hashtable.Add("CardEffect", activateClass);
  152. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(deletePermanents, hashtable).Destroy());
  153. }
  154. }
  155. }
  156. }
  157. }
  158. if (timing == EffectTiming.SecuritySkill)
  159. {
  160. ActivateClass activateClass = new ActivateClass();
  161. activateClass.SetUpICardEffect($"Trash 1 card from hand to delete 1 Digimon", CanUseCondition, card);
  162. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  163. activateClass.SetIsSecurityEffect(true);
  164. cardEffects.Add(activateClass);
  165. string EffectDiscription()
  166. {
  167. return "[Security] By trashing 1 card with a [Cyborg] or [Machine] trait from your hand, delete 1 of your opponent's Digimon with a play cost less than or equal to the trashed card.";
  168. }
  169. bool CanSelectCardCondition(CardSource cardSource)
  170. {
  171. if (cardSource != null)
  172. {
  173. if (cardSource.Owner == card.Owner)
  174. {
  175. if (cardSource.CardTraits.Contains("Cyborg"))
  176. {
  177. return true;
  178. }
  179. if (cardSource.CardTraits.Contains("Machine"))
  180. {
  181. return true;
  182. }
  183. }
  184. }
  185. return false;
  186. }
  187. bool CanUseCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  192. {
  193. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  194. {
  195. CardSource discardedCard = null;
  196. int discardCount = 1;
  197. int maxCost = -1;
  198. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  199. selectHandEffect.SetUp(
  200. selectPlayer: card.Owner,
  201. canTargetCondition: CanSelectCardCondition,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canEndSelectCondition: null,
  204. maxCount: discardCount,
  205. canNoSelect: true,
  206. canEndNotMax: false,
  207. isShowOpponent: true,
  208. selectCardCoroutine: null,
  209. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  210. mode: SelectHandEffect.Mode.Discard,
  211. cardEffect: activateClass);
  212. yield return StartCoroutine(selectHandEffect.Activate());
  213. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  214. {
  215. if (cardSources.Count >= 1)
  216. {
  217. discardedCard = cardSources[0];
  218. yield return null;
  219. }
  220. }
  221. if (discardedCard != null)
  222. {
  223. if (discardedCard.HasPlayCost)
  224. {
  225. maxCost = discardedCard.GetCostItself;
  226. }
  227. }
  228. if (discardedCard != null)
  229. {
  230. if (maxCost >= 0)
  231. {
  232. bool CanSelectPermanentCondition(Permanent permanent)
  233. {
  234. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  235. {
  236. if (permanent.TopCard.GetCostItself <= maxCost)
  237. {
  238. if (permanent.TopCard.HasPlayCost)
  239. {
  240. return true;
  241. }
  242. }
  243. }
  244. return false;
  245. }
  246. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  247. {
  248. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  249. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  250. selectPermanentEffect.SetUp(
  251. selectPlayer: card.Owner,
  252. canTargetCondition: CanSelectPermanentCondition,
  253. canTargetCondition_ByPreSelecetedList: null,
  254. canEndSelectCondition: null,
  255. maxCount: maxCount,
  256. canNoSelect: false,
  257. canEndNotMax: false,
  258. selectPermanentCoroutine: null,
  259. afterSelectPermanentCoroutine: null,
  260. mode: SelectPermanentEffect.Mode.Destroy,
  261. cardEffect: activateClass);
  262. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  263. }
  264. }
  265. }
  266. }
  267. }
  268. }
  269. return cardEffects;
  270. }
  271. }
  272. }