BT24_081.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Titamon + Skullbaluchimon
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_081: CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Execute
  13. if (timing == EffectTiming.OnEndTurn)
  14. {
  15. cardEffects.Add(CardEffectFactory.ExecuteSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region Piercing
  19. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  20. {
  21. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Rush
  25. if (timing == EffectTiming.None)
  26. {
  27. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Assembly
  31. if (timing == EffectTiming.None)
  32. {
  33. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  34. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  35. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  36. addAssemblyConditionClass.SetNotShowUI(true);
  37. cardEffects.Add(addAssemblyConditionClass);
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return true;
  41. }
  42. AssemblyCondition GetAssembly(CardSource cardSource)
  43. {
  44. if (cardSource == card)
  45. {
  46. AssemblyConditionElement element1 = new AssemblyConditionElement(CanSelectCardCondition1, selectMessage: "[Titamon]", elementCount: 1);
  47. AssemblyConditionElement element2 = new AssemblyConditionElement(CanSelectCardCondition2, selectMessage: "[SkullBaluchimon]", elementCount: 1);
  48. bool CanSelectCardCondition1(CardSource cardSource)
  49. {
  50. return cardSource != null &&
  51. cardSource.Owner == card.Owner &&
  52. cardSource.IsDigimon &&
  53. cardSource.EqualsCardName("Titamon");
  54. }
  55. bool CanSelectCardCondition2(CardSource cardSource)
  56. {
  57. return cardSource != null &&
  58. cardSource.Owner == card.Owner &&
  59. cardSource.IsDigimon &&
  60. cardSource.EqualsCardName("SkullBaluchimon");
  61. }
  62. AssemblyCondition assemblyCondition = new AssemblyCondition(
  63. elements:new List<AssemblyConditionElement>() { element1, element2 },
  64. reduceCost: 6);
  65. return assemblyCondition;
  66. }
  67. return null;
  68. }
  69. }
  70. #endregion
  71. #region Shared OP WD WA
  72. string SharedEffectName()
  73. {
  74. return "Trash a card to delete all opponent's lowest digimon.";
  75. }
  76. string SharedEffectDescription(string tag)
  77. {
  78. return $"[{tag}] By trashing 1 card in your hand, delete all of your opponent's Digimon with the lowest level.";
  79. }
  80. bool SharedCanActivateCondition(Hashtable hashtable)
  81. {
  82. if (CardEffectCommons.IsExistOnBattleArea(card))
  83. {
  84. if (card.Owner.HandCards.Count >= 1)
  85. {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91. bool CanSelectPermanentCondition(Permanent permanent)
  92. {
  93. return CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  94. }
  95. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  96. {
  97. if (card.Owner.HandCards.Count >= 1)
  98. {
  99. bool discarded = false;
  100. int discardCount = 1;
  101. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  102. selectHandEffect.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: (cardSource) => true,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. maxCount: discardCount,
  108. canNoSelect: true,
  109. canEndNotMax: false,
  110. isShowOpponent: true,
  111. selectCardCoroutine: null,
  112. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  113. mode: SelectHandEffect.Mode.Discard,
  114. cardEffect: activateClass);
  115. selectHandEffect.SetUpCustomMessage("Select 1 Card to trash.", "The opponent is selecting 1 card to trash from their hand.");
  116. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  117. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  118. {
  119. if (cardSources.Count >= 1)
  120. {
  121. discarded = true;
  122. yield return null;
  123. }
  124. }
  125. if (discarded && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  126. {
  127. List<Permanent> deleteTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(CanSelectPermanentCondition);
  128. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(deleteTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  129. }
  130. }
  131. }
  132. #endregion
  133. #region On Play
  134. if (timing == EffectTiming.OnEnterFieldAnyone)
  135. {
  136. ActivateClass activateClass = new ActivateClass();
  137. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  138. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  139. cardEffects.Add(activateClass);
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  143. && CardEffectCommons.IsExistOnBattleArea(card);
  144. }
  145. }
  146. #endregion
  147. #region When Digivolving
  148. if (timing == EffectTiming.OnEnterFieldAnyone)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  152. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  153. cardEffects.Add(activateClass);
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  157. && CardEffectCommons.IsExistOnBattleArea(card);
  158. }
  159. }
  160. #endregion
  161. #region When Attacking
  162. if (timing == EffectTiming.OnAllyAttack)
  163. {
  164. ActivateClass activateClass = new ActivateClass();
  165. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  166. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Attacking"));
  167. cardEffects.Add(activateClass);
  168. bool CanUseCondition(Hashtable hashtable)
  169. {
  170. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  171. && CardEffectCommons.IsExistOnBattleArea(card);
  172. }
  173. }
  174. #endregion
  175. #region On Deletion
  176. if (timing == EffectTiming.OnDestroyedAnyone)
  177. {
  178. ActivateClass activateClass = new ActivateClass();
  179. activateClass.SetUpICardEffect("You may play 1 Titamon or level 5 or lower Titan Digimon", CanUseCondition, card);
  180. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  181. cardEffects.Add(activateClass);
  182. string EffectDescription()
  183. {
  184. return "[On Deletion] You may play 1 [Titamon] or 1 level 5 or lower Digimon card with the [Titan] trait from your trash without paying the cost.";
  185. }
  186. bool CanUseCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  189. }
  190. bool CanActivateCondition(Hashtable hashtable)
  191. {
  192. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasCorrectTrait);
  193. }
  194. bool HasCorrectTrait(CardSource cardSource)
  195. {
  196. return cardSource.IsDigimon &&
  197. (cardSource.EqualsCardName("Titamon") || (
  198. cardSource.EqualsTraits("Titan") &&
  199. cardSource.HasLevel && cardSource.Level <= 5
  200. )) &&
  201. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  202. }
  203. IEnumerator ActivateCoroutine(Hashtable hashtable)
  204. {
  205. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasCorrectTrait))
  206. {
  207. CardSource selectedCard = null;
  208. #region Select Digimon
  209. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  210. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, HasCorrectTrait));
  211. selectCardEffect.SetUp(
  212. canTargetCondition: HasCorrectTrait,
  213. canTargetCondition_ByPreSelecetedList: null,
  214. canEndSelectCondition: null,
  215. canNoSelect: () => true,
  216. selectCardCoroutine: SelectCardCoroutine,
  217. afterSelectCardCoroutine: null,
  218. message: "Select 1 Digimon card to play.",
  219. maxCount: maxCount,
  220. canEndNotMax: false,
  221. isShowOpponent: true,
  222. mode: SelectCardEffect.Mode.Custom,
  223. root: SelectCardEffect.Root.Trash,
  224. customRootCardList: null,
  225. canLookReverseCard: true,
  226. selectPlayer: card.Owner,
  227. cardEffect: activateClass);
  228. IEnumerator SelectCardCoroutine(CardSource cardSource)
  229. {
  230. selectedCard = cardSource;
  231. yield return null;
  232. }
  233. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card to play.", "The opponent is selecting 1 Digimon card to play.");
  234. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  235. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  236. #endregion
  237. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  238. cardSources: new List<CardSource>() { selectedCard },
  239. activateClass: activateClass,
  240. payCost: false,
  241. isTapped: false,
  242. root: SelectCardEffect.Root.Trash,
  243. activateETB: true)
  244. );
  245. }
  246. }
  247. }
  248. #endregion
  249. return cardEffects;
  250. }
  251. }
  252. }