BT21_088.cs 21 KB

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