BT24_016.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Lamiamon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_016 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Hand Main
  14. if (timing == EffectTiming.OnDeclaration)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Place 1 [Dimetromon] from trash under 1 [Elizamon], to digivolve for 3", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return "[Hand] [Main] If you have [Owen Dreadnought], by placing 1 [Dimetromon] from your trash as any of your [Elizamon]'s bottom digivolution card, it digivolves into this card for a digivolution cost of 3, ignoring digivolution requirements.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.IsExistOnHand(card)
  27. && CardEffectCommons.IsOwnerTurn(card)
  28. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsOwen)
  29. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsElizamon)
  30. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsDimetromon);
  31. }
  32. bool IsOwen(Permanent permanent)
  33. {
  34. return permanent.IsTamer && permanent.TopCard.EqualsCardName("Owen Dreadnought");
  35. }
  36. bool IsElizamon(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  39. permanent.TopCard.EqualsCardName("Elizamon");
  40. }
  41. bool IsDimetromon(CardSource source)
  42. {
  43. return source.IsDigimon && source.EqualsCardName("Dimetromon");
  44. }
  45. bool IsLamiamon(CardSource cardSource)
  46. {
  47. return CardEffectCommons.IsExistOnHand(cardSource) && cardSource == card;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable hashtable)
  50. {
  51. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsOwen))
  52. {
  53. Permanent Elizamon = null;
  54. CardSource Dimetromon = null;
  55. #region Select Dimetromon From Trash
  56. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsDimetromon));
  57. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  58. selectCardEffect.SetUp(
  59. canTargetCondition: IsDimetromon,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. canNoSelect: () => false,
  63. selectCardCoroutine: SelectCardCoroutine,
  64. afterSelectCardCoroutine: null,
  65. message: "Select 1 [Dimetromon] to add as digivolution source",
  66. maxCount: maxCount,
  67. canEndNotMax: false,
  68. isShowOpponent: true,
  69. mode: SelectCardEffect.Mode.Custom,
  70. root: SelectCardEffect.Root.Trash,
  71. customRootCardList: null,
  72. canLookReverseCard: true,
  73. selectPlayer: card.Owner,
  74. cardEffect: activateClass);
  75. IEnumerator SelectCardCoroutine(CardSource cardSource)
  76. {
  77. Dimetromon = cardSource;
  78. yield return null;
  79. }
  80. selectCardEffect.SetUpCustomMessage("Select 1 [Dimetromon] to add as digivolution source.", "The opponent is selecting 1 [Dimetromon] to add as digivolution source.");
  81. yield return StartCoroutine(selectCardEffect.Activate());
  82. #endregion
  83. if (Dimetromon != null)
  84. {
  85. #region Select Elizamon Permanent
  86. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsElizamon));
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: IsElizamon,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount1,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: SelectPermanentCoroutine,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Custom,
  99. cardEffect: activateClass);
  100. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  101. {
  102. Elizamon = permanent;
  103. yield return null;
  104. }
  105. selectPermanentEffect.SetUpCustomMessage("Select 1 [Elizamon] to add digivolution sources.", "The opponent is selecting 1 [Elizamon] to add digivolution sources.");
  106. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  107. #endregion
  108. if (Elizamon != null)
  109. {
  110. yield return ContinuousController.instance.StartCoroutine(Elizamon.AddDigivolutionCardsBottom(new List<CardSource>() { Dimetromon }, activateClass));
  111. if (Elizamon.DigivolutionCards.Contains(Dimetromon))
  112. {
  113. #region Digivolve into Lamiamon
  114. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  115. Elizamon,
  116. IsLamiamon,
  117. payCost: true,
  118. reduceCostTuple: null,
  119. fixedCostTuple: null,
  120. ignoreDigivolutionRequirementFixedCost: 3,
  121. isHand: true,
  122. activateClass: activateClass,
  123. successProcess: null,
  124. ignoreSelection: true,
  125. failedProcess: FailureProcess()));
  126. #endregion
  127. }
  128. IEnumerator FailureProcess()
  129. {
  130. List<IDiscardHand> discardHands = new List<IDiscardHand>() { new IDiscardHand(card, null) };
  131. yield return ContinuousController.instance.StartCoroutine(new IDiscardHands(discardHands, null).DiscardHands());
  132. }
  133. }
  134. }
  135. }
  136. }
  137. }
  138. #endregion
  139. #region Shared WD/WA
  140. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  141. {
  142. bool CanSelectCardCondition(CardSource cardSource)
  143. {
  144. return true;
  145. }
  146. CardSource selectedCard = null;
  147. if (card.Owner.Enemy.HandCards.Count() >= 1 && card.Owner.CanAddSecurity(activateClass))
  148. {
  149. int maxCount = 1;
  150. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  151. selectHandEffect.SetUp(
  152. selectPlayer: card.Owner.Enemy,
  153. canTargetCondition: CanSelectCardCondition,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: maxCount,
  157. canNoSelect: false,
  158. canEndNotMax: false,
  159. isShowOpponent: false,
  160. selectCardCoroutine: SelectCardCoroutine,
  161. afterSelectCardCoroutine: null,
  162. mode: SelectHandEffect.Mode.Custom,
  163. cardEffect: activateClass);
  164. selectHandEffect.SetUpCustomMessage(
  165. "Select 1 card to place at the bottom of security.",
  166. "The opponent is selecting 1 card to place at the bottom of security.");
  167. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  168. IEnumerator SelectCardCoroutine(CardSource cardSource)
  169. {
  170. selectedCard = cardSource;
  171. yield return null;
  172. }
  173. }
  174. if (selectedCard != null)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard, toTop: false));
  177. }
  178. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  179. player: card.Owner.Enemy,
  180. destroySecurityCount: 1,
  181. cardEffect: activateClass,
  182. fromTop: true).DestroySecurity());
  183. }
  184. string SharedEffectDescription(string tag)
  185. {
  186. return $"[{tag}] [Once Per Turn] Your opponent places 1 card from their hand as the bottom security card. Then, trash their top security card.";
  187. }
  188. bool SharedCanActivateCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  191. }
  192. #endregion
  193. #region When Attacking
  194. if (timing == EffectTiming.OnAllyAttack)
  195. {
  196. ActivateClass activateClass = new ActivateClass();
  197. activateClass.SetUpICardEffect("Opponent places 1 card from hand in security bottom. Trash their security top", CanUseCondition, card);
  198. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  199. activateClass.SetHashString("WAWD_BT24-016");
  200. cardEffects.Add(activateClass);
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  204. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  205. }
  206. }
  207. #endregion
  208. #region When Digivolving
  209. if (timing == EffectTiming.OnEnterFieldAnyone)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect("Opponent places 1 card from hand in security bottom. Trash their security top", CanUseCondition, card);
  213. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  214. activateClass.SetHashString("WAWD_BT24-016");
  215. cardEffects.Add(activateClass);
  216. bool CanUseCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  219. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  220. }
  221. }
  222. #endregion
  223. #region All Turns - ESS
  224. if (timing == EffectTiming.OnLoseSecurity)
  225. {
  226. ActivateClass activateClass = new ActivateClass();
  227. activateClass.SetUpICardEffect("Play 1 [Reptile] or [Dragonkin] from hand", CanUseCondition, card);
  228. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  229. activateClass.SetIsInheritedEffect(true);
  230. activateClass.SetHashString("PlayDigimon_BT24_016");
  231. cardEffects.Add(activateClass);
  232. string EffectDescription()
  233. => "[All Turns] [Once Per Turn] When your opponent's security stack is removed from, you may play 1 5000 DP or lower [Reptile] or [Dragonkin] trait Digimon card from your hand without paying the cost.";
  234. bool CanUseCondition(Hashtable hashtable)
  235. {
  236. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  237. {
  238. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, PlayerCondition))
  239. {
  240. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  241. {
  242. return true;
  243. }
  244. }
  245. }
  246. return false;
  247. }
  248. bool CanActivateCondition(Hashtable hashtable)
  249. {
  250. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  251. {
  252. return true;
  253. }
  254. return false;
  255. }
  256. bool PlayerCondition(Player player)
  257. {
  258. if (player == card.Owner.Enemy)
  259. {
  260. return true;
  261. }
  262. return false;
  263. }
  264. bool CanSelectCardCondition(CardSource source)
  265. {
  266. if (source.IsDigimon)
  267. {
  268. if (source.EqualsTraits("Reptile") || source.EqualsTraits("Dragonkin"))
  269. {
  270. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: source, payCost: false, cardEffect: activateClass))
  271. {
  272. if (source.CardDP <= 5000)
  273. {
  274. return true;
  275. }
  276. }
  277. }
  278. }
  279. return false;
  280. }
  281. IEnumerator ActivateCoroutine(Hashtable hashtable)
  282. {
  283. CardSource selectedCard = null;
  284. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  285. selectHandEffect.SetUp(
  286. selectPlayer: card.Owner,
  287. canTargetCondition: CanSelectCardCondition,
  288. canTargetCondition_ByPreSelecetedList: null,
  289. canEndSelectCondition: null,
  290. maxCount: 1,
  291. canNoSelect: true,
  292. canEndNotMax: false,
  293. isShowOpponent: true,
  294. selectCardCoroutine: SelectCardCoroutine,
  295. afterSelectCardCoroutine: null,
  296. mode: SelectHandEffect.Mode.Custom,
  297. cardEffect: activateClass);
  298. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  299. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  300. yield return StartCoroutine(selectHandEffect.Activate());
  301. IEnumerator SelectCardCoroutine(CardSource cardSource)
  302. {
  303. selectedCard = cardSource;
  304. yield return null;
  305. }
  306. if (selectedCard != null)
  307. {
  308. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  309. }
  310. }
  311. }
  312. #endregion
  313. return cardEffects;
  314. }
  315. }
  316. }