BT8_043.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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 BT8_043 : 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 purple [Cherubimon] and Play Cost -8", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. activateClass.SetHashString("PlayCost-8_BT8_043");
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "When you would play this card from your hand, you may delete 1 of your purple [Cherubimon] to reduce this card's play cost by 8.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  27. {
  28. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  29. {
  30. if (permanent.TopCard.CardNames.Contains("Cherubimon"))
  31. {
  32. if (permanent.CanSelectBySkill(activateClass))
  33. {
  34. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  35. {
  36. if (permanent.CanBeDestroyedBySkill(activateClass))
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. bool CardCondition(CardSource cardSource)
  48. {
  49. if (cardSource == card)
  50. {
  51. if (CardEffectCommons.IsExistOnHand(cardSource))
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  61. {
  62. return true;
  63. }
  64. return false;
  65. }
  66. bool CanActivateCondition(Hashtable hashtable)
  67. {
  68. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  69. {
  70. return true;
  71. }
  72. return false;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  77. {
  78. bool CanNoSelect = true;
  79. CardSource Card = CardEffectCommons.GetCardFromHashtable(_hashtable);
  80. if (Card != null)
  81. {
  82. if (Card.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > Card.Owner.MaxMemoryCost)
  83. {
  84. CanNoSelect = false;
  85. }
  86. }
  87. int maxCount = 1;
  88. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  89. selectPermanentEffect.SetUp(
  90. selectPlayer: card.Owner,
  91. canTargetCondition: CanSelectPermanentCondition,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. maxCount: maxCount,
  95. canNoSelect: CanNoSelect,
  96. canEndNotMax: false,
  97. selectPermanentCoroutine: SelectPermanentCoroutine,
  98. afterSelectPermanentCoroutine: null,
  99. mode: SelectPermanentEffect.Mode.Custom,
  100. cardEffect: activateClass);
  101. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  102. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  103. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  104. {
  105. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  106. IEnumerator SuccessProcess()
  107. {
  108. if (card.Owner.CanReduceCost(null, card))
  109. {
  110. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  111. }
  112. ChangeCostClass changeCostClass = new ChangeCostClass();
  113. changeCostClass.SetUpICardEffect("Play Cost -8", CanUseCondition1, card);
  114. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  115. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  117. bool CanUseCondition1(Hashtable hashtable)
  118. {
  119. return true;
  120. }
  121. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  122. {
  123. if (CardSourceCondition(cardSource))
  124. {
  125. if (RootCondition(root))
  126. {
  127. if (PermanentsCondition(targetPermanents))
  128. {
  129. Cost -= 8;
  130. }
  131. }
  132. }
  133. return Cost;
  134. }
  135. bool PermanentsCondition(List<Permanent> targetPermanents)
  136. {
  137. if (targetPermanents == null)
  138. {
  139. return true;
  140. }
  141. else
  142. {
  143. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. bool CardSourceCondition(CardSource cardSource)
  151. {
  152. return cardSource == card;
  153. }
  154. bool RootCondition(SelectCardEffect.Root root)
  155. {
  156. return true;
  157. }
  158. bool isUpDown()
  159. {
  160. return true;
  161. }
  162. yield return null;
  163. }
  164. }
  165. }
  166. }
  167. }
  168. if (timing == EffectTiming.None)
  169. {
  170. ChangeCostClass changeCostClass = new ChangeCostClass();
  171. changeCostClass.SetUpICardEffect("Play Cost -8", CanUseCondition, card);
  172. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  173. changeCostClass.SetNotShowUI(true);
  174. cardEffects.Add(changeCostClass);
  175. bool CanSelectPermanentCondition(Permanent permanent, ICardEffect activateClass)
  176. {
  177. if (permanent != null)
  178. {
  179. if (permanent.TopCard != null)
  180. {
  181. if (permanent.TopCard.Owner == card.Owner)
  182. {
  183. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  184. {
  185. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  186. {
  187. if (permanent.TopCard.CardNames.Contains("Cherubimon"))
  188. {
  189. if (activateClass != null)
  190. {
  191. if (permanent.CanSelectBySkill(activateClass))
  192. {
  193. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  194. {
  195. if (permanent.CanBeDestroyedBySkill(activateClass))
  196. {
  197. return true;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. }
  208. return false;
  209. }
  210. bool CanUseCondition(Hashtable hashtable)
  211. {
  212. if (card.Owner.HandCards.Contains(card))
  213. {
  214. ICardEffect activateClass = null;
  215. if (card.EffectList(EffectTiming.BeforePayCost).Count >= 1)
  216. {
  217. foreach (ICardEffect cardEffect in card.EffectList(EffectTiming.BeforePayCost))
  218. {
  219. if (cardEffect.EffectName == "Delete 1 purple [Cherubimon] and Play Cost -8")
  220. {
  221. activateClass = cardEffect;
  222. break;
  223. }
  224. }
  225. }
  226. if (activateClass != null)
  227. {
  228. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count((permanent) => CanSelectPermanentCondition(permanent, activateClass)) >= 1) >= 1)
  229. {
  230. return true;
  231. }
  232. }
  233. }
  234. return false;
  235. }
  236. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  237. {
  238. if (CardSourceCondition(cardSource))
  239. {
  240. if (RootCondition(root))
  241. {
  242. if (PermanentsCondition(targetPermanents))
  243. {
  244. Cost -= 8;
  245. }
  246. }
  247. }
  248. return Cost;
  249. }
  250. bool PermanentsCondition(List<Permanent> targetPermanents)
  251. {
  252. if (targetPermanents == null)
  253. {
  254. return true;
  255. }
  256. else
  257. {
  258. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  259. {
  260. return true;
  261. }
  262. }
  263. return false;
  264. }
  265. bool CardSourceCondition(CardSource cardSource)
  266. {
  267. if (cardSource != null)
  268. {
  269. if (cardSource == card)
  270. {
  271. return true;
  272. }
  273. }
  274. return false;
  275. }
  276. bool RootCondition(SelectCardEffect.Root root)
  277. {
  278. return true;
  279. }
  280. bool isUpDown()
  281. {
  282. return true;
  283. }
  284. }
  285. if (timing == EffectTiming.OnEnterFieldAnyone)
  286. {
  287. ActivateClass activateClass = new ActivateClass();
  288. activateClass.SetUpICardEffect("Security Attack -2 for each your Tamer", CanUseCondition, card);
  289. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  290. cardEffects.Add(activateClass);
  291. string EffectDiscription()
  292. {
  293. return "[On Play] For each Tamer you have in play, activate the effect below. - 1 of your opponent's Digimon gets <Security Attack -2> until the end of your opponent's next turn. (This Digimon checks 2 fewer security cards.)";
  294. }
  295. bool CanSelectPermanentCondition(Permanent permanent)
  296. {
  297. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  298. }
  299. bool CanUseCondition(Hashtable hashtable)
  300. {
  301. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  302. }
  303. bool CanActivateCondition(Hashtable hashtable)
  304. {
  305. if (CardEffectCommons.IsExistOnBattleArea(card))
  306. {
  307. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  308. {
  309. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  310. {
  311. return true;
  312. }
  313. }
  314. }
  315. return false;
  316. }
  317. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  318. {
  319. int tamerCount = card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  320. if (tamerCount >= 1)
  321. {
  322. for (int i = 0; i < tamerCount; i++)
  323. {
  324. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  325. {
  326. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  327. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  328. selectPermanentEffect.SetUp(
  329. selectPlayer: card.Owner,
  330. canTargetCondition: CanSelectPermanentCondition,
  331. canTargetCondition_ByPreSelecetedList: null,
  332. canEndSelectCondition: null,
  333. maxCount: maxCount,
  334. canNoSelect: false,
  335. canEndNotMax: false,
  336. selectPermanentCoroutine: SelectPermanentCoroutine,
  337. afterSelectPermanentCoroutine: null,
  338. mode: SelectPermanentEffect.Mode.Custom,
  339. cardEffect: activateClass);
  340. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack -2.", "The opponent is selecting 1 Digimon that will get Security Attack -2.");
  341. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  342. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  343. {
  344. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -2, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. if (timing == EffectTiming.OnEnterFieldAnyone)
  352. {
  353. ActivateClass activateClass = new ActivateClass();
  354. activateClass.SetUpICardEffect("Security Attack -2 for each your Tamer", CanUseCondition, card);
  355. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  356. cardEffects.Add(activateClass);
  357. string EffectDiscription()
  358. {
  359. return "[When Digivolving] For each Tamer you have in play, activate the effect below. - 1 of your opponent's Digimon gets <Security Attack -2> until the end of your opponent's next turn. (This Digimon checks 2 fewer security cards.)";
  360. }
  361. bool CanSelectPermanentCondition(Permanent permanent)
  362. {
  363. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  364. }
  365. bool CanUseCondition(Hashtable hashtable)
  366. {
  367. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  368. }
  369. bool CanActivateCondition(Hashtable hashtable)
  370. {
  371. if (CardEffectCommons.IsExistOnBattleArea(card))
  372. {
  373. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  374. {
  375. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  376. {
  377. return true;
  378. }
  379. }
  380. }
  381. return false;
  382. }
  383. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  384. {
  385. int tamerCount = card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  386. if (tamerCount >= 1)
  387. {
  388. for (int i = 0; i < tamerCount; i++)
  389. {
  390. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  391. {
  392. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  393. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  394. selectPermanentEffect.SetUp(
  395. selectPlayer: card.Owner,
  396. canTargetCondition: CanSelectPermanentCondition,
  397. canTargetCondition_ByPreSelecetedList: null,
  398. canEndSelectCondition: null,
  399. maxCount: maxCount,
  400. canNoSelect: false,
  401. canEndNotMax: false,
  402. selectPermanentCoroutine: SelectPermanentCoroutine,
  403. afterSelectPermanentCoroutine: null,
  404. mode: SelectPermanentEffect.Mode.Custom,
  405. cardEffect: activateClass);
  406. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack -2.", "The opponent is selecting 1 Digimon that will get Security Attack -2.");
  407. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  408. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  409. {
  410. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -2, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  411. }
  412. }
  413. }
  414. }
  415. }
  416. }
  417. return cardEffects;
  418. }
  419. }