BT12_094.cs 20 KB

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