EX5_012.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_012 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.None)
  11. {
  12. static bool PermanentCondition(Permanent targetPermanent)
  13. {
  14. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4)
  15. {
  16. if (targetPermanent.TopCard.CardTraits.Contains("Light Fang"))
  17. {
  18. return true;
  19. }
  20. if (targetPermanent.TopCard.CardTraits.Contains("LightFang"))
  21. {
  22. return true;
  23. }
  24. if (targetPermanent.TopCard.CardTraits.Contains("Night Claw"))
  25. {
  26. return true;
  27. }
  28. if (targetPermanent.TopCard.CardTraits.Contains("NightClaw"))
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  36. }
  37. if (timing == EffectTiming.None)
  38. {
  39. ChangeCostClass changeCostClass = new ChangeCostClass();
  40. changeCostClass.SetUpICardEffect($"Reduce Play Cost", CanUseCondition, card);
  41. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  42. cardEffects.Add(changeCostClass);
  43. bool PermanentCondition(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  46. {
  47. if (permanent.DigivolutionCards.Count >= 3)
  48. {
  49. if (permanent.TopCard.CardTraits.Contains("Light Fang"))
  50. {
  51. return true;
  52. }
  53. if (permanent.TopCard.CardTraits.Contains("LightFang"))
  54. {
  55. return true;
  56. }
  57. if (permanent.TopCard.CardTraits.Contains("Night Claw"))
  58. {
  59. return true;
  60. }
  61. if (permanent.TopCard.CardTraits.Contains("NightClaw"))
  62. {
  63. return true;
  64. }
  65. if (permanent.TopCard.CardTraits.Contains("Galaxy"))
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. bool CanUseCondition(Hashtable hashtable)
  74. {
  75. if (card.PermanentOfThisCard() == null)
  76. {
  77. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  78. {
  79. return true;
  80. }
  81. }
  82. return false;
  83. }
  84. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  85. {
  86. if (CardSourceCondition(cardSource))
  87. {
  88. if (RootCondition(root))
  89. {
  90. if (PermanentsCondition(targetPermanents))
  91. {
  92. Cost -= 2;
  93. }
  94. }
  95. }
  96. return Cost;
  97. }
  98. bool PermanentsCondition(List<Permanent> targetPermanents)
  99. {
  100. if (targetPermanents == null)
  101. {
  102. return true;
  103. }
  104. else
  105. {
  106. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. bool CardSourceCondition(CardSource cardSource)
  114. {
  115. return cardSource == card;
  116. }
  117. bool RootCondition(SelectCardEffect.Root root)
  118. {
  119. return true;
  120. }
  121. bool isUpDown()
  122. {
  123. return true;
  124. }
  125. }
  126. if (timing == EffectTiming.None)
  127. {
  128. bool PermanentCondition1(Permanent permanent)
  129. {
  130. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  131. {
  132. if (permanent.DigivolutionCards.Count >= 3)
  133. {
  134. if (permanent.TopCard.CardTraits.Contains("Light Fang"))
  135. {
  136. return true;
  137. }
  138. if (permanent.TopCard.CardTraits.Contains("LightFang"))
  139. {
  140. return true;
  141. }
  142. if (permanent.TopCard.CardTraits.Contains("Night Claw"))
  143. {
  144. return true;
  145. }
  146. if (permanent.TopCard.CardTraits.Contains("NightClaw"))
  147. {
  148. return true;
  149. }
  150. if (permanent.TopCard.CardTraits.Contains("Galaxy"))
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. bool Condition()
  159. {
  160. if (card.PermanentOfThisCard() == null)
  161. {
  162. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition1))
  163. {
  164. return true;
  165. }
  166. }
  167. return false;
  168. }
  169. bool PermanentCondition(Permanent targetPermanent)
  170. {
  171. if (targetPermanent != null)
  172. {
  173. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
  174. {
  175. return true;
  176. }
  177. }
  178. return false;
  179. }
  180. bool CardSourceCondition(CardSource cardSource)
  181. {
  182. return cardSource == card;
  183. }
  184. bool RootCondition(SelectCardEffect.Root root)
  185. {
  186. return true;
  187. }
  188. cardEffects.Add(CardEffectFactory.ChangeDigivolutionCostStaticEffect(
  189. changeValue: -2,
  190. permanentCondition: PermanentCondition,
  191. cardCondition: CardSourceCondition,
  192. rootCondition: RootCondition,
  193. isInheritedEffect: false,
  194. card: card,
  195. condition: Condition,
  196. setFixedCost: false));
  197. }
  198. if (timing == EffectTiming.OnEnterFieldAnyone)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("Delete 1 Digimon with 5000 DP or less", CanUseCondition, card);
  202. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  203. cardEffects.Add(activateClass);
  204. string EffectDiscription()
  205. {
  206. return "[On Play] Delete 1 of your opponent's Digimon with 5000 DP or less.";
  207. }
  208. bool CanSelectPermanentCondition(Permanent permanent)
  209. {
  210. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  211. {
  212. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(5000, activateClass))
  213. {
  214. return true;
  215. }
  216. }
  217. return false;
  218. }
  219. bool CanUseCondition(Hashtable hashtable)
  220. {
  221. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  222. }
  223. bool CanActivateCondition(Hashtable hashtable)
  224. {
  225. if (CardEffectCommons.IsExistOnBattleArea(card))
  226. {
  227. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  228. {
  229. return true;
  230. }
  231. }
  232. return false;
  233. }
  234. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  235. {
  236. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  237. {
  238. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  239. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  240. selectPermanentEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: CanSelectPermanentCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: maxCount,
  246. canNoSelect: false,
  247. canEndNotMax: false,
  248. selectPermanentCoroutine: null,
  249. afterSelectPermanentCoroutine: null,
  250. mode: SelectPermanentEffect.Mode.Destroy,
  251. cardEffect: activateClass);
  252. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  253. }
  254. }
  255. }
  256. if (timing == EffectTiming.OnEnterFieldAnyone)
  257. {
  258. ActivateClass activateClass = new ActivateClass();
  259. activateClass.SetUpICardEffect("Delete 1 Digimon with 5000 DP or less", CanUseCondition, card);
  260. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  261. cardEffects.Add(activateClass);
  262. string EffectDiscription()
  263. {
  264. return "[When Digivolving] Delete 1 of your opponent's Digimon with 5000 DP or less.";
  265. }
  266. bool CanSelectPermanentCondition(Permanent permanent)
  267. {
  268. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  269. {
  270. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(5000, activateClass))
  271. {
  272. return true;
  273. }
  274. }
  275. return false;
  276. }
  277. bool CanUseCondition(Hashtable hashtable)
  278. {
  279. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  280. }
  281. bool CanActivateCondition(Hashtable hashtable)
  282. {
  283. if (CardEffectCommons.IsExistOnBattleArea(card))
  284. {
  285. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  286. {
  287. return true;
  288. }
  289. }
  290. return false;
  291. }
  292. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  293. {
  294. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  295. {
  296. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  297. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  298. selectPermanentEffect.SetUp(
  299. selectPlayer: card.Owner,
  300. canTargetCondition: CanSelectPermanentCondition,
  301. canTargetCondition_ByPreSelecetedList: null,
  302. canEndSelectCondition: null,
  303. maxCount: maxCount,
  304. canNoSelect: false,
  305. canEndNotMax: false,
  306. selectPermanentCoroutine: null,
  307. afterSelectPermanentCoroutine: null,
  308. mode: SelectPermanentEffect.Mode.Destroy,
  309. cardEffect: activateClass);
  310. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  311. }
  312. }
  313. }
  314. if (timing == EffectTiming.None)
  315. {
  316. bool Condition()
  317. {
  318. if (CardEffectCommons.IsOwnerTurn(card))
  319. {
  320. return true;
  321. }
  322. return false;
  323. }
  324. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: +2000, isInheritedEffect: true, card: card, condition: Condition));
  325. }
  326. return cardEffects;
  327. }
  328. }