P_219.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. using System.Linq.Expressions;
  9. // Flame Inferno
  10. namespace DCGO.CardEffects.P
  11. {
  12. public class P_219 : CEntity_Effect
  13. {
  14. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  15. {
  16. List<ICardEffect> cardEffects = new List<ICardEffect>();
  17. #region Reduce Use Cost
  18. if (timing == EffectTiming.BeforePayCost)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("Reduce Use Cost -3", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  23. cardEffects.Add(activateClass);
  24. string EffectDiscription()
  25. {
  26. return "When this card would be used, if your opponent has 10 or more cards in their trash, reduce the use cost by 3";
  27. }
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card))
  31. return card.Owner.Enemy.TrashCards.Count >= 10;
  32. return false;
  33. }
  34. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  35. {
  36. if (card.Owner.CanReduceCost(null, card))
  37. {
  38. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  39. }
  40. ChangeCostClass changeCostClass = new ChangeCostClass();
  41. changeCostClass.SetUpICardEffect("Use Cost -3", CanUseCondition1, card);
  42. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  43. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  44. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  45. bool CanUseCondition1(Hashtable hashtable)
  46. {
  47. return true;
  48. }
  49. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  50. {
  51. if (CardSourceCondition(cardSource))
  52. {
  53. if (RootCondition(root))
  54. {
  55. if (PermanentsCondition(targetPermanents))
  56. {
  57. Cost -= 3;
  58. }
  59. }
  60. }
  61. return Cost;
  62. }
  63. bool PermanentsCondition(List<Permanent> targetPermanents)
  64. {
  65. if (targetPermanents == null)
  66. {
  67. return true;
  68. }
  69. else
  70. {
  71. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  72. {
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. bool CardSourceCondition(CardSource cardSource)
  79. {
  80. if (cardSource != null)
  81. {
  82. if (cardSource == card)
  83. {
  84. return true;
  85. }
  86. }
  87. return false;
  88. }
  89. bool RootCondition(SelectCardEffect.Root root)
  90. {
  91. return true;
  92. }
  93. bool isUpDown()
  94. {
  95. return true;
  96. }
  97. yield return null;
  98. }
  99. }
  100. #endregion
  101. #region Main Option Effect
  102. if (timing == EffectTiming.OptionSkill)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Delete opponent's Digimon. Delete 1 of your own to play [Creepymon] from Trash", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  107. cardEffects.Add(activateClass);
  108. string EffectDiscription()
  109. {
  110. return "[Main] Delete 1 of your opponent's level 6 or lower Digimon. Then, by deleting 1 of your [Evil] or [Fallen Angel] trait Digimon, you may play 1 [Creepymon] from your trash without paying the cost. The Digimon this effect played gains <Rush> and <Blocker> until your opponent's turn ends.";
  111. }
  112. bool CanSelectPermanentCondition(Permanent permanent)
  113. {
  114. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  115. && permanent.Level <= 6
  116. && permanent.TopCard.HasLevel;
  117. }
  118. bool CanSelectPermanentCondition1(Permanent permanent)
  119. {
  120. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  121. && (permanent.TopCard.EqualsTraits("Evil")
  122. || permanent.TopCard.EqualsTraits("Fallen Angel"));
  123. }
  124. bool CanSelectCardCondition(CardSource cardSource)
  125. {
  126. return cardSource.EqualsCardName("Creepymon")
  127. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  128. }
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  134. {
  135. #region Delete 1 lvl 6 or lower
  136. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  137. {
  138. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  139. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  140. selectPermanentEffect.SetUp(
  141. selectPlayer: card.Owner,
  142. canTargetCondition: CanSelectPermanentCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. maxCount: maxCount,
  146. canNoSelect: false,
  147. canEndNotMax: false,
  148. selectPermanentCoroutine: null,
  149. afterSelectPermanentCoroutine: null,
  150. mode: SelectPermanentEffect.Mode.Destroy,
  151. cardEffect: activateClass);
  152. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  153. }
  154. #endregion
  155. #region By Deleting 1, Play Creepy
  156. List<CardSource> selectedTrashCard = new List<CardSource>();
  157. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  158. {
  159. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  160. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  161. selectPermanentEffect.SetUp(
  162. selectPlayer: card.Owner,
  163. canTargetCondition: CanSelectPermanentCondition1,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. maxCount: 1,
  167. canNoSelect: true,
  168. canEndNotMax: false,
  169. selectPermanentCoroutine: null,
  170. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  171. mode: SelectPermanentEffect.Mode.Custom,
  172. cardEffect: activateClass);
  173. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  174. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  175. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  176. {
  177. deleteTargetPermanents = permanents.Clone();
  178. yield return null;
  179. }
  180. if (deleteTargetPermanents?.Any() == true)
  181. {
  182. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: SuccessProcess, failureProcess: null));
  183. }
  184. }
  185. IEnumerator SuccessProcess(List<Permanent> permanents)
  186. {
  187. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  188. {
  189. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  190. selectCardEffect.SetUp(
  191. canTargetCondition: CanSelectCardCondition,
  192. canTargetCondition_ByPreSelecetedList: null,
  193. canEndSelectCondition: null,
  194. canNoSelect: () => true,
  195. selectCardCoroutine: SelectCardCoroutine,
  196. afterSelectCardCoroutine: null,
  197. message: "Select 1 [Creepymon] to play",
  198. maxCount: 1,
  199. canEndNotMax: false,
  200. isShowOpponent: true,
  201. mode: SelectCardEffect.Mode.Custom,
  202. root: SelectCardEffect.Root.Trash,
  203. customRootCardList: null,
  204. canLookReverseCard: true,
  205. selectPlayer: card.Owner,
  206. cardEffect: activateClass);
  207. IEnumerator SelectCardCoroutine(CardSource cardSource)
  208. {
  209. selectedTrashCard.Add(cardSource);
  210. yield return null;
  211. }
  212. selectCardEffect.SetUpCustomMessage("Select 1 [Creepymon] to play", "The opponent is selecting 1 [Creepymon] to play");
  213. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  214. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  215. if (selectedTrashCard != null)
  216. {
  217. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  218. cardSources: selectedTrashCard,
  219. activateClass: activateClass,
  220. payCost: false,
  221. isTapped: false,
  222. root: SelectCardEffect.Root.Trash,
  223. activateETB: true));
  224. }
  225. }
  226. }
  227. #endregion
  228. #region Give Rush and Blocker
  229. foreach (CardSource cardSource in selectedTrashCard)
  230. {
  231. if (CardEffectCommons.IsExistOnBattleArea(cardSource))
  232. {
  233. Permanent selectedPermanent = cardSource.PermanentOfThisCard();
  234. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  235. targetPermanent: selectedPermanent,
  236. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  237. activateClass: activateClass));
  238. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  239. targetPermanent: selectedPermanent,
  240. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  241. activateClass: activateClass));
  242. }
  243. }
  244. #endregion
  245. }
  246. }
  247. #endregion
  248. #region Security Effect
  249. if (timing == EffectTiming.SecuritySkill)
  250. {
  251. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  252. card: card,
  253. cardEffects: ref cardEffects,
  254. effectName: $"Delete opponent's Digimon. Delete 1 of your own to play [Creepymon] from Trash");
  255. }
  256. #endregion
  257. return cardEffects;
  258. }
  259. }
  260. }