BT13_103.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_103 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete 1 Digimon to reduce Play Cost", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. activateClass.SetHashString("DeleteDigimon_BT13_103");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Your Turn] When a card with [Belphemon] in its name would be played, by deleting 1 of your Digimon with [Gizmon] in its name, reduce the play cost by the play cost of the deleted Digimon.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.TopCard.ContainsCardName("Gizmon"))
  28. {
  29. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  30. {
  31. if (permanent.CanBeDestroyedBySkill(activateClass))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CardCondition(CardSource cardSource)
  41. {
  42. return cardSource.ContainsCardName("Belphemon");
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  47. {
  48. if (CardEffectCommons.IsOwnerTurn(card))
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  67. {
  68. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  69. {
  70. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  71. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  72. selectPermanentEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectPermanentCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: maxCount,
  78. canNoSelect: true,
  79. canEndNotMax: false,
  80. selectPermanentCoroutine: SelectPermanentCoroutine,
  81. afterSelectPermanentCoroutine: null,
  82. mode: SelectPermanentEffect.Mode.Custom,
  83. cardEffect: activateClass);
  84. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  85. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  86. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  89. targetPermanents: new List<Permanent>() { permanent },
  90. activateClass: activateClass,
  91. successProcess: permanents => SuccessProcess(),
  92. failureProcess: null));
  93. IEnumerator SuccessProcess()
  94. {
  95. int reduceCost = permanent.CostJustBeforeRemoveField;
  96. if (reduceCost <= 0) yield break;
  97. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  98. ChangeCostClass changeCostClass = new ChangeCostClass();
  99. changeCostClass.SetUpICardEffect($"Play Cost -{reduceCost}", CanUseCondition1, card);
  100. changeCostClass.SetUpChangeCostClass(
  101. changeCostFunc: ChangeCost,
  102. cardSourceCondition: CardSourceCondition,
  103. rootCondition: RootCondition,
  104. isUpDown: isUpDown,
  105. isCheckAvailability: () => false,
  106. isChangePayingCost: () => true);
  107. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  108. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  109. bool CanUseCondition1(Hashtable hashtable)
  110. {
  111. return true;
  112. }
  113. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  114. {
  115. if (CardSourceCondition(cardSource))
  116. {
  117. if (RootCondition(root))
  118. {
  119. if (PermanentsCondition(targetPermanents))
  120. {
  121. Cost -= reduceCost;
  122. }
  123. }
  124. }
  125. return Cost;
  126. }
  127. bool PermanentsCondition(List<Permanent> targetPermanents)
  128. {
  129. if (targetPermanents == null)
  130. {
  131. return true;
  132. }
  133. else
  134. {
  135. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. bool CardSourceCondition(CardSource cardSource)
  143. {
  144. return cardSource != null;
  145. }
  146. bool RootCondition(SelectCardEffect.Root root)
  147. {
  148. return true;
  149. }
  150. bool isUpDown()
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. if (timing == EffectTiming.None)
  160. {
  161. ChangeCostClass changeCostClass = new ChangeCostClass();
  162. changeCostClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition, card);
  163. changeCostClass.SetUpChangeCostClass(
  164. changeCostFunc: ChangeCost,
  165. cardSourceCondition: CardSourceCondition,
  166. rootCondition: RootCondition,
  167. isUpDown: isUpDown,
  168. isCheckAvailability: () => true,
  169. isChangePayingCost: () => true);
  170. changeCostClass.SetNotShowUI(true);
  171. cardEffects.Add(changeCostClass);
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. if (!card.Owner.isYou && GManager.instance.IsAI)
  175. {
  176. return false;
  177. }
  178. if (CardEffectCommons.IsExistOnBattleArea(card))
  179. {
  180. if (CardEffectCommons.IsOwnerTurn(card))
  181. {
  182. return true;
  183. }
  184. }
  185. return false;
  186. }
  187. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  188. {
  189. if (CardSourceCondition(cardSource))
  190. {
  191. if (RootCondition(root))
  192. {
  193. if (PermanentsCondition(targetPermanents))
  194. {
  195. int reduceCost = 0;
  196. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.HashString == "DeleteDigimon_BT13_103");
  197. bool CanSelectPermanentCondition(Permanent permanent)
  198. {
  199. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  200. {
  201. if (permanent.TopCard.ContainsCardName("Gizmon"))
  202. {
  203. if (permanent.CanBeDestroyedBySkill(activateClass))
  204. {
  205. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  206. {
  207. if (permanent.TopCard.HasPlayCost)
  208. {
  209. if (permanent.TopCard.GetCostItself >= 1)
  210. {
  211. return true;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. return false;
  219. }
  220. List<int> gizmonCosts = card.Owner.GetBattleAreaDigimons()
  221. .Filter(CanSelectPermanentCondition)
  222. .Map(permanent => permanent.TopCard.GetCostItself);
  223. if (gizmonCosts.Count >= 1)
  224. {
  225. reduceCost = gizmonCosts.Max();
  226. }
  227. Cost -= reduceCost;
  228. }
  229. }
  230. }
  231. return Cost;
  232. }
  233. bool PermanentsCondition(List<Permanent> targetPermanents)
  234. {
  235. if (targetPermanents == null)
  236. {
  237. return true;
  238. }
  239. else
  240. {
  241. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  242. {
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248. bool CardSourceCondition(CardSource cardSource)
  249. {
  250. return cardSource.ContainsCardName("Belphemon");
  251. }
  252. bool RootCondition(SelectCardEffect.Root root)
  253. {
  254. return true;
  255. }
  256. bool isUpDown()
  257. {
  258. return true;
  259. }
  260. }
  261. if (timing == EffectTiming.OnEndTurn)
  262. {
  263. ActivateClass activateClass = new ActivateClass();
  264. activateClass.SetUpICardEffect("Draw 1, trash 1 card from hand and Delete Digimon", CanUseCondition, card);
  265. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  266. activateClass.SetHashString("Draw1_BT13_103");
  267. cardEffects.Add(activateClass);
  268. string EffectDiscription()
  269. {
  270. return "[End of Opponent's Turn][Once Per Turn] <Draw 1> and trash 1 card in your hand. Then, by placing this Tamer as the bottom digivolution card of 1 of your Digimon with [Belphemon] in its name, delete 1 of your opponent's level 6 Digimon.";
  271. }
  272. bool CanSelectPermanentCondition(Permanent permanent)
  273. {
  274. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  275. {
  276. if (permanent != card.PermanentOfThisCard())
  277. {
  278. if (permanent.TopCard.ContainsCardName("Belphemon"))
  279. {
  280. if (!permanent.IsToken)
  281. {
  282. return true;
  283. }
  284. }
  285. }
  286. }
  287. return false;
  288. }
  289. bool CanSelectPermanentCondition1(Permanent permanent)
  290. {
  291. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  292. {
  293. if (permanent.Level == 6)
  294. {
  295. if (permanent.TopCard.HasLevel)
  296. {
  297. return true;
  298. }
  299. }
  300. }
  301. return false;
  302. }
  303. bool CanUseCondition(Hashtable hashtable)
  304. {
  305. if (CardEffectCommons.IsExistOnBattleArea(card))
  306. {
  307. if (CardEffectCommons.IsOpponentTurn(card))
  308. {
  309. return true;
  310. }
  311. }
  312. return false;
  313. }
  314. bool CanActivateCondition(Hashtable hashtable)
  315. {
  316. if (CardEffectCommons.IsExistOnBattleArea(card))
  317. {
  318. return true;
  319. }
  320. return false;
  321. }
  322. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  323. {
  324. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  325. if (card.Owner.HandCards.Count >= 1)
  326. {
  327. int discardCount = 1;
  328. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  329. selectHandEffect.SetUp(
  330. selectPlayer: card.Owner,
  331. canTargetCondition: (cardSource) => true,
  332. canTargetCondition_ByPreSelecetedList: null,
  333. canEndSelectCondition: null,
  334. maxCount: discardCount,
  335. canNoSelect: false,
  336. canEndNotMax: false,
  337. isShowOpponent: true,
  338. selectCardCoroutine: null,
  339. afterSelectCardCoroutine: null,
  340. mode: SelectHandEffect.Mode.Discard,
  341. cardEffect: activateClass);
  342. yield return StartCoroutine(selectHandEffect.Activate());
  343. }
  344. bool digivolutionCardAdded = false;
  345. if (CardEffectCommons.IsExistOnBattleArea(card))
  346. {
  347. if (!card.PermanentOfThisCard().IsToken)
  348. {
  349. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  350. {
  351. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  352. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  353. selectPermanentEffect.SetUp(
  354. selectPlayer: card.Owner,
  355. canTargetCondition: CanSelectPermanentCondition,
  356. canTargetCondition_ByPreSelecetedList: null,
  357. canEndSelectCondition: null,
  358. maxCount: maxCount,
  359. canNoSelect: true,
  360. canEndNotMax: false,
  361. selectPermanentCoroutine: SelectPermanentCoroutine,
  362. afterSelectPermanentCoroutine: null,
  363. mode: SelectPermanentEffect.Mode.Custom,
  364. cardEffect: activateClass);
  365. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get digivolution cards.", "The opponent is selecting 1 Digimon that will get digivolution cards.");
  366. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  367. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  368. {
  369. Permanent oldThisCardPermanent = card.PermanentOfThisCard();
  370. CardSource topCard = oldThisCardPermanent.TopCard;
  371. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { oldThisCardPermanent, permanent } }, false, activateClass).PlacePermanentToDigivolutionCards());
  372. if (oldThisCardPermanent.TopCard == null && CardEffectCommons.IsExistOnBattleArea(card))
  373. {
  374. if (permanent.DigivolutionCards.Contains(topCard))
  375. {
  376. digivolutionCardAdded = true;
  377. }
  378. }
  379. }
  380. }
  381. }
  382. }
  383. if (digivolutionCardAdded)
  384. {
  385. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  386. {
  387. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  388. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  389. selectPermanentEffect.SetUp(
  390. selectPlayer: card.Owner,
  391. canTargetCondition: CanSelectPermanentCondition1,
  392. canTargetCondition_ByPreSelecetedList: null,
  393. canEndSelectCondition: null,
  394. maxCount: maxCount,
  395. canNoSelect: false,
  396. canEndNotMax: false,
  397. selectPermanentCoroutine: null,
  398. afterSelectPermanentCoroutine: null,
  399. mode: SelectPermanentEffect.Mode.Destroy,
  400. cardEffect: activateClass);
  401. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  402. }
  403. }
  404. }
  405. }
  406. if (timing == EffectTiming.SecuritySkill)
  407. {
  408. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  409. }
  410. return cardEffects;
  411. }
  412. }
  413. }