BT21_093.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //Raging Serpentine
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_093 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Reduce Play Cost
  14. if (timing == EffectTiming.BeforePayCost)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Reduce Play Cost -4", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  19. activateClass.SetHashString("PlayCost-4_BT21_093");
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "When this card would be used, if your opponent has 3 or fewer security cards, reduce the use cost by ";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card))
  28. return (card.Owner.Enemy.SecurityCards.Count <= 3);
  29. return false;
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  32. {
  33. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  34. {
  35. if (card.Owner.CanReduceCost(null, card))
  36. {
  37. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  38. }
  39. ChangeCostClass changeCostClass = new ChangeCostClass();
  40. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  41. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  42. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  43. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  44. bool CanUseCondition1(Hashtable hashtable)
  45. {
  46. return true;
  47. }
  48. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  49. {
  50. if (CardSourceCondition(cardSource))
  51. {
  52. if (RootCondition(root))
  53. {
  54. if (PermanentsCondition(targetPermanents))
  55. {
  56. Cost -= 4;
  57. }
  58. }
  59. }
  60. return Cost;
  61. }
  62. bool PermanentsCondition(List<Permanent> targetPermanents)
  63. {
  64. if (targetPermanents == null)
  65. {
  66. return true;
  67. }
  68. else
  69. {
  70. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. bool CardSourceCondition(CardSource cardSource)
  78. {
  79. if (cardSource != null)
  80. {
  81. if (cardSource == card)
  82. {
  83. return true;
  84. }
  85. }
  86. return false;
  87. }
  88. bool RootCondition(SelectCardEffect.Root root)
  89. {
  90. return true;
  91. }
  92. bool isUpDown()
  93. {
  94. return true;
  95. }
  96. yield return null;
  97. }
  98. }
  99. }
  100. if (timing == EffectTiming.None)
  101. {
  102. ChangeCostClass changeCostClass = new ChangeCostClass();
  103. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition, card);
  104. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  105. changeCostClass.SetNotShowUI(true);
  106. cardEffects.Add(changeCostClass);
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. if (CardEffectCommons.IsExistOnHand(card))
  110. {
  111. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  119. {
  120. if (CardSourceCondition(cardSource))
  121. {
  122. if (RootCondition(root))
  123. {
  124. Cost -= 4;
  125. }
  126. }
  127. return Cost;
  128. }
  129. bool CardSourceCondition(CardSource cardSource)
  130. {
  131. if (cardSource != null)
  132. {
  133. if (cardSource == card)
  134. {
  135. return true;
  136. }
  137. }
  138. return false;
  139. }
  140. bool RootCondition(SelectCardEffect.Root root)
  141. {
  142. return true;
  143. }
  144. bool isUpDown()
  145. {
  146. return true;
  147. }
  148. }
  149. #endregion
  150. #region Shared Main/Security Effect
  151. bool SelectPermanentCondition(Permanent permanent)
  152. {
  153. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  154. {
  155. if (CardEffectCommons.IsMaxDP(permanent, card.Owner.Enemy, null))
  156. {
  157. return true;
  158. }
  159. }
  160. return false;
  161. }
  162. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  163. {
  164. if (CardEffectCommons.HasMatchConditionPermanent(SelectPermanentCondition))
  165. {
  166. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SelectPermanentCondition));
  167. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  168. selectPermanentEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: SelectPermanentCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: maxCount,
  174. canNoSelect: false,
  175. canEndNotMax: false,
  176. selectPermanentCoroutine: null,
  177. afterSelectPermanentCoroutine: null,
  178. mode: SelectPermanentEffect.Mode.Destroy,
  179. cardEffect: activateClass);
  180. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete", "The opponent is selecting 1 Digimon to delete");
  181. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  182. }
  183. }
  184. #endregion
  185. #region Main
  186. if (timing == EffectTiming.OptionSkill)
  187. {
  188. ActivateClass activateClass = new ActivateClass();
  189. activateClass.SetUpICardEffect("Delete 1 of your opponent's Digimon with the highest DP", CanUseCondition, card);
  190. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  191. cardEffects.Add(activateClass);
  192. string EffectDiscription()
  193. {
  194. return "[Main] Delete 1 of your opponent's highest DP Digimon. Then, place this card in the battle area.";
  195. }
  196. bool CanUseCondition(Hashtable hashtable)
  197. {
  198. if (CardEffectCommons.CanTriggerSecurityEffect(hashtable, card))
  199. {
  200. return true;
  201. }
  202. return false;
  203. }
  204. IEnumerator ActivateCoroutine(Hashtable hashtable)
  205. {
  206. yield return SharedActivateCoroutine(hashtable, activateClass);
  207. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  208. }
  209. }
  210. #endregion
  211. #region All Turns - Delay
  212. if (timing == EffectTiming.OnLoseSecurity)
  213. {
  214. ActivateClass activateClass = new ActivateClass();
  215. activateClass.SetUpICardEffect("1 of your [Reptile]/[Dragonkin] trait Digimon may digivolve", CanUseCondition, card);
  216. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  217. cardEffects.Add(activateClass);
  218. string EffectDiscription()
  219. {
  220. return "[All Turns] When your opponent's security stack is removed from, <Delay> (After this card is placed, by trashing it the next turn or later, activate the effect below).\r\n・1 of your [Reptile]/[Dragonkin] trait Digimon may digivolve into a [Reptile]/[Dragonkin] trait Digimon card in the hand without paying the cost.\r\n";
  221. }
  222. bool CanUseCondition(Hashtable hashtable)
  223. {
  224. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner.Enemy))
  225. {
  226. if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
  227. {
  228. return true;
  229. }
  230. }
  231. return false;
  232. }
  233. bool CanActivateCondition(Hashtable hashtable)
  234. {
  235. if (CardEffectCommons.IsExistOnBattleArea(card))
  236. {
  237. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent))
  238. {
  239. return true;
  240. }
  241. }
  242. return false;
  243. }
  244. bool CanSelectPermanent(Permanent permanent)
  245. {
  246. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  247. {
  248. if (permanent.TopCard.EqualsTraits("Reptile") || permanent.TopCard.EqualsTraits("Dragonkin"))
  249. {
  250. foreach (CardSource cardSource in card.Owner.HandCards)
  251. {
  252. if (CanSelectCardCondition(cardSource))
  253. {
  254. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  255. {
  256. return true;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. return false;
  263. }
  264. bool CanSelectCardCondition(CardSource cardSource)
  265. {
  266. return cardSource.EqualsTraits("Reptile") || cardSource.EqualsTraits("Dragonkin");
  267. }
  268. IEnumerator ActivateCoroutine(Hashtable hashtable)
  269. {
  270. bool delaySuccessful = false;
  271. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  272. IEnumerator SuccessProcess()
  273. {
  274. delaySuccessful = true;
  275. yield return null;
  276. }
  277. if (delaySuccessful)
  278. {
  279. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent))
  280. {
  281. Permanent selectedDigimon = null;
  282. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent));
  283. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  284. selectPermanentEffect.SetUp(
  285. selectPlayer: card.Owner,
  286. canTargetCondition: CanSelectPermanent,
  287. canTargetCondition_ByPreSelecetedList: null,
  288. canEndSelectCondition: null,
  289. maxCount: maxCount,
  290. canNoSelect: true,
  291. canEndNotMax: false,
  292. selectPermanentCoroutine: SelectPermanentCoroutine,
  293. afterSelectPermanentCoroutine: null,
  294. mode: SelectPermanentEffect.Mode.Custom,
  295. cardEffect: activateClass);
  296. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve", "The opponent is selecting 1 Digimon to digivolve");
  297. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  298. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  299. {
  300. selectedDigimon = permanent;
  301. yield return null;
  302. }
  303. if (selectedDigimon != null)
  304. {
  305. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  306. targetPermanent: selectedDigimon,
  307. cardCondition: CanSelectCardCondition,
  308. payCost: false,
  309. reduceCostTuple: null,
  310. fixedCostTuple: null,
  311. ignoreDigivolutionRequirementFixedCost: -1,
  312. isHand: true,
  313. activateClass: activateClass,
  314. successProcess: null));
  315. }
  316. }
  317. }
  318. }
  319. }
  320. #endregion
  321. #region Security
  322. if (timing == EffectTiming.SecuritySkill)
  323. {
  324. ActivateClass activateClass = new ActivateClass();
  325. activateClass.SetUpICardEffect("Delete 1 of your opponent's Digimon with the highest DP", CanUseCondition, card);
  326. activateClass.SetUpActivateClass(null, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  327. activateClass.SetIsSecurityEffect(true);
  328. cardEffects.Add(activateClass);
  329. string EffectDiscription()
  330. {
  331. return "[Security] Delete 1 of your opponent's Digimon with the highest DP.";
  332. }
  333. bool CanUseCondition(Hashtable hashtable)
  334. {
  335. if (CardEffectCommons.CanTriggerSecurityEffect(hashtable, card))
  336. {
  337. return true;
  338. }
  339. return false;
  340. }
  341. }
  342. #endregion
  343. return cardEffects;
  344. }
  345. }
  346. }