EX2_064.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_064 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete 1 Digimon to get Digivolution Cost -3", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  17. activateClass.SetHashString("DeleteDigimon_EX2_064");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Your Turn][Once Per Turn] When one of your Digimon would digivolve from level 5 to level 6, you may delete 1 of your Digimon to reduce the digivolution cost by 3.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  26. }
  27. bool PermanentCondition(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  30. {
  31. if (permanent.TopCard.Level == 5)
  32. {
  33. if (permanent.TopCard.HasLevel)
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. bool CardCondition(CardSource cardSource)
  42. {
  43. if (cardSource.Level == 6)
  44. {
  45. if (cardSource.HasLevel)
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. if (CardEffectCommons.IsOwnerTurn(card))
  57. {
  58. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  59. {
  60. return true;
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanActivateCondition(Hashtable hashtable)
  67. {
  68. if (CardEffectCommons.IsExistOnBattleArea(card))
  69. {
  70. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  78. {
  79. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  80. {
  81. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: true,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  100. IEnumerator SuccessProcess()
  101. {
  102. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  103. ChangeCostClass changeCostClass = new ChangeCostClass();
  104. changeCostClass.SetUpICardEffect("Digivolution Cost -3", CanUseCondition1, card);
  105. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  106. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  108. bool CanUseCondition1(Hashtable hashtable)
  109. {
  110. return true;
  111. }
  112. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  113. {
  114. if (CardSourceCondition(cardSource))
  115. {
  116. if (RootCondition(root))
  117. {
  118. if (PermanentsCondition(targetPermanents))
  119. {
  120. Cost -= 3;
  121. }
  122. }
  123. }
  124. return Cost;
  125. }
  126. bool PermanentsCondition(List<Permanent> targetPermanents)
  127. {
  128. if (targetPermanents != null)
  129. {
  130. if (targetPermanents.Count(PermanentCondition) >= 1)
  131. {
  132. return true;
  133. }
  134. }
  135. return false;
  136. }
  137. bool PermanentCondition(Permanent targetPermanent)
  138. {
  139. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  140. }
  141. bool CardSourceCondition(CardSource cardSource)
  142. {
  143. if (cardSource != null)
  144. {
  145. if (cardSource.Owner == card.Owner)
  146. {
  147. return true;
  148. }
  149. }
  150. return false;
  151. }
  152. bool RootCondition(SelectCardEffect.Root root)
  153. {
  154. return true;
  155. }
  156. bool isUpDown()
  157. {
  158. return true;
  159. }
  160. yield return null;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. if (timing == EffectTiming.None)
  167. {
  168. ChangeCostClass changeCostClass = new ChangeCostClass();
  169. changeCostClass.SetUpICardEffect("Digivolution Cost -3", CanUseCondition, card);
  170. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  171. changeCostClass.SetNotShowUI(true);
  172. cardEffects.Add(changeCostClass);
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. if (!card.Owner.isYou && GManager.instance.IsAI)
  176. {
  177. return false;
  178. }
  179. if (isExistOnField(card))
  180. {
  181. if (CardEffectCommons.IsOwnerTurn(card))
  182. {
  183. ICardEffect activateClass = null;
  184. if (card.EffectList(EffectTiming.BeforePayCost).Count >= 1)
  185. {
  186. foreach (ICardEffect cardEffect in card.EffectList(EffectTiming.BeforePayCost))
  187. {
  188. if (cardEffect.HashString == "DeleteDigimon_EX2_064")
  189. {
  190. activateClass = cardEffect;
  191. break;
  192. }
  193. }
  194. }
  195. if (activateClass != null)
  196. {
  197. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass, activateClass.MaxCountPerTurn))
  198. {
  199. bool CanSelectPermanentCondition(Permanent permanent)
  200. {
  201. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  202. {
  203. if (permanent.CanBeDestroyedBySkill(activateClass))
  204. {
  205. if (permanent.CanSelectBySkill(activateClass))
  206. {
  207. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  208. {
  209. return true;
  210. }
  211. }
  212. }
  213. }
  214. return false;
  215. }
  216. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  217. {
  218. return true;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. return false;
  225. }
  226. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  227. {
  228. if (CardSourceCondition(cardSource))
  229. {
  230. if (RootCondition(root))
  231. {
  232. if (PermanentsCondition(targetPermanents, cardSource))
  233. {
  234. Cost -= 3;
  235. }
  236. }
  237. }
  238. return Cost;
  239. }
  240. bool PermanentsCondition(List<Permanent> targetPermanents, CardSource cardSource)
  241. {
  242. if (targetPermanents != null)
  243. {
  244. if (card.Owner.CanReduceCost(targetPermanents, cardSource))
  245. {
  246. foreach (Permanent targetPermanent in targetPermanents)
  247. {
  248. if (targetPermanent != null)
  249. {
  250. if (targetPermanent.TopCard != null)
  251. {
  252. if (targetPermanent.Level == 5)
  253. {
  254. if (targetPermanent.TopCard.Owner == card.Owner)
  255. {
  256. return true;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. return false;
  265. }
  266. bool CardSourceCondition(CardSource cardSource)
  267. {
  268. if (cardSource != null)
  269. {
  270. if (cardSource.Owner == card.Owner)
  271. {
  272. if (cardSource.Level == 6)
  273. {
  274. return true;
  275. }
  276. }
  277. }
  278. return false;
  279. }
  280. bool RootCondition(SelectCardEffect.Root root)
  281. {
  282. return true;
  283. }
  284. bool isUpDown()
  285. {
  286. return true;
  287. }
  288. }
  289. if (timing == EffectTiming.SecuritySkill)
  290. {
  291. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  292. }
  293. return cardEffects;
  294. }
  295. }
  296. }