P_074.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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 P_074 : 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("Trash your Security to reduce digivolution cost", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. activateClass.SetHashString("TrashSecurity_P_074");
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Your Turn] When this Digimon would digivolve into a card with [Shaman] or [Wizard] in its traits, you may trash up to 3 of your security cards. For each security card trashed with this effect, reduce the digivolution cost by 1.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleArea(card))
  27. {
  28. if (CardEffectCommons.IsOwnerTurn(card))
  29. {
  30. bool CardCondition(CardSource cardSource)
  31. {
  32. return cardSource.CardTraits.Contains("Shaman") || cardSource.CardTraits.Contains("Wizard");
  33. }
  34. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolveOfCard(hashtable, CardCondition, card))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (card.Owner.SecurityCards.Count >= 1)
  47. {
  48. if (card.Owner.CanReduceSecurity())
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. int trashCount = 0;
  59. if (card.Owner.SecurityCards.Count >= 1 && card.Owner.CanReduceSecurity())
  60. {
  61. int maxCount = Math.Min(3, card.Owner.SecurityCards.Count);
  62. SelectCountEffect selectCountEffect = GManager.instance.GetComponent<SelectCountEffect>();
  63. selectCountEffect.SetUp(
  64. SelectPlayer: card.Owner,
  65. targetPermanent: null,
  66. MaxCount: maxCount,
  67. CanNoSelect: true,
  68. Message: "How many security cards will you trash?",
  69. Message_Enemy: "The opponent is choosing how many security cards to trash.",
  70. SelectCountCoroutine: SelectCountCoroutine);
  71. yield return ContinuousController.instance.StartCoroutine(selectCountEffect.Activate());
  72. IEnumerator SelectCountCoroutine(int count)
  73. {
  74. trashCount = count;
  75. yield return null;
  76. }
  77. }
  78. if (trashCount >= 1 && card.Owner.SecurityCards.Count >= 1)
  79. {
  80. int reduceCost = 0;
  81. if (card.Owner.SecurityCards.Count < trashCount)
  82. {
  83. trashCount = card.Owner.SecurityCards.Count;
  84. }
  85. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  86. player: card.Owner,
  87. destroySecurityCount: trashCount,
  88. cardEffect: activateClass,
  89. fromTop: true).DestroySecurity());
  90. reduceCost = trashCount;
  91. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  92. ChangeCostClass changeCostClass = new ChangeCostClass();
  93. changeCostClass.SetUpICardEffect($"Digivolution Cost -{reduceCost}", CanUseCondition1, card);
  94. changeCostClass.SetUpChangeCostClass(
  95. changeCostFunc: ChangeCost,
  96. cardSourceCondition: CardSourceCondition,
  97. rootCondition: RootCondition,
  98. isUpDown: isUpDown,
  99. isCheckAvailability: () => false,
  100. isChangePayingCost: () => true);
  101. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  102. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  103. bool CanUseCondition1(Hashtable hashtable)
  104. {
  105. return true;
  106. }
  107. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  108. {
  109. if (CardSourceCondition(cardSource))
  110. {
  111. if (RootCondition(root))
  112. {
  113. if (PermanentsCondition(targetPermanents))
  114. {
  115. Cost -= reduceCost;
  116. }
  117. }
  118. }
  119. return Cost;
  120. }
  121. bool PermanentsCondition(List<Permanent> targetPermanents)
  122. {
  123. if (targetPermanents != null)
  124. {
  125. if (targetPermanents.Count(PermanentCondition) >= 1)
  126. {
  127. return true;
  128. }
  129. }
  130. return false;
  131. }
  132. bool PermanentCondition(Permanent targetPermanent)
  133. {
  134. if (CardEffectCommons.IsExistOnBattleArea(card))
  135. {
  136. if (targetPermanent == card.PermanentOfThisCard())
  137. {
  138. return true;
  139. }
  140. }
  141. return false;
  142. }
  143. bool CardSourceCondition(CardSource cardSource)
  144. {
  145. if (cardSource.Owner == card.Owner)
  146. {
  147. return true;
  148. }
  149. return false;
  150. }
  151. bool RootCondition(SelectCardEffect.Root root)
  152. {
  153. return true;
  154. }
  155. bool isUpDown()
  156. {
  157. return true;
  158. }
  159. }
  160. }
  161. }
  162. if (timing == EffectTiming.None)
  163. {
  164. ChangeCostClass changeCostClass = new ChangeCostClass();
  165. changeCostClass.SetUpICardEffect($"Digivolution Cost -", CanUseCondition, card);
  166. changeCostClass.SetUpChangeCostClass(
  167. changeCostFunc: ChangeCost,
  168. cardSourceCondition: CardSourceCondition,
  169. rootCondition: RootCondition,
  170. isUpDown: isUpDown,
  171. isCheckAvailability: () => true,
  172. isChangePayingCost: () => true);
  173. changeCostClass.SetNotShowUI(true);
  174. cardEffects.Add(changeCostClass);
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.IsExistOnBattleArea(card))
  178. {
  179. if (CardEffectCommons.IsOwnerTurn(card))
  180. {
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  187. {
  188. if (CardSourceCondition(cardSource))
  189. {
  190. if (RootCondition(root))
  191. {
  192. if (PermanentsCondition(targetPermanents))
  193. {
  194. int reduceCost = 3;
  195. if (card.Owner.SecurityCards.Count < reduceCost)
  196. {
  197. reduceCost = card.Owner.SecurityCards.Count;
  198. }
  199. Cost -= reduceCost;
  200. }
  201. }
  202. }
  203. return Cost;
  204. }
  205. bool PermanentsCondition(List<Permanent> targetPermanents)
  206. {
  207. if (targetPermanents != null)
  208. {
  209. if (targetPermanents.Count(PermanentCondition) >= 1)
  210. {
  211. return true;
  212. }
  213. }
  214. return false;
  215. }
  216. bool PermanentCondition(Permanent targetPermanent)
  217. {
  218. if (CardEffectCommons.IsExistOnBattleArea(card))
  219. {
  220. if (targetPermanent == card.PermanentOfThisCard())
  221. {
  222. return true;
  223. }
  224. }
  225. return false;
  226. }
  227. bool CardSourceCondition(CardSource cardSource)
  228. {
  229. if (cardSource.CardTraits.Contains("Shaman"))
  230. {
  231. return true;
  232. }
  233. if (cardSource.CardTraits.Contains("Wizard"))
  234. {
  235. return true;
  236. }
  237. return false;
  238. }
  239. bool RootCondition(SelectCardEffect.Root root)
  240. {
  241. return true;
  242. }
  243. bool isUpDown()
  244. {
  245. return true;
  246. }
  247. }
  248. if (timing == EffectTiming.OnAllyAttack)
  249. {
  250. ActivateClass activateClass = new ActivateClass();
  251. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  252. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  253. activateClass.SetIsInheritedEffect(true);
  254. activateClass.SetHashString("Unsuspend_P_074");
  255. cardEffects.Add(activateClass);
  256. string EffectDiscription()
  257. {
  258. return "[When Attacking][Once Per Turn] If you have exactly 3 security cards, unsuspend this Digimon.";
  259. }
  260. bool CanUseCondition(Hashtable hashtable)
  261. {
  262. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  263. }
  264. bool CanActivateCondition(Hashtable hashtable)
  265. {
  266. if (CardEffectCommons.IsExistOnBattleArea(card))
  267. {
  268. if (card.Owner.SecurityCards.Count == 3)
  269. {
  270. return true;
  271. }
  272. }
  273. return false;
  274. }
  275. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  276. {
  277. Permanent selectedPermanent = card.PermanentOfThisCard();
  278. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  279. new List<Permanent>() { selectedPermanent },
  280. activateClass).Unsuspend());
  281. }
  282. }
  283. return cardEffects;
  284. }
  285. }