BT19_075.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_075 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Millenniummon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region On Play/When Digivolving Shared
  23. bool CardTrashed(CardSource source)
  24. {
  25. return true;
  26. }
  27. bool IsTamer(Permanent permanent)
  28. {
  29. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  30. permanent.IsTamer;
  31. }
  32. #endregion
  33. #region On Play
  34. if (timing == EffectTiming.OnEnterFieldAnyone)
  35. {
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect("Your opponent trashes cards in their hand so that 5 remain", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  39. cardEffects.Add(activateClass);
  40. string EffectDiscription()
  41. {
  42. return "[On Play] Your opponent trashes cards in their hand so that 5 remain. For every 2 trashed by this effect, delete 1 of their Tamers.";
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  47. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. List<CardSource> trashed = new List<CardSource>();
  56. if(card.Owner.Enemy.HandCards.Count > 5)
  57. {
  58. int maxCount = card.Owner.Enemy.HandCards.Count - 5;
  59. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  60. selectHandEffect.SetUp(
  61. selectPlayer: card.Owner.Enemy,
  62. canTargetCondition: CardTrashed,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: maxCount,
  66. canNoSelect: false,
  67. canEndNotMax: false,
  68. isShowOpponent: true,
  69. selectCardCoroutine: null,
  70. afterSelectCardCoroutine: AllSelectedCards,
  71. mode: SelectHandEffect.Mode.Discard,
  72. cardEffect: activateClass);
  73. selectHandEffect.SetUpCustomMessage($"Select {maxCount} card(s) to trash.", $"The opponent is selecting {maxCount} card(s) to trash.");
  74. yield return StartCoroutine(selectHandEffect.Activate());
  75. IEnumerator AllSelectedCards(List<CardSource> sources)
  76. {
  77. trashed = sources;
  78. yield return null;
  79. }
  80. if(trashed.Count >= 2)
  81. {
  82. if (CardEffectCommons.HasMatchConditionPermanent(IsTamer))
  83. {
  84. int maxDeletes = Math.Min(Mathf.FloorToInt(trashed.Count/2), CardEffectCommons.MatchConditionPermanentCount(IsTamer));
  85. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  86. selectPermanentEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: IsTamer,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: maxDeletes,
  92. canNoSelect: false,
  93. canEndNotMax: false,
  94. selectPermanentCoroutine: null,
  95. afterSelectPermanentCoroutine: null,
  96. mode: SelectPermanentEffect.Mode.Destroy,
  97. cardEffect: activateClass);
  98. selectPermanentEffect.SetUpCustomMessage($"Select {maxDeletes} Tamer(s) to delete.", $"The opponent is selecting {maxDeletes} Tamer(s) to delete.");
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. }
  101. }
  102. }
  103. }
  104. }
  105. #endregion
  106. #region When Digivolving
  107. if (timing == EffectTiming.OnEnterFieldAnyone)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("Your opponent trashes cards in their hand so that 5 remain", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  112. cardEffects.Add(activateClass);
  113. string EffectDiscription()
  114. {
  115. return "[When Digivolving] Your opponent trashes cards in their hand so that 5 remain. For every 2 trashed by this effect, delete 1 of their Tamers.";
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass) &&
  120. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  125. }
  126. IEnumerator ActivateCoroutine(Hashtable hashtable)
  127. {
  128. List<CardSource> trashed = new List<CardSource>();
  129. if (card.Owner.Enemy.HandCards.Count > 5)
  130. {
  131. int maxCount = card.Owner.Enemy.HandCards.Count - 5;
  132. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  133. selectHandEffect.SetUp(
  134. selectPlayer: card.Owner.Enemy,
  135. canTargetCondition: CardTrashed,
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: maxCount,
  139. canNoSelect: false,
  140. canEndNotMax: false,
  141. isShowOpponent: true,
  142. selectCardCoroutine: null,
  143. afterSelectCardCoroutine: AllSelectedCards,
  144. mode: SelectHandEffect.Mode.Discard,
  145. cardEffect: activateClass);
  146. selectHandEffect.SetUpCustomMessage($"Select {maxCount} card(s) to trash.", $"The opponent is selecting {maxCount} card(s) to trash.");
  147. yield return StartCoroutine(selectHandEffect.Activate());
  148. IEnumerator AllSelectedCards(List<CardSource> sources)
  149. {
  150. trashed = sources;
  151. yield return null;
  152. }
  153. if (trashed.Count >= 2)
  154. {
  155. if (CardEffectCommons.HasMatchConditionPermanent(IsTamer))
  156. {
  157. int maxDeletes = Math.Min(Mathf.FloorToInt(trashed.Count / 2), CardEffectCommons.MatchConditionPermanentCount(IsTamer));
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: IsTamer,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxDeletes,
  165. canNoSelect: false,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: null,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Destroy,
  170. cardEffect: activateClass);
  171. selectPermanentEffect.SetUpCustomMessage($"Select {maxDeletes} Tamer(s) to delete.", $"The opponent is selecting {maxDeletes} Tamer(s) to delete.");
  172. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  173. }
  174. }
  175. }
  176. }
  177. }
  178. #endregion
  179. #region All Turns
  180. if (timing == EffectTiming.WhenRemoveField)
  181. {
  182. ActivateClass activateClass = new ActivateClass();
  183. activateClass.SetUpICardEffect("Delete [Composite] trait digimon to prevent removal", CanUseCondition, card);
  184. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  185. cardEffects.Add(activateClass);
  186. string EffectDiscription()
  187. {
  188. return "[All Turns] When this Digimon would leave the battle area, by deleting 1 of your Digimon with the [Composite] trait, it doesn't leave.";
  189. }
  190. bool HasCompositeTrait(Permanent permanent)
  191. {
  192. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  193. permanent.TopCard.EqualsTraits("Composite");
  194. }
  195. bool CanUseCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  198. }
  199. bool CanActivateCondition(Hashtable hashtable)
  200. {
  201. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  202. CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasCompositeTrait);
  203. }
  204. IEnumerator ActivateCoroutine(Hashtable hashtable)
  205. {
  206. bool deleted = false;
  207. Permanent selectedPermanent = card.PermanentOfThisCard();
  208. if (CardEffectCommons.HasMatchConditionPermanent(HasCompositeTrait))
  209. {
  210. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  211. selectPermanentEffect.SetUp(
  212. selectPlayer: card.Owner,
  213. canTargetCondition: HasCompositeTrait,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. maxCount: 1,
  217. canNoSelect: true,
  218. canEndNotMax: false,
  219. selectPermanentCoroutine: SelectCompositeDigimon,
  220. afterSelectPermanentCoroutine: null,
  221. mode: SelectPermanentEffect.Mode.Custom,
  222. cardEffect: activateClass);
  223. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  224. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  225. IEnumerator SelectCompositeDigimon(Permanent permanent)
  226. {
  227. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  228. targetPermanents: new List<Permanent>() { permanent },
  229. activateClass: activateClass,
  230. successProcess: permanents => SuccessProcess(),
  231. failureProcess: null));
  232. }
  233. IEnumerator SuccessProcess()
  234. {
  235. deleted = true;
  236. yield return null;
  237. }
  238. if (deleted)
  239. {
  240. selectedPermanent.willBeRemoveField = false;
  241. selectedPermanent.HideDeleteEffect();
  242. selectedPermanent.HideHandBounceEffect();
  243. selectedPermanent.HideDeckBounceEffect();
  244. selectedPermanent.HideWillRemoveFieldEffect();
  245. }
  246. }
  247. }
  248. }
  249. #endregion
  250. #region All Turns
  251. if (timing == EffectTiming.OnDestroyedAnyone)
  252. {
  253. ActivateClass activateClass = new ActivateClass();
  254. activateClass.SetUpICardEffect("Trash your opponent's top security card", CanUseCondition, card);
  255. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  256. activateClass.SetHashString("TrashSecurity_BT19-075");
  257. cardEffects.Add(activateClass);
  258. string EffectDiscription()
  259. {
  260. return "[All Turns] [Once Per Turn] When other Digimon or Tamers are deleted, trash your opponent's top security card.";
  261. }
  262. bool OtherPermanentDeleted(Permanent permanent)
  263. {
  264. return permanent.IsDigimon || permanent.IsTamer &&
  265. permanent != card.PermanentOfThisCard();
  266. }
  267. bool CanUseCondition(Hashtable hashtable)
  268. {
  269. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass) &&
  270. CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, OtherPermanentDeleted, activateClass);
  271. }
  272. bool CanActivateCondition(Hashtable hashtable)
  273. {
  274. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  275. }
  276. IEnumerator ActivateCoroutine(Hashtable hashtable)
  277. {
  278. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  279. player: card.Owner.Enemy,
  280. destroySecurityCount: 1,
  281. cardEffect: activateClass,
  282. fromTop: true).DestroySecurity());
  283. }
  284. }
  285. #endregion
  286. return cardEffects;
  287. }
  288. }
  289. }