BT12_091.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_091 : 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.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Place 1 card under this Tamer from hand to reduce opponent's Digimon's DP by 2000", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Start of Your Main Phase] By placing 1 Digimon card with <Save> in its text from your hand under this Tamer, 1 of your opponent's Digimon gets -2000 DP for the turn.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource != null)
  25. {
  26. if (cardSource.Owner == card.Owner)
  27. {
  28. if (cardSource.IsDigimon)
  29. {
  30. if (cardSource.HasSaveText)
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanSelectPermanentCondition(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.IsOwnerTurn(card))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (isExistOnField(card))
  57. {
  58. if (card.Owner.GetBattleAreaPermanents().Contains(card.PermanentOfThisCard()))
  59. {
  60. if (card.Owner.HandCards.Count >= 1)
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. return false;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. if (isExistOnField(card))
  71. {
  72. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  73. {
  74. bool placed = false;
  75. int maxCount = 1;
  76. List<CardSource> selectedCards = new List<CardSource>();
  77. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  78. selectHandEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectCardCondition,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: CanEndSelectCondition,
  83. maxCount: maxCount,
  84. canNoSelect: true,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. selectCardCoroutine: SelectCardCoroutine,
  88. afterSelectCardCoroutine: null,
  89. mode: SelectHandEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. selectHandEffect.SetUpCustomMessage("Select 1 card to place in Digivolution cards.", "The opponent is selecting 1 card to place in Digivolution cards.");
  92. selectHandEffect.SetNotShowCard();
  93. yield return StartCoroutine(selectHandEffect.Activate());
  94. bool CanEndSelectCondition(List<CardSource> cardSources)
  95. {
  96. if (maxCount >= 1)
  97. {
  98. if (cardSources.Count <= 0)
  99. {
  100. return false;
  101. }
  102. }
  103. return true;
  104. }
  105. IEnumerator SelectCardCoroutine(CardSource cardSource)
  106. {
  107. selectedCards.Add(cardSource);
  108. yield return null;
  109. }
  110. if (selectedCards.Count >= 1)
  111. {
  112. if (!card.PermanentOfThisCard().IsToken)
  113. {
  114. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  115. placed = true;
  116. }
  117. }
  118. if (placed)
  119. {
  120. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  121. {
  122. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  123. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  124. selectPermanentEffect.SetUp(
  125. selectPlayer: card.Owner,
  126. canTargetCondition: CanSelectPermanentCondition,
  127. canTargetCondition_ByPreSelecetedList: null,
  128. canEndSelectCondition: null,
  129. maxCount: maxCount,
  130. canNoSelect: false,
  131. canEndNotMax: false,
  132. selectPermanentCoroutine: SelectPermanentCoroutine,
  133. afterSelectPermanentCoroutine: null,
  134. mode: SelectPermanentEffect.Mode.Custom,
  135. cardEffect: activateClass);
  136. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -2000.", "The opponent is selecting 1 Digimon that will get DP -2000.");
  137. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  138. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  139. {
  140. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  141. }
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. if (timing == EffectTiming.BeforePayCost)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  153. activateClass.SetHashString("DigivolutionCost-1_BT12_091");
  154. cardEffects.Add(activateClass);
  155. string EffectDiscription()
  156. {
  157. return "[Your Turn] If one of your Digimon digivolves into a Digimon card with <Save> in its text, by suspending this Tamer and placing 1 card from under one of your Tamers under that Digimon as one of its digivolution cards, reduce the digivolution cost by 1.";
  158. }
  159. bool CanSelectCardCondition(CardSource cardSource)
  160. {
  161. return true;
  162. }
  163. bool CanSelectPermanentCondition(Permanent permanent)
  164. {
  165. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  166. {
  167. if (permanent.IsTamer)
  168. {
  169. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  170. {
  171. return true;
  172. }
  173. }
  174. }
  175. return false;
  176. }
  177. bool PermanentCondition(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  180. }
  181. bool CardCondition(CardSource cardSource)
  182. {
  183. if (cardSource.IsDigimon)
  184. {
  185. if (cardSource.HasSaveText)
  186. {
  187. return true;
  188. }
  189. }
  190. return false;
  191. }
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. if (CardEffectCommons.IsExistOnBattleArea(card))
  195. {
  196. if (CardEffectCommons.IsOwnerTurn(card))
  197. {
  198. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  199. {
  200. return true;
  201. }
  202. }
  203. }
  204. return false;
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. if (CardEffectCommons.IsExistOnBattleArea(card))
  209. {
  210. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  211. {
  212. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  213. {
  214. return true;
  215. }
  216. }
  217. }
  218. return false;
  219. }
  220. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  221. {
  222. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  223. {
  224. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  225. Permanent giveDigivolutionCardsTamer = null;
  226. List<CardSource> selectedDigivolutionCards = new List<CardSource>();
  227. Permanent getDigivolutionCardsDigimon = null;
  228. int maxCount = 1;
  229. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  230. selectPermanentEffect.SetUp(
  231. selectPlayer: card.Owner,
  232. canTargetCondition: CanSelectPermanentCondition,
  233. canTargetCondition_ByPreSelecetedList: null,
  234. canEndSelectCondition: null,
  235. maxCount: maxCount,
  236. canNoSelect: false,
  237. canEndNotMax: false,
  238. selectPermanentCoroutine: SelectPermanentCoroutine,
  239. afterSelectPermanentCoroutine: null,
  240. mode: SelectPermanentEffect.Mode.Custom,
  241. cardEffect: activateClass);
  242. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer that has digivolution cards.", "The opponent is selecting 1 Tamer that has digivolution cards.");
  243. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  244. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  245. {
  246. giveDigivolutionCardsTamer = permanent;
  247. yield return null;
  248. }
  249. if (giveDigivolutionCardsTamer != null)
  250. {
  251. if (giveDigivolutionCardsTamer.DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  252. {
  253. maxCount = 1;
  254. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  255. selectCardEffect.SetUp(
  256. canTargetCondition: CanSelectCardCondition,
  257. canTargetCondition_ByPreSelecetedList: null,
  258. canEndSelectCondition: null,
  259. canNoSelect: () => false,
  260. selectCardCoroutine: SelectCardCoroutine,
  261. afterSelectCardCoroutine: null,
  262. message: "Select 1 digivolution card.",
  263. maxCount: maxCount,
  264. canEndNotMax: false,
  265. isShowOpponent: true,
  266. mode: SelectCardEffect.Mode.Custom,
  267. root: SelectCardEffect.Root.Custom,
  268. customRootCardList: giveDigivolutionCardsTamer.DigivolutionCards,
  269. canLookReverseCard: true,
  270. selectPlayer: card.Owner,
  271. cardEffect: activateClass);
  272. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card.", "The opponent is selecting 1 digivolution card.");
  273. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  274. yield return StartCoroutine(selectCardEffect.Activate());
  275. IEnumerator SelectCardCoroutine(CardSource cardSource)
  276. {
  277. selectedDigivolutionCards.Add(cardSource);
  278. yield return null;
  279. }
  280. bool CanSelectPermanentCondition1(Permanent permanent)
  281. {
  282. List<Permanent> Permanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable);
  283. if (Permanents != null)
  284. {
  285. if (Permanents.Contains(permanent))
  286. {
  287. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  288. {
  289. if (!permanent.IsToken)
  290. {
  291. return true;
  292. }
  293. }
  294. }
  295. }
  296. return false;
  297. }
  298. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  299. {
  300. maxCount = 1;
  301. selectPermanentEffect.SetUp(
  302. selectPlayer: card.Owner,
  303. canTargetCondition: CanSelectPermanentCondition1,
  304. canTargetCondition_ByPreSelecetedList: null,
  305. canEndSelectCondition: null,
  306. maxCount: maxCount,
  307. canNoSelect: false,
  308. canEndNotMax: false,
  309. selectPermanentCoroutine: SelectPermanentCoroutine1,
  310. afterSelectPermanentCoroutine: null,
  311. mode: SelectPermanentEffect.Mode.Custom,
  312. cardEffect: activateClass);
  313. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get digivolution cards.", "The opponent is selecting 1 Digimon that will get digivolution cards.");
  314. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  315. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  316. {
  317. getDigivolutionCardsDigimon = permanent;
  318. yield return null;
  319. }
  320. }
  321. if (getDigivolutionCardsDigimon != null)
  322. {
  323. if (selectedDigivolutionCards.Count >= 1)
  324. {
  325. foreach (CardSource selectedCard in selectedDigivolutionCards)
  326. {
  327. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(selectedCard, giveDigivolutionCardsTamer));
  328. }
  329. yield return ContinuousController.instance.StartCoroutine(getDigivolutionCardsDigimon.AddDigivolutionCardsBottom(selectedDigivolutionCards, activateClass));
  330. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  331. ChangeCostClass changeCostClass = new ChangeCostClass();
  332. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  333. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  334. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  335. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  336. bool CanUseCondition1(Hashtable hashtable)
  337. {
  338. return true;
  339. }
  340. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  341. {
  342. if (CardSourceCondition(cardSource))
  343. {
  344. if (RootCondition(root))
  345. {
  346. if (PermanentsCondition(targetPermanents))
  347. {
  348. Cost -= 1;
  349. }
  350. }
  351. }
  352. return Cost;
  353. }
  354. bool PermanentsCondition(List<Permanent> targetPermanents)
  355. {
  356. if (targetPermanents != null)
  357. {
  358. if (targetPermanents.Count(PermanentCondition) >= 1)
  359. {
  360. return true;
  361. }
  362. }
  363. return false;
  364. }
  365. bool PermanentCondition(Permanent targetPermanent)
  366. {
  367. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  368. }
  369. bool CardSourceCondition(CardSource cardSource)
  370. {
  371. return cardSource.HasSaveText;
  372. }
  373. bool RootCondition(SelectCardEffect.Root root)
  374. {
  375. return true;
  376. }
  377. bool isUpDown()
  378. {
  379. return true;
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. }
  388. if (timing == EffectTiming.SecuritySkill)
  389. {
  390. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  391. }
  392. return cardEffects;
  393. }
  394. }
  395. }