BT12_087.cs 20 KB

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