BT5_085.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. public class BT5_085 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.BeforePayCost)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Delete 1 [Diaboromon] to get Play Cost -12", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. activateClass.SetHashString("PlayCost-12_BT5_085");
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "When playing this card from your hand, you may delete 1 of your [Diaboromon] to reduce this card's play cost by 12.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  27. {
  28. if (permanent.TopCard.CardNames.Contains("Diaboromon"))
  29. {
  30. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  31. {
  32. if (permanent.CanBeDestroyedBySkill(activateClass))
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. bool CardCondition(CardSource cardSource)
  42. {
  43. if (cardSource == card)
  44. {
  45. if (CardEffectCommons.IsExistOnHand(cardSource))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  55. {
  56. return true;
  57. }
  58. return false;
  59. }
  60. bool CanActivateCondition(Hashtable hashtable)
  61. {
  62. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  63. {
  64. return true;
  65. }
  66. return false;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  71. {
  72. bool CanNoSelect = true;
  73. CardSource Card = CardEffectCommons.GetCardFromHashtable(_hashtable);
  74. if (Card != null)
  75. {
  76. if (Card.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > Card.Owner.MaxMemoryCost)
  77. {
  78. CanNoSelect = false;
  79. }
  80. }
  81. int maxCount = 1;
  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: CanNoSelect,
  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. if (card.Owner.CanReduceCost(null, card))
  103. {
  104. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  105. }
  106. ChangeCostClass changeCostClass = new ChangeCostClass();
  107. changeCostClass.SetUpICardEffect("Play Cost -12", CanUseCondition1, card);
  108. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  109. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  110. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  111. bool CanUseCondition1(Hashtable hashtable)
  112. {
  113. return true;
  114. }
  115. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  116. {
  117. if (CardSourceCondition(cardSource))
  118. {
  119. if (RootCondition(root))
  120. {
  121. if (PermanentsCondition(targetPermanents))
  122. {
  123. Cost -= 12;
  124. }
  125. }
  126. }
  127. return Cost;
  128. }
  129. bool PermanentsCondition(List<Permanent> targetPermanents)
  130. {
  131. if (targetPermanents == null)
  132. {
  133. return true;
  134. }
  135. else
  136. {
  137. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  138. {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. bool CardSourceCondition(CardSource cardSource)
  145. {
  146. return cardSource == card;
  147. }
  148. bool RootCondition(SelectCardEffect.Root root)
  149. {
  150. return true;
  151. }
  152. bool isUpDown()
  153. {
  154. return true;
  155. }
  156. }
  157. }
  158. }
  159. }
  160. }
  161. if (timing == EffectTiming.None)
  162. {
  163. ChangeCostClass changeCostClass = new ChangeCostClass();
  164. changeCostClass.SetUpICardEffect("Play Cost -12", CanUseCondition, card);
  165. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  166. changeCostClass.SetNotShowUI(true);
  167. cardEffects.Add(changeCostClass);
  168. bool CanSelectPermanentCondition(Permanent permanent, ICardEffect activateClass)
  169. {
  170. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  171. {
  172. if (permanent.TopCard.CardNames.Contains("Diaboromon"))
  173. {
  174. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  175. {
  176. if (permanent.CanBeDestroyedBySkill(activateClass))
  177. {
  178. return true;
  179. }
  180. }
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. if (card.Owner.HandCards.Contains(card))
  188. {
  189. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Delete 1 [Diaboromon] to get Play Cost -12");
  190. if (activateClass != null)
  191. {
  192. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && CanSelectPermanentCondition(permanent, activateClass)))
  193. {
  194. return true;
  195. }
  196. }
  197. }
  198. return false;
  199. }
  200. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  201. {
  202. if (CardSourceCondition(cardSource))
  203. {
  204. if (RootCondition(root))
  205. {
  206. if (PermanentsCondition(targetPermanents))
  207. {
  208. Cost -= 12;
  209. }
  210. }
  211. }
  212. return Cost;
  213. }
  214. bool PermanentsCondition(List<Permanent> targetPermanents)
  215. {
  216. if (targetPermanents == null)
  217. {
  218. return true;
  219. }
  220. else
  221. {
  222. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  223. {
  224. return true;
  225. }
  226. }
  227. return false;
  228. }
  229. bool CardSourceCondition(CardSource cardSource)
  230. {
  231. if (cardSource != null)
  232. {
  233. if (cardSource == card)
  234. {
  235. return true;
  236. }
  237. }
  238. return false;
  239. }
  240. bool RootCondition(SelectCardEffect.Root root)
  241. {
  242. return true;
  243. }
  244. bool isUpDown()
  245. {
  246. return true;
  247. }
  248. }
  249. if (timing == EffectTiming.None)
  250. {
  251. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  252. }
  253. if (timing == EffectTiming.None)
  254. {
  255. DisableEffectClass invalidationClass = new DisableEffectClass();
  256. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseCondition, card);
  257. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  258. cardEffects.Add(invalidationClass);
  259. bool CanUseCondition(Hashtable hashtable)
  260. {
  261. return true;
  262. }
  263. bool InvalidateCondition(ICardEffect cardEffect)
  264. {
  265. if (CardEffectCommons.IsExistOnBattleArea(card))
  266. {
  267. if (cardEffect != null)
  268. {
  269. if (cardEffect is ActivateICardEffect)
  270. {
  271. if (cardEffect.EffectSourceCard != null)
  272. {
  273. if (CardEffectCommons.IsExistOnBattleArea(cardEffect.EffectSourceCard))
  274. {
  275. if (cardEffect.EffectSourceCard.PermanentOfThisCard().Level == 7 && cardEffect.EffectSourceCard.HasLevel)
  276. {
  277. if (!cardEffect.EffectSourceCard.PermanentOfThisCard().TopCard.CanNotBeAffected(invalidationClass))
  278. {
  279. if (cardEffect.IsWhenDigivolving)
  280. {
  281. return true;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. return false;
  291. }
  292. }
  293. return cardEffects;
  294. }
  295. }