BT12_102.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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_102 : 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.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play Cost -3", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. activateClass.SetHashString("PlayCost-3_BT12_102");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "If you have this card in your hand, you may place 1 of your blue Digimon under another of your blue Digimon as its bottom digivolution card and reduce the cost by 3.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  28. {
  29. if (!permanent.IsToken)
  30. {
  31. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  32. {
  33. bool CanSelectPermanentCondition1(Permanent permanent1)
  34. {
  35. if (permanent1 != permanent)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent1, card))
  38. {
  39. if (permanent1.TopCard.CardColors.Contains(CardColor.Blue))
  40. {
  41. if (!permanent1.IsToken)
  42. {
  43. if (!permanent1.TopCard.CanNotBeAffected(activateClass))
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Some(CanSelectPermanentCondition1))
  54. {
  55. return true;
  56. }
  57. }
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. bool CardCondition(CardSource cardSource)
  64. {
  65. if (cardSource == card)
  66. {
  67. if (CardEffectCommons.IsExistOnHand(cardSource))
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. bool CanUseCondition(Hashtable hashtable)
  75. {
  76. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  77. {
  78. return true;
  79. }
  80. return false;
  81. }
  82. bool CanActivateCondition(Hashtable hashtable)
  83. {
  84. if (card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent.TopCard.CardColors.Contains(CardColor.Blue) && !permanent.IsToken) >= 2
  85. && card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) >= 1)
  86. {
  87. return true;
  88. }
  89. return false;
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  92. {
  93. if (card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent.TopCard.CardColors.Contains(CardColor.Blue) && !permanent.IsToken) >= 2
  94. && card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) >= 1)
  95. {
  96. bool CanNoSelect =
  97. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable) != null &&
  98. card.PayingCost(
  99. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable).Root,
  100. null,
  101. checkAvailability: false)
  102. <= card.Owner.MaxMemoryCost;
  103. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  104. {
  105. Permanent digivolutionPermanent = null;
  106. int maxCount = 1;
  107. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  108. selectPermanentEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: CanSelectPermanentCondition,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: maxCount,
  114. canNoSelect: CanNoSelect,
  115. canEndNotMax: false,
  116. selectPermanentCoroutine: SelectPermanentCoroutine,
  117. afterSelectPermanentCoroutine: null,
  118. mode: SelectPermanentEffect.Mode.Custom,
  119. cardEffect: activateClass);
  120. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that place under other Digimon's digivolution cards.", "The opponent is selecting 1 Digimon that place under other Digimon's digivolution cards.");
  121. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  122. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  123. {
  124. digivolutionPermanent = permanent;
  125. yield return null;
  126. }
  127. if (digivolutionPermanent != null)
  128. {
  129. bool CanSelectPermanentCondition1(Permanent permanent1)
  130. {
  131. if (permanent1 != digivolutionPermanent)
  132. {
  133. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent1, card))
  134. {
  135. if (permanent1.TopCard.CardColors.Contains(CardColor.Blue))
  136. {
  137. if (!permanent1.IsToken)
  138. {
  139. if (!permanent1.TopCard.CanNotBeAffected(activateClass))
  140. {
  141. return true;
  142. }
  143. }
  144. }
  145. }
  146. }
  147. return false;
  148. }
  149. maxCount = 1;
  150. selectPermanentEffect.SetUp(
  151. selectPlayer: card.Owner,
  152. canTargetCondition: CanSelectPermanentCondition1,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. maxCount: maxCount,
  156. canNoSelect: CanNoSelect,
  157. canEndNotMax: false,
  158. selectPermanentCoroutine: SelectPermanentCoroutine1,
  159. afterSelectPermanentCoroutine: null,
  160. mode: SelectPermanentEffect.Mode.Custom,
  161. cardEffect: activateClass);
  162. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get digivolution cards.", "The opponent is selecting 1 Digimon that will get digivolution cards.");
  163. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  164. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  165. {
  166. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { digivolutionPermanent, permanent } }, false, activateClass).PlacePermanentToDigivolutionCards());
  167. }
  168. if (digivolutionPermanent.TopCard == null && digivolutionPermanent.PlaceOtherPermanentEffect == activateClass)
  169. {
  170. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  171. ChangeCostClass changeCostClass = new ChangeCostClass();
  172. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition1, card);
  173. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  174. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  175. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  176. bool CanUseCondition1(Hashtable hashtable)
  177. {
  178. return true;
  179. }
  180. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  181. {
  182. if (CardSourceCondition(cardSource))
  183. {
  184. if (RootCondition(root))
  185. {
  186. if (PermanentsCondition(targetPermanents))
  187. {
  188. Cost -= 3;
  189. }
  190. }
  191. }
  192. return Cost;
  193. }
  194. bool PermanentsCondition(List<Permanent> targetPermanents)
  195. {
  196. if (targetPermanents == null)
  197. {
  198. return true;
  199. }
  200. else
  201. {
  202. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  203. {
  204. return true;
  205. }
  206. }
  207. return false;
  208. }
  209. bool CardSourceCondition(CardSource cardSource)
  210. {
  211. if (cardSource != null)
  212. {
  213. if (cardSource == card)
  214. {
  215. return true;
  216. }
  217. }
  218. return false;
  219. }
  220. bool RootCondition(SelectCardEffect.Root root)
  221. {
  222. return true;
  223. }
  224. bool isUpDown()
  225. {
  226. return true;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. if (timing == EffectTiming.None)
  235. {
  236. ChangeCostClass changeCostClass = new ChangeCostClass();
  237. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition, card);
  238. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  239. changeCostClass.SetNotShowUI(true);
  240. cardEffects.Add(changeCostClass);
  241. bool CanSelectPermanentCondition(Permanent permanent, ICardEffect activateClass)
  242. {
  243. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  244. {
  245. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  246. {
  247. if (!permanent.IsToken)
  248. {
  249. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  250. {
  251. bool CanSelectPermanentCondition1(Permanent permanent1)
  252. {
  253. if (permanent1 != permanent)
  254. {
  255. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent1, card))
  256. {
  257. if (permanent1.TopCard.CardColors.Contains(CardColor.Blue))
  258. {
  259. if (!permanent1.IsToken)
  260. {
  261. if (!permanent1.TopCard.CanNotBeAffected(activateClass))
  262. {
  263. return true;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. return false;
  270. }
  271. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Some(CanSelectPermanentCondition1))
  272. {
  273. return true;
  274. }
  275. }
  276. }
  277. }
  278. }
  279. return false;
  280. }
  281. bool CanUseCondition(Hashtable hashtable)
  282. {
  283. if (card.Owner.HandCards.Contains(card))
  284. {
  285. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Play Cost -3");
  286. if (activateClass != null)
  287. {
  288. if (card.Owner.GetBattleAreaDigimons().Count((permanent) =>
  289. permanent.TopCard.CardColors.Contains(CardColor.Blue) && !permanent.IsToken) >= 2
  290. && card.Owner.GetBattleAreaDigimons().Count(permanent => CanSelectPermanentCondition(permanent, activateClass)) >= 1)
  291. {
  292. return true;
  293. }
  294. }
  295. }
  296. return false;
  297. }
  298. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  299. {
  300. if (CardSourceCondition(cardSource))
  301. {
  302. if (RootCondition(root))
  303. {
  304. if (PermanentsCondition(targetPermanents))
  305. {
  306. Cost -= 3;
  307. }
  308. }
  309. }
  310. return Cost;
  311. }
  312. bool PermanentsCondition(List<Permanent> targetPermanents)
  313. {
  314. if (targetPermanents == null)
  315. {
  316. return true;
  317. }
  318. else
  319. {
  320. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  321. {
  322. return true;
  323. }
  324. }
  325. return false;
  326. }
  327. bool CardSourceCondition(CardSource cardSource)
  328. {
  329. if (cardSource != null)
  330. {
  331. if (cardSource == card)
  332. {
  333. return true;
  334. }
  335. }
  336. return false;
  337. }
  338. bool RootCondition(SelectCardEffect.Root root)
  339. {
  340. return true;
  341. }
  342. bool isUpDown()
  343. {
  344. return true;
  345. }
  346. }
  347. if (timing == EffectTiming.OptionSkill)
  348. {
  349. ActivateClass activateClass = new ActivateClass();
  350. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  351. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  352. cardEffects.Add(activateClass);
  353. string EffectDiscription()
  354. {
  355. return "[Main] Return 1 of your opponent's Digimon to their owner's deck.";
  356. }
  357. bool CanSelectPermanentCondition(Permanent permanent)
  358. {
  359. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  360. }
  361. bool CanUseCondition(Hashtable hashtable)
  362. {
  363. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  364. }
  365. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  366. {
  367. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  368. {
  369. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  370. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  371. selectPermanentEffect.SetUp(
  372. selectPlayer: card.Owner,
  373. canTargetCondition: CanSelectPermanentCondition,
  374. canTargetCondition_ByPreSelecetedList: null,
  375. canEndSelectCondition: null,
  376. maxCount: maxCount,
  377. canNoSelect: false,
  378. canEndNotMax: false,
  379. selectPermanentCoroutine: null,
  380. afterSelectPermanentCoroutine: null,
  381. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  382. cardEffect: activateClass);
  383. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  384. }
  385. }
  386. }
  387. if (timing == EffectTiming.SecuritySkill)
  388. {
  389. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Return 1 Digimon to the bottom of deck");
  390. }
  391. return cardEffects;
  392. }
  393. }
  394. }