Cthyllamon_LM_006.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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 Cthyllamon_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, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  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: true, 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 OnPlay/When Digivolving
  150. if(timing == EffectTiming.OnEnterFieldAnyone)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  155. cardEffects.Add(activateClass);
  156. string EffectDiscription()
  157. {
  158. return "[On Play] [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.";
  159. }
  160. bool CanSelectPermanentCondition(Permanent permanent)
  161. {
  162. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  163. {
  164. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  165. {
  166. return true;
  167. }
  168. }
  169. return false;
  170. }
  171. bool CanUseCondition(Hashtable hashtable)
  172. {
  173. return CardEffectCommons.CanTriggerOnPlay(hashtable, card) || CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.IsExistOnBattleArea(card))
  178. {
  179. return true;
  180. }
  181. return false;
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  184. {
  185. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  186. {
  187. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  188. selectPermanentEffect.SetUp(
  189. selectPlayer: card.Owner,
  190. canTargetCondition: CanSelectPermanentCondition,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. maxCount: 1,
  194. canNoSelect: false,
  195. canEndNotMax: false,
  196. selectPermanentCoroutine: SelectPermanentCoroutine,
  197. afterSelectPermanentCoroutine: null,
  198. mode: SelectPermanentEffect.Mode.Custom,
  199. cardEffect: activateClass);
  200. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  201. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  202. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  203. {
  204. Permanent selectedPermanent = permanent;
  205. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 3, isFromTop: false, activateClass: activateClass));
  206. }
  207. }
  208. bool AttackerCondition(Permanent attacker)
  209. {
  210. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(attacker, card))
  211. {
  212. if (attacker.HasNoDigivolutionCards)
  213. {
  214. return true;
  215. }
  216. }
  217. return false;
  218. }
  219. bool DefenderCondition(Permanent defender)
  220. {
  221. return true;
  222. }
  223. foreach(Permanent permanent in card.Owner.Enemy.GetBattleAreaDigimons())
  224. {
  225. if (permanent.DigivolutionCards.Count == 0)
  226. {
  227. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  228. targetPermanent: permanent,
  229. defenderCondition: DefenderCondition,
  230. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  231. activateClass: activateClass,
  232. effectName: "Can't Attack"));
  233. }
  234. }
  235. }
  236. }
  237. #endregion
  238. return cardEffects;
  239. }
  240. }
  241. }