LM_006.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using System.Linq;
  6. namespace DCGO.CardEffects.LM
  7. {
  8. public class LM_006 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Trash - Main
  14. if (timing == EffectTiming.OnDeclaration)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Play this card for reduced cost", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, TrashEffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string TrashEffectDiscription()
  21. {
  22. return "[Trash] [Main] By returning 1 of your Tamers to the bottom of the deck, play this card with the play cost reduced by the play cost of the returned Tamer.";
  23. }
  24. bool CanSelectTamerCondition(Permanent permanent)
  25. {
  26. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  27. {
  28. if (permanent.IsTamer)
  29. {
  30. if(!permanent.CannotReturnToLibrary(activateClass))
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnTrash(card))
  39. {
  40. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectTamerCondition))
  41. {
  42. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: card, payCost: false, cardEffect: activateClass))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. int reduceCost = 0;
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerCondition))
  54. {
  55. Permanent selectedPermanent = null;
  56. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectTamerCondition));
  57. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: CanSelectTamerCondition,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: maxCount,
  64. canNoSelect: false,
  65. canEndNotMax: false,
  66. selectPermanentCoroutine: SelectPermanentCoroutine,
  67. afterSelectPermanentCoroutine: AfterSelectTamer,
  68. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  69. cardEffect: activateClass);
  70. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to return to bottom of deck.", "The opponent is selecting 1 Tamer to return to bottom of deck.");
  71. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  72. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  73. {
  74. selectedPermanent = permanent;
  75. reduceCost = selectedPermanent.PlayCostJustAfterPlayed;
  76. yield return null;
  77. }
  78. #region reduce play cost
  79. IEnumerator AfterSelectTamer(List<Permanent> permanent)
  80. {
  81. if (card.Owner.CanReduceCost(null, card))
  82. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  83. ChangeCostClass changeCostClass = new ChangeCostClass();
  84. changeCostClass.SetUpICardEffect($"Play Cost -{reduceCost}", CanUseCondition1, card);
  85. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  86. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  88. bool CanUseCondition1(Hashtable hashtable)
  89. {
  90. return true;
  91. }
  92. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  93. {
  94. if (CardSourceCondition(cardSource))
  95. {
  96. if (RootCondition(root))
  97. {
  98. if (PermanentsCondition(targetPermanents))
  99. {
  100. Cost -= reduceCost;
  101. }
  102. }
  103. }
  104. return Cost;
  105. }
  106. bool PermanentsCondition(List<Permanent> targetPermanents)
  107. {
  108. if (targetPermanents == null)
  109. {
  110. return true;
  111. }
  112. else
  113. {
  114. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  115. {
  116. return true;
  117. }
  118. }
  119. return false;
  120. }
  121. bool CardSourceCondition(CardSource cardSource)
  122. {
  123. return true;
  124. }
  125. bool RootCondition(SelectCardEffect.Root root)
  126. {
  127. return true;
  128. }
  129. bool isUpDown()
  130. {
  131. return true;
  132. }
  133. }
  134. #endregion
  135. if (selectedPermanent != null)
  136. {
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  138. cardSources: new List<CardSource> { card },
  139. activateClass: activateClass,
  140. payCost: true,
  141. isTapped: false,
  142. root: SelectCardEffect.Root.Trash,
  143. activateETB: true));
  144. }
  145. }
  146. }
  147. }
  148. #endregion
  149. #region On Play/When Digivolving Shared
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.IsExistOnBattleArea(card))
  153. {
  154. return true;
  155. }
  156. return false;
  157. }
  158. #endregion
  159. #region On Play
  160. if (timing == EffectTiming.OnEnterFieldAnyone)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  165. cardEffects.Add(activateClass);
  166. string EffectDiscription()
  167. {
  168. return "[On Play] Trash the bottom 3 digivolution cards of 1 of your opponent's Digimon. Then, until the end of their turn, none of their Digimon with no digivolution cards can't attack.";
  169. }
  170. bool CanSelectPermanentCondition(Permanent permanent)
  171. {
  172. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  173. }
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  177. }
  178. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  179. {
  180. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  181. {
  182. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  183. selectPermanentEffect.SetUp(
  184. selectPlayer: card.Owner,
  185. canTargetCondition: CanSelectPermanentCondition,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. maxCount: 1,
  189. canNoSelect: false,
  190. canEndNotMax: false,
  191. selectPermanentCoroutine: SelectPermanentCoroutine,
  192. afterSelectPermanentCoroutine: null,
  193. mode: SelectPermanentEffect.Mode.Custom,
  194. cardEffect: activateClass);
  195. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  196. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  197. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  198. {
  199. Permanent selectedPermanent = permanent;
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 3, isFromTop: false, activateClass: activateClass));
  201. }
  202. }
  203. bool AttackerCondition(Permanent attacker)
  204. {
  205. return attacker.DigivolutionCards.Count == 0;
  206. }
  207. bool DefenderCondition(Permanent defender)
  208. {
  209. return true;
  210. }
  211. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttackPlayerEffect(
  212. attackerCondition: AttackerCondition,
  213. defenderCondition: DefenderCondition,
  214. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  215. activateClass: activateClass,
  216. effectName: "Can't Attack"));
  217. }
  218. }
  219. #endregion
  220. #region When Digivolving
  221. if (timing == EffectTiming.OnEnterFieldAnyone)
  222. {
  223. ActivateClass activateClass = new ActivateClass();
  224. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  225. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  226. cardEffects.Add(activateClass);
  227. string EffectDiscription()
  228. {
  229. return "[When Digivolving] Trash the bottom 3 digivolution cards of 1 of your opponent's Digimon. Then, until the end of their turn, none of their Digimon with no digivolution cards can't attack.";
  230. }
  231. bool CanSelectPermanentCondition(Permanent permanent)
  232. {
  233. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  234. {
  235. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  236. {
  237. return true;
  238. }
  239. }
  240. return false;
  241. }
  242. bool CanUseCondition(Hashtable hashtable)
  243. {
  244. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  245. }
  246. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  247. {
  248. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  249. {
  250. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  251. selectPermanentEffect.SetUp(
  252. selectPlayer: card.Owner,
  253. canTargetCondition: CanSelectPermanentCondition,
  254. canTargetCondition_ByPreSelecetedList: null,
  255. canEndSelectCondition: null,
  256. maxCount: 1,
  257. canNoSelect: false,
  258. canEndNotMax: false,
  259. selectPermanentCoroutine: SelectPermanentCoroutine,
  260. afterSelectPermanentCoroutine: null,
  261. mode: SelectPermanentEffect.Mode.Custom,
  262. cardEffect: activateClass);
  263. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  264. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  265. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  266. {
  267. Permanent selectedPermanent = permanent;
  268. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 3, isFromTop: false, activateClass: activateClass));
  269. }
  270. }
  271. bool DefenderCondition(Permanent defender)
  272. {
  273. return true;
  274. }
  275. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaDigimons())
  276. {
  277. if (permanent.DigivolutionCards.Count == 0)
  278. {
  279. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  280. targetPermanent: permanent,
  281. defenderCondition: DefenderCondition,
  282. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  283. activateClass: activateClass,
  284. effectName: "Can't Attack"));
  285. }
  286. }
  287. }
  288. }
  289. #endregion
  290. return cardEffects;
  291. }
  292. }
  293. }