EX6_039.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX6
  5. {
  6. public class EX6_039 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region When Would be Played
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete 1 digimon with [Unidentified] trait, to get Play Cost -3", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. activateClass.SetHashString("PlayCost-12_BT5_085");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "When this card would be played from the hand, by deleting 1 of your Digimon with the [Unidentified] trait, reduce the play cost by 3.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  26. {
  27. if (permanent.TopCard.ContainsTraits("Unidentified") && permanent.IsDigimon)
  28. {
  29. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  30. {
  31. if (permanent.CanBeDestroyedBySkill(activateClass))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CardCondition(CardSource cardSource)
  41. {
  42. if (cardSource == card)
  43. return CardEffectCommons.IsExistOnHand(cardSource);
  44. return false;
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition);
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  57. {
  58. bool CanNoSelect = true;
  59. CardSource Card = CardEffectCommons.GetCardFromHashtable(_hashtable);
  60. if (Card != null)
  61. {
  62. if (Card.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > Card.Owner.MaxMemoryCost)
  63. {
  64. CanNoSelect = false;
  65. }
  66. }
  67. int maxCount = 1;
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. selectPermanentEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectPermanentCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: CanNoSelect,
  76. canEndNotMax: false,
  77. selectPermanentCoroutine: SelectPermanentCoroutine,
  78. afterSelectPermanentCoroutine: null,
  79. mode: SelectPermanentEffect.Mode.Custom,
  80. cardEffect: activateClass);
  81. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  86. IEnumerator SuccessProcess()
  87. {
  88. if (card.Owner.CanReduceCost(null, card))
  89. {
  90. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  91. }
  92. ChangeCostClass changeCostClass = new ChangeCostClass();
  93. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition1, card);
  94. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  95. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  96. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  97. bool CanUseCondition1(Hashtable hashtable)
  98. {
  99. return true;
  100. }
  101. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  102. {
  103. if (CardSourceCondition(cardSource))
  104. {
  105. if (RootCondition(root))
  106. {
  107. if (PermanentsCondition(targetPermanents))
  108. {
  109. Cost -= 3;
  110. }
  111. }
  112. }
  113. return Cost;
  114. }
  115. bool PermanentsCondition(List<Permanent> targetPermanents)
  116. {
  117. if (targetPermanents == null)
  118. {
  119. return true;
  120. }
  121. else
  122. {
  123. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  124. {
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. bool CardSourceCondition(CardSource cardSource)
  131. {
  132. return cardSource == card;
  133. }
  134. bool RootCondition(SelectCardEffect.Root root)
  135. {
  136. return true;
  137. }
  138. bool isUpDown()
  139. {
  140. return true;
  141. }
  142. }
  143. }
  144. }
  145. }
  146. }
  147. #endregion
  148. #region On Play
  149. if (timing == EffectTiming.OnEnterFieldAnyone)
  150. {
  151. ActivateClass activateClass = new ActivateClass();
  152. activateClass.SetUpICardEffect("Delete 1 opponents Digimon, with 3 cost or less", CanUseCondition, card);
  153. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  154. cardEffects.Add(activateClass);
  155. string EffectDiscription()
  156. {
  157. return "[On Play] Delete 1 of your opponent's Digimon with a play cost of 3 or less.";
  158. }
  159. bool IsThreeCostOrLessDigimon(Permanent permanent)
  160. {
  161. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  162. {
  163. if (permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 3 && permanent.IsDigimon)
  164. {
  165. return true;
  166. }
  167. }
  168. return false;
  169. }
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  173. }
  174. bool CanActivateCondition(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  177. {
  178. return CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsThreeCostOrLessDigimon);
  179. }
  180. return false;
  181. }
  182. IEnumerator ActivateCoroutine(Hashtable hashtable)
  183. {
  184. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  185. selectPermanentEffect.SetUp(
  186. selectPlayer: card.Owner,
  187. canTargetCondition: IsThreeCostOrLessDigimon,
  188. canTargetCondition_ByPreSelecetedList: null,
  189. canEndSelectCondition: null,
  190. maxCount: 1,
  191. canNoSelect: false,
  192. canEndNotMax: false,
  193. selectPermanentCoroutine: null,
  194. afterSelectPermanentCoroutine: null,
  195. mode: SelectPermanentEffect.Mode.Destroy,
  196. cardEffect: activateClass);
  197. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  198. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  199. }
  200. }
  201. #endregion
  202. #region When Digivolving
  203. if (timing == EffectTiming.OnEnterFieldAnyone)
  204. {
  205. ActivateClass activateClass = new ActivateClass();
  206. activateClass.SetUpICardEffect("Delete 1 opponents Digimon, with 3 cost or less", CanUseCondition, card);
  207. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  208. cardEffects.Add(activateClass);
  209. string EffectDiscription()
  210. {
  211. return "[When Digivolving] Delete 1 of your opponent's Digimon with a play cost of 3 or less.";
  212. }
  213. bool IsThreeCostOrLessDigimon(Permanent permanent)
  214. {
  215. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  216. {
  217. if (permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 3)
  218. {
  219. return true;
  220. }
  221. }
  222. return false;
  223. }
  224. bool CanUseCondition(Hashtable hashtable)
  225. {
  226. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  227. }
  228. bool CanActivateCondition(Hashtable hashtable)
  229. {
  230. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  231. {
  232. return CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsThreeCostOrLessDigimon);
  233. }
  234. return false;
  235. }
  236. IEnumerator ActivateCoroutine(Hashtable hashtable)
  237. {
  238. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  239. selectPermanentEffect.SetUp(
  240. selectPlayer: card.Owner,
  241. canTargetCondition: IsThreeCostOrLessDigimon,
  242. canTargetCondition_ByPreSelecetedList: null,
  243. canEndSelectCondition: null,
  244. maxCount: 1,
  245. canNoSelect: false,
  246. canEndNotMax: false,
  247. selectPermanentCoroutine: null,
  248. afterSelectPermanentCoroutine: null,
  249. mode: SelectPermanentEffect.Mode.Destroy,
  250. cardEffect: activateClass);
  251. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  252. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  253. }
  254. }
  255. #endregion
  256. #region On Deletion - ESS
  257. if (timing == EffectTiming.OnDestroyedAnyone)
  258. {
  259. ActivateClass activateClass = new ActivateClass();
  260. activateClass.SetUpICardEffect("Play 1 Diaboromon Token", CanUseCondition, card);
  261. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  262. activateClass.SetIsInheritedEffect(true);
  263. cardEffects.Add(activateClass);
  264. string EffectDiscription()
  265. {
  266. return "[On Deletion] If this card has the [Unidentified] trait, you may play 1 [Diaboromon] (Digimon | 14 Cost | Level 6 | White | Mega | Unknown | Unidentified | DP3000) Token without paying the cost.";
  267. }
  268. bool CanUseCondition(Hashtable hashtable)
  269. {
  270. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  271. }
  272. bool CanActivateCondition(Hashtable hashtable)
  273. {
  274. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  275. {
  276. if (card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame()) >= 1)
  277. {
  278. if (card.PermanentJustBeforeRemoveField.CardTraitsJustBeforeRemoveField.Contains("Unidentified"))
  279. {
  280. return true;
  281. }
  282. }
  283. }
  284. return false;
  285. }
  286. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  287. {
  288. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayDiaboromonToken(activateClass));
  289. }
  290. }
  291. #endregion
  292. return cardEffects;
  293. }
  294. }
  295. }