BT23_044.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Lilamon
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_044 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel4
  19. && targetPermanent.TopCard.HasCSTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null)
  27. );
  28. }
  29. #endregion
  30. #region Reduce Cost
  31. bool IsCSOrYuuko(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  34. && permanent.IsDigimon && permanent.TopCard.HasCSTraits
  35. || permanent.IsTamer && permanent.TopCard.EqualsCardName("Yuuko Kamishiro");
  36. }
  37. #region Before Pay Cost - Condition Effect
  38. if (timing == EffectTiming.BeforePayCost)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect("Play cost reduction -3", CanUseCondition, card);
  42. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  43. activateClass.SetHashString("BT23_031_ReducePlayCost");
  44. cardEffects.Add(activateClass);
  45. string EffectDiscription()
  46. {
  47. return "When this card would be played from the hand, if you have [Yuuko Kamishiro] or a [CS] trait Digimon, reduce the play cost by 3.";
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnHand(card)
  56. && CardEffectCommons.HasMatchConditionPermanent(IsCSOrYuuko);
  57. }
  58. bool CardCondition(CardSource cardSource)
  59. {
  60. return CardEffectCommons.IsExistOnHand(cardSource)
  61. && cardSource == card;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. ChangeCostClass changeCostClass = new ChangeCostClass();
  66. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition1, card);
  67. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  68. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  69. bool CanUseCondition1(Hashtable hashtable)
  70. {
  71. return true;
  72. }
  73. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  74. {
  75. if (CardSourceCondition(cardSource))
  76. {
  77. if (RootCondition(root))
  78. {
  79. if (PermanentsCondition(targetPermanents))
  80. {
  81. if (CardEffectCommons.HasMatchConditionPermanent(IsCSOrYuuko))
  82. {
  83. Cost -= 3;
  84. }
  85. }
  86. }
  87. }
  88. return Cost;
  89. }
  90. bool PermanentsCondition(List<Permanent> targetPermanents)
  91. {
  92. if (targetPermanents == null)
  93. {
  94. return true;
  95. }
  96. else
  97. {
  98. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  99. {
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105. bool CardSourceCondition(CardSource cardSource)
  106. {
  107. return cardSource == card;
  108. }
  109. bool RootCondition(SelectCardEffect.Root root)
  110. {
  111. return root == SelectCardEffect.Root.Hand;
  112. }
  113. bool isUpDown()
  114. {
  115. return true;
  116. }
  117. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  118. }
  119. }
  120. #endregion
  121. #region Reduce Play Cost - Not Shown
  122. if (timing == EffectTiming.None)
  123. {
  124. ChangeCostClass changeCostClass = new ChangeCostClass();
  125. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition, card);
  126. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  127. changeCostClass.SetNotShowUI(true);
  128. cardEffects.Add(changeCostClass);
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. if (card.Owner.HandCards.Contains(card))
  132. {
  133. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Play cost reduction -3");
  134. if (activateClass != null)
  135. {
  136. if (CardEffectCommons.HasMatchConditionPermanent(IsCSOrYuuko))
  137. {
  138. return true;
  139. }
  140. }
  141. }
  142. return false;
  143. }
  144. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  145. {
  146. if (CardSourceCondition(cardSource))
  147. {
  148. if (RootCondition(root))
  149. {
  150. if (PermanentsCondition(targetPermanents))
  151. {
  152. if (CardEffectCommons.HasMatchConditionPermanent(IsCSOrYuuko))
  153. {
  154. Cost -= 3;
  155. }
  156. }
  157. }
  158. }
  159. return Cost;
  160. }
  161. bool PermanentsCondition(List<Permanent> targetPermanents)
  162. {
  163. if (targetPermanents == null)
  164. {
  165. return true;
  166. }
  167. else
  168. {
  169. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  170. {
  171. return true;
  172. }
  173. }
  174. return false;
  175. }
  176. bool CardSourceCondition(CardSource cardSource)
  177. {
  178. if (cardSource != null)
  179. {
  180. if (cardSource == card)
  181. {
  182. return true;
  183. }
  184. }
  185. return false;
  186. }
  187. bool RootCondition(SelectCardEffect.Root root)
  188. {
  189. return root == SelectCardEffect.Root.Hand;
  190. }
  191. bool isUpDown()
  192. {
  193. return true;
  194. }
  195. }
  196. #endregion
  197. #endregion
  198. #region OP/WD Shared
  199. bool IsUnSuspendedDigimon(Permanent permanent)
  200. {
  201. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  202. && !permanent.IsSuspended;
  203. }
  204. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  205. {
  206. if (CardEffectCommons.HasMatchConditionPermanent(IsUnSuspendedDigimon))
  207. {
  208. Permanent selectedPermament = null;
  209. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsUnSuspendedDigimon));
  210. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  211. selectPermanentEffect.SetUp(
  212. selectPlayer: card.Owner,
  213. canTargetCondition: IsUnSuspendedDigimon,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. maxCount: maxCount,
  217. canNoSelect: false,
  218. canEndNotMax: false,
  219. selectPermanentCoroutine: SelectPermanentCoroutine,
  220. afterSelectPermanentCoroutine: null,
  221. mode: SelectPermanentEffect.Mode.Tap,
  222. cardEffect: activateClass);
  223. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  224. {
  225. selectedPermament = permanent;
  226. yield return null;
  227. }
  228. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  229. if (selectedPermament != null && selectedPermament.IsSuspended)
  230. {
  231. bool CanSelectPermanentCondition(Permanent permanent)
  232. {
  233. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  234. && (permanent.TopCard.EqualsTraits("Vegetation")
  235. || permanent.TopCard.EqualsTraits("Plant")
  236. || permanent.TopCard.EqualsTraits("Fairy")
  237. || permanent.TopCard.HasCSTraits);
  238. }
  239. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  240. {
  241. Permanent selectedPermament1 = null;
  242. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  243. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  244. selectPermanentEffect1.SetUp(
  245. selectPlayer: card.Owner,
  246. canTargetCondition: CanSelectPermanentCondition,
  247. canTargetCondition_ByPreSelecetedList: null,
  248. canEndSelectCondition: null,
  249. maxCount: maxCount1,
  250. canNoSelect: false,
  251. canEndNotMax: false,
  252. selectPermanentCoroutine: SelectPermanentCoroutine1,
  253. afterSelectPermanentCoroutine: null,
  254. mode: SelectPermanentEffect.Mode.Custom,
  255. cardEffect: activateClass);
  256. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  257. {
  258. selectedPermament1 = permanent;
  259. yield return null;
  260. }
  261. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  262. if (selectedPermament1 != null)
  263. {
  264. bool CardEffectCondition(ICardEffect cardEffect)
  265. {
  266. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  267. }
  268. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  269. targetPermanent: selectedPermament1,
  270. cardEffectCondition: CardEffectCondition,
  271. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  272. activateClass: activateClass,
  273. effectName: "Can't return to hand by opponent's effects"));
  274. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  275. targetPermanent: selectedPermament1,
  276. cardEffectCondition: CardEffectCondition,
  277. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  278. activateClass: activateClass,
  279. effectName: "Can't return to deck by opponent's effects"));
  280. }
  281. }
  282. }
  283. }
  284. }
  285. #endregion
  286. #region On Play
  287. if (timing == EffectTiming.OnEnterFieldAnyone)
  288. {
  289. ActivateClass activateClass = new ActivateClass();
  290. activateClass.SetUpICardEffect("By suspending 1 digimon, 1 digimon cant be bounced to hand & deck", CanUseCondition, card);
  291. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscription());
  292. cardEffects.Add(activateClass);
  293. string EffectDiscription()
  294. {
  295. return "[On Play] By suspending 1 Digimon, until your opponent's turn ends, their effects can't return 1 of your Digimon with [Vegetation], [Plant] or [Fairy] in any of its traits or the [CS] trait to hands or decks.";
  296. }
  297. bool CanUseCondition(Hashtable hashtable)
  298. {
  299. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  300. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  301. }
  302. bool CanActivateCondition(Hashtable hashtable)
  303. {
  304. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  305. && CardEffectCommons.HasMatchConditionPermanent(IsUnSuspendedDigimon);
  306. }
  307. }
  308. #endregion
  309. #region When Digivolving
  310. if (timing == EffectTiming.OnEnterFieldAnyone)
  311. {
  312. ActivateClass activateClass = new ActivateClass();
  313. activateClass.SetUpICardEffect("By suspending 1 digimon, 1 digimon cant be bounced to hand & deck", CanUseCondition, card);
  314. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscription());
  315. cardEffects.Add(activateClass);
  316. string EffectDiscription()
  317. {
  318. return "[When Digivolving] By suspending 1 Digimon, until your opponent's turn ends, their effects can't return 1 of your Digimon with [Vegetation], [Plant] or [Fairy] in any of its traits or the [CS] trait to hands or decks.";
  319. }
  320. bool CanUseCondition(Hashtable hashtable)
  321. {
  322. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  323. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  324. }
  325. bool CanActivateCondition(Hashtable hashtable)
  326. {
  327. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  328. && CardEffectCommons.HasMatchConditionPermanent(IsUnSuspendedDigimon);
  329. }
  330. }
  331. #endregion
  332. #region ESS
  333. if (timing == EffectTiming.OnEndBattle)
  334. {
  335. ActivateClass activateClass = new ActivateClass();
  336. activateClass.SetUpICardEffect("Trash opponent top security", CanUseCondition, card);
  337. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  338. activateClass.SetIsInheritedEffect(true);
  339. activateClass.SetHashString("BT23_044_AT");
  340. cardEffects.Add(activateClass);
  341. string EffectDiscription()
  342. {
  343. return "[All Turns] [Once Per Turn] When this Digimon deletes your opponent's Digimon in battle, trash their top security card.";
  344. }
  345. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  346. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  347. bool CanUseCondition(Hashtable hashtable)
  348. {
  349. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  350. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  351. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  352. }
  353. bool CanActivateCondition(Hashtable hashtable)
  354. {
  355. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  356. }
  357. IEnumerator ActivateCoroutine(Hashtable hashtable)
  358. {
  359. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  360. player: card.Owner.Enemy,
  361. destroySecurityCount: 1,
  362. cardEffect: activateClass,
  363. fromTop: true).DestroySecurity());
  364. }
  365. }
  366. #endregion
  367. return cardEffects;
  368. }
  369. }
  370. }