BT12_097.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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_097 : 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 trash", 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] If there are 2 or less cards under this Tamer, place 1 Digimon card with <Save> in its text from your trash under this Tamer.";
  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 CanUseCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. if (CardEffectCommons.IsOwnerTurn(card))
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. if (isExistOnField(card))
  53. {
  54. if (card.Owner.GetBattleAreaPermanents().Contains(card.PermanentOfThisCard()))
  55. {
  56. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  57. {
  58. if (card.PermanentOfThisCard().DigivolutionCards.Count <= 2)
  59. {
  60. return true;
  61. }
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. if (isExistOnField(card))
  70. {
  71. if (card.Owner.GetBattleAreaPermanents().Contains(card.PermanentOfThisCard()))
  72. {
  73. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  74. {
  75. if (card.PermanentOfThisCard().DigivolutionCards.Count <= 2)
  76. {
  77. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  78. List<CardSource> selectedCards = new List<CardSource>();
  79. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  80. selectCardEffect.SetUp(
  81. canTargetCondition: CanSelectCardCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. canNoSelect: () => true,
  85. selectCardCoroutine: SelectCardCoroutine,
  86. afterSelectCardCoroutine: null,
  87. message: "Select 1 card to place in Digivolution cards.",
  88. maxCount: maxCount,
  89. canEndNotMax: false,
  90. isShowOpponent: true,
  91. mode: SelectCardEffect.Mode.Custom,
  92. root: SelectCardEffect.Root.Trash,
  93. customRootCardList: null,
  94. canLookReverseCard: true,
  95. selectPlayer: card.Owner,
  96. cardEffect: activateClass);
  97. selectCardEffect.SetUpCustomMessage("Select 1 card to place in Digivolution cards.", "The opponent is selecting 1 card to place in Digivolution cards.");
  98. selectCardEffect.SetNotShowCard();
  99. yield return StartCoroutine(selectCardEffect.Activate());
  100. IEnumerator SelectCardCoroutine(CardSource cardSource)
  101. {
  102. selectedCards.Add(cardSource);
  103. yield return null;
  104. }
  105. if (selectedCards.Count >= 1)
  106. {
  107. if (!card.PermanentOfThisCard().IsToken)
  108. {
  109. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. if (timing == EffectTiming.BeforePayCost)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  123. activateClass.SetHashString("DigivolutionCost-1_BT12_097");
  124. cardEffects.Add(activateClass);
  125. string EffectDiscription()
  126. {
  127. 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.";
  128. }
  129. bool CanSelectCardCondition(CardSource cardSource)
  130. {
  131. return true;
  132. }
  133. bool CanSelectPermanentCondition(Permanent permanent)
  134. {
  135. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  136. {
  137. if (permanent.IsTamer)
  138. {
  139. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  140. {
  141. return true;
  142. }
  143. }
  144. }
  145. return false;
  146. }
  147. bool PermanentCondition(Permanent permanent)
  148. {
  149. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  150. }
  151. bool CardCondition(CardSource cardSource)
  152. {
  153. if (cardSource.IsDigimon)
  154. {
  155. if (cardSource.HasSaveText)
  156. {
  157. return true;
  158. }
  159. }
  160. return false;
  161. }
  162. bool CanUseCondition(Hashtable hashtable)
  163. {
  164. if (CardEffectCommons.IsExistOnBattleArea(card))
  165. {
  166. if (CardEffectCommons.IsOwnerTurn(card))
  167. {
  168. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  169. {
  170. return true;
  171. }
  172. }
  173. }
  174. return false;
  175. }
  176. bool CanActivateCondition(Hashtable hashtable)
  177. {
  178. if (CardEffectCommons.IsExistOnBattleArea(card))
  179. {
  180. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  181. {
  182. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  183. {
  184. return true;
  185. }
  186. }
  187. }
  188. return false;
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  191. {
  192. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  193. {
  194. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  195. Permanent giveDigivolutionCardsTamer = null;
  196. List<CardSource> selectedDigivolutionCards = new List<CardSource>();
  197. Permanent getDigivolutionCardsDigimon = null;
  198. int maxCount = 1;
  199. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  200. selectPermanentEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition: CanSelectPermanentCondition,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. maxCount: maxCount,
  206. canNoSelect: false,
  207. canEndNotMax: false,
  208. selectPermanentCoroutine: SelectPermanentCoroutine,
  209. afterSelectPermanentCoroutine: null,
  210. mode: SelectPermanentEffect.Mode.Custom,
  211. cardEffect: activateClass);
  212. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer that has digivolution cards.", "The opponent is selecting 1 Tamer that has digivolution cards.");
  213. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  214. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  215. {
  216. giveDigivolutionCardsTamer = permanent;
  217. yield return null;
  218. }
  219. if (giveDigivolutionCardsTamer != null)
  220. {
  221. if (giveDigivolutionCardsTamer.DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  222. {
  223. maxCount = 1;
  224. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  225. selectCardEffect.SetUp(
  226. canTargetCondition: CanSelectCardCondition,
  227. canTargetCondition_ByPreSelecetedList: null,
  228. canEndSelectCondition: null,
  229. canNoSelect: () => false,
  230. selectCardCoroutine: SelectCardCoroutine,
  231. afterSelectCardCoroutine: null,
  232. message: "Select 1 digivolution card.",
  233. maxCount: maxCount,
  234. canEndNotMax: false,
  235. isShowOpponent: true,
  236. mode: SelectCardEffect.Mode.Custom,
  237. root: SelectCardEffect.Root.Custom,
  238. customRootCardList: giveDigivolutionCardsTamer.DigivolutionCards,
  239. canLookReverseCard: true,
  240. selectPlayer: card.Owner,
  241. cardEffect: activateClass);
  242. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card.", "The opponent is selecting 1 digivolution card.");
  243. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  244. yield return StartCoroutine(selectCardEffect.Activate());
  245. IEnumerator SelectCardCoroutine(CardSource cardSource)
  246. {
  247. selectedDigivolutionCards.Add(cardSource);
  248. yield return null;
  249. }
  250. bool CanSelectPermanentCondition1(Permanent permanent)
  251. {
  252. List<Permanent> Permanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable);
  253. if (Permanents != null)
  254. {
  255. if (Permanents.Contains(permanent))
  256. {
  257. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  258. {
  259. if (!permanent.IsToken)
  260. {
  261. return true;
  262. }
  263. }
  264. }
  265. }
  266. return false;
  267. }
  268. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  269. {
  270. maxCount = 1;
  271. selectPermanentEffect.SetUp(
  272. selectPlayer: card.Owner,
  273. canTargetCondition: CanSelectPermanentCondition1,
  274. canTargetCondition_ByPreSelecetedList: null,
  275. canEndSelectCondition: null,
  276. maxCount: maxCount,
  277. canNoSelect: false,
  278. canEndNotMax: false,
  279. selectPermanentCoroutine: SelectPermanentCoroutine1,
  280. afterSelectPermanentCoroutine: null,
  281. mode: SelectPermanentEffect.Mode.Custom,
  282. cardEffect: activateClass);
  283. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get digivolution cards.", "The opponent is selecting 1 Digimon that will get digivolution cards.");
  284. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  285. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  286. {
  287. getDigivolutionCardsDigimon = permanent;
  288. yield return null;
  289. }
  290. }
  291. if (getDigivolutionCardsDigimon != null)
  292. {
  293. if (selectedDigivolutionCards.Count >= 1)
  294. {
  295. foreach (CardSource selectedCard in selectedDigivolutionCards)
  296. {
  297. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(selectedCard, giveDigivolutionCardsTamer));
  298. }
  299. yield return ContinuousController.instance.StartCoroutine(getDigivolutionCardsDigimon.AddDigivolutionCardsBottom(selectedDigivolutionCards, activateClass));
  300. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  301. ChangeCostClass changeCostClass = new ChangeCostClass();
  302. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  303. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  304. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  305. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  306. bool CanUseCondition1(Hashtable hashtable)
  307. {
  308. return true;
  309. }
  310. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  311. {
  312. if (CardSourceCondition(cardSource))
  313. {
  314. if (RootCondition(root))
  315. {
  316. if (PermanentsCondition(targetPermanents))
  317. {
  318. Cost -= 1;
  319. }
  320. }
  321. }
  322. return Cost;
  323. }
  324. bool PermanentsCondition(List<Permanent> targetPermanents)
  325. {
  326. if (targetPermanents != null)
  327. {
  328. if (targetPermanents.Count(PermanentCondition) >= 1)
  329. {
  330. return true;
  331. }
  332. }
  333. return false;
  334. }
  335. bool PermanentCondition(Permanent targetPermanent)
  336. {
  337. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  338. }
  339. bool CardSourceCondition(CardSource cardSource)
  340. {
  341. return cardSource.HasSaveText;
  342. }
  343. bool RootCondition(SelectCardEffect.Root root)
  344. {
  345. return true;
  346. }
  347. bool isUpDown()
  348. {
  349. return true;
  350. }
  351. }
  352. }
  353. }
  354. }
  355. }
  356. }
  357. }
  358. if (timing == EffectTiming.SecuritySkill)
  359. {
  360. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  361. }
  362. return cardEffects;
  363. }
  364. }
  365. }