BT24_074.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // SkullSeadramon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_074 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4
  19. && (targetPermanent.TopCard.HasTSTraits
  20. || targetPermanent.TopCard.HasAquaTraits);
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Shared OP/WD
  26. string SharedEffectName() => "Trash 3 sources, if by effect, delete 1 sourceless.";
  27. string SharedEffectDescription(string tag) => $"[{tag}] Trash any 3 digivolution cards from 1 of your opponent's Digimon. Then, if played by effects, delete 1 of your opponent's Digimon with no digivolution cards.";
  28. bool SharedCanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  31. }
  32. bool CanSelectNoSourcePermanentCondition(Permanent permanent)
  33. {
  34. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  35. && permanent.HasNoDigivolutionCards;
  36. }
  37. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  38. {
  39. bool CanSelectCardCondition(CardSource cardSource)
  40. {
  41. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  42. }
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  46. && permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  47. }
  48. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  49. {
  50. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  51. permanentCondition: CanSelectPermanentCondition,
  52. cardCondition: CanSelectCardCondition,
  53. maxCount: 3,
  54. canNoTrash: false,
  55. isFromOnly1Permanent: true,
  56. activateClass: activateClass
  57. ));
  58. }
  59. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectNoSourcePermanentCondition)
  60. && CardEffectCommons.IsByEffect(hashtable, null)
  61. && CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  62. {
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectNoSourcePermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: 1,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: null,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Destroy,
  75. cardEffect: activateClass);
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  77. }
  78. }
  79. #endregion
  80. #region On Play
  81. if (timing == EffectTiming.OnEnterFieldAnyone)
  82. {
  83. ActivateClass activateClass = new ActivateClass();
  84. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  85. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  86. cardEffects.Add(activateClass);
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  90. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  91. }
  92. }
  93. #endregion
  94. #region When Digivolving
  95. if (timing == EffectTiming.OnEnterFieldAnyone)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  99. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  100. cardEffects.Add(activateClass);
  101. bool CanUseCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  104. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  105. }
  106. }
  107. #endregion
  108. #region On Deletion
  109. if (timing == EffectTiming.OnDestroyedAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("You may play 1 level 4 or lower Digimon", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  114. cardEffects.Add(activateClass);
  115. string EffectDescription()
  116. {
  117. return "[On Deletion] You may play 1 level 4 or lower Digimon card with [Seadramon] in it's name or the [TS] trait from your trash without paying the cost.";
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  122. }
  123. bool CanSelectCardCondition(CardSource cardSource)
  124. {
  125. return cardSource.IsDigimon
  126. && (cardSource.EqualsTraits("TS")
  127. || cardSource.ContainsCardName("Seadramon"))
  128. && cardSource.HasLevel && cardSource.Level <= 4
  129. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  130. }
  131. bool CanActivateCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  134. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable hashtable)
  137. {
  138. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  139. List<CardSource> selectedCards = new List<CardSource>();
  140. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  141. selectCardEffect.SetUp(
  142. canTargetCondition: CanSelectCardCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. canNoSelect: () => true,
  146. selectCardCoroutine: SelectCardCoroutine,
  147. afterSelectCardCoroutine: null,
  148. message: "Select 1 Digimon card to play.",
  149. maxCount: maxCount,
  150. canEndNotMax: false,
  151. isShowOpponent: true,
  152. mode: SelectCardEffect.Mode.Custom,
  153. root: SelectCardEffect.Root.Trash,
  154. customRootCardList: null,
  155. canLookReverseCard: true,
  156. selectPlayer: card.Owner,
  157. cardEffect: activateClass);
  158. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card to play.",
  159. "The opponent is selecting 1 Digimon card to play.");
  160. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  161. yield return StartCoroutine(selectCardEffect.Activate());
  162. IEnumerator SelectCardCoroutine(CardSource cardSource)
  163. {
  164. selectedCards.Add(cardSource);
  165. yield return null;
  166. }
  167. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  168. cardSources: selectedCards,
  169. activateClass: activateClass,
  170. payCost: false,
  171. isTapped: false,
  172. root: SelectCardEffect.Root.Trash,
  173. activateETB: true));
  174. }
  175. }
  176. #endregion
  177. #region When Attacking - ESS
  178. if (timing == EffectTiming.OnAllyAttack)
  179. {
  180. ActivateClass activateClass = new ActivateClass();
  181. activateClass.SetUpICardEffect("Place 1 of your other Digimon as this Digimon's bottom digivolution card to unsuspend this Digimon.", CanUseCondition, card);
  182. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  183. activateClass.SetIsInheritedEffect(true);
  184. activateClass.SetHashString("Attacking_BT24_074");
  185. cardEffects.Add(activateClass);
  186. string EffectDescription()
  187. {
  188. return "[When Attacking] [Once Per Turn] By placing 1 of your other Digimon as this Digimon's bottom digivolution card, it unsuspends.";
  189. }
  190. bool CanSelectPermanentCondition(Permanent permanent)
  191. {
  192. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  193. && permanent != card.PermanentOfThisCard()
  194. && !permanent.TopCard.Equals(card);
  195. }
  196. bool CanUseCondition(Hashtable hashtable)
  197. {
  198. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  199. }
  200. bool CanActivateCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.IsExistOnBattleArea(card)
  203. && !card.PermanentOfThisCard().IsToken
  204. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  205. }
  206. IEnumerator ActivateCoroutine(Hashtable hashtable)
  207. {
  208. List<CardSource> selectedCards = new List<CardSource>();
  209. SelectPermanentEffect selectPermanentEffect =
  210. GManager.instance.GetComponent<SelectPermanentEffect>();
  211. selectPermanentEffect.SetUp(
  212. selectPlayer: card.Owner,
  213. canTargetCondition: CanSelectPermanentCondition,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. maxCount: 1,
  217. canNoSelect: false,
  218. canEndNotMax: false,
  219. selectPermanentCoroutine: SelectPermanentCoroutine,
  220. afterSelectPermanentCoroutine: null,
  221. mode: SelectPermanentEffect.Mode.Custom,
  222. cardEffect: activateClass);
  223. selectPermanentEffect.SetUpCustomMessage(
  224. "Select 1 card to place on bottom of digivolution cards.",
  225. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  226. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  227. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  228. {
  229. selectedCards.Add(permanent.TopCard);
  230. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  231. new List<Permanent[]>() { new Permanent[] { permanent, card.PermanentOfThisCard() } },
  232. false,
  233. activateClass).PlacePermanentToDigivolutionCards());
  234. }
  235. if (selectedCards.Count >= 1)
  236. {
  237. yield return ContinuousController.instance.StartCoroutine(
  238. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() },
  239. activateClass).Unsuspend());
  240. }
  241. }
  242. }
  243. #endregion
  244. return cardEffects;
  245. }
  246. }
  247. }