BT13_056.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_056 : 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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  17. activateClass.SetHashString("PlayDigimon_BT13_056");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving][Once Per Turn] You may play 1 green or [Royal Knight] trait Digimon card from your hand for the cost. When it would be played by this effect, reduce the play cost by 4.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsDigimon)
  26. {
  27. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass))
  28. {
  29. if (cardSource.HasRoyalKnightTraits)
  30. {
  31. return true;
  32. }
  33. if (cardSource.CardColors.Contains(CardColor.Green))
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. return true;
  50. }
  51. return false;
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  54. {
  55. #region 登場コスト-4
  56. ChangeCostClass changeCostClass = new ChangeCostClass();
  57. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  58. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  59. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  60. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  61. ICardEffect GetCardEffect(EffectTiming _timing)
  62. {
  63. if (_timing == EffectTiming.None)
  64. {
  65. return changeCostClass;
  66. }
  67. return null;
  68. }
  69. bool CanUseCondition1(Hashtable hashtable)
  70. {
  71. return true;
  72. }
  73. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  74. {
  75. if (CardSourceCondition(cardSource))
  76. {
  77. if (RootCondition(root))
  78. {
  79. if (PermanentsCondition(targetPermanents))
  80. {
  81. Cost -= 4;
  82. }
  83. }
  84. }
  85. return Cost;
  86. }
  87. bool PermanentsCondition(List<Permanent> targetPermanents)
  88. {
  89. if (targetPermanents == null)
  90. {
  91. return true;
  92. }
  93. else
  94. {
  95. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  96. {
  97. return true;
  98. }
  99. }
  100. return false;
  101. }
  102. bool CardSourceCondition(CardSource cardSource)
  103. {
  104. if (cardSource != null)
  105. {
  106. if (cardSource.Owner == card.Owner)
  107. {
  108. if (cardSource.IsDigimon)
  109. {
  110. if (cardSource.HasRoyalKnightTraits)
  111. {
  112. return true;
  113. }
  114. if (cardSource.CardColors.Contains(CardColor.Green))
  115. {
  116. return true;
  117. }
  118. }
  119. }
  120. }
  121. return false;
  122. }
  123. bool RootCondition(SelectCardEffect.Root root)
  124. {
  125. return true;
  126. }
  127. bool isUpDown()
  128. {
  129. return true;
  130. }
  131. #endregion
  132. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  133. {
  134. List<CardSource> selectedCards = new List<CardSource>();
  135. int maxCount = 1;
  136. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  137. selectHandEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: CanSelectCardCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: maxCount,
  143. canNoSelect: true,
  144. canEndNotMax: false,
  145. isShowOpponent: true,
  146. selectCardCoroutine: SelectCardCoroutine,
  147. afterSelectCardCoroutine: null,
  148. mode: SelectHandEffect.Mode.Custom,
  149. cardEffect: activateClass);
  150. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  151. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  152. yield return StartCoroutine(selectHandEffect.Activate());
  153. IEnumerator SelectCardCoroutine(CardSource cardSource)
  154. {
  155. selectedCards.Add(cardSource);
  156. yield return null;
  157. }
  158. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: true, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  159. }
  160. #region 登場コスト-4解除
  161. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  162. #endregion
  163. }
  164. }
  165. if (timing == EffectTiming.OnDeclaration)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  170. activateClass.SetHashString("PlayDigimon_BT13_056");
  171. cardEffects.Add(activateClass);
  172. string EffectDiscription()
  173. {
  174. return "[Main][Once Per Turn] You may play 1 green or [Royal Knight] trait Digimon card from your hand for the cost. When it would be played by this effect, reduce the play cost by 4.";
  175. }
  176. bool CanSelectCardCondition(CardSource cardSource)
  177. {
  178. if (cardSource.IsDigimon)
  179. {
  180. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass))
  181. {
  182. if (cardSource.HasRoyalKnightTraits)
  183. {
  184. return true;
  185. }
  186. if (cardSource.CardColors.Contains(CardColor.Green))
  187. {
  188. return true;
  189. }
  190. }
  191. }
  192. return false;
  193. }
  194. bool CanUseCondition(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.IsExistOnBattleArea(card))
  197. {
  198. bool canPlay = false;
  199. #region 登場コスト-4
  200. ChangeCostClass changeCostClass = new ChangeCostClass();
  201. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  202. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  203. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  204. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  205. ICardEffect GetCardEffect(EffectTiming _timing)
  206. {
  207. if (_timing == EffectTiming.None)
  208. {
  209. return changeCostClass;
  210. }
  211. return null;
  212. }
  213. bool CanUseCondition1(Hashtable hashtable)
  214. {
  215. return true;
  216. }
  217. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  218. {
  219. if (CardSourceCondition(cardSource))
  220. {
  221. if (RootCondition(root))
  222. {
  223. if (PermanentsCondition(targetPermanents))
  224. {
  225. Cost -= 4;
  226. }
  227. }
  228. }
  229. return Cost;
  230. }
  231. bool PermanentsCondition(List<Permanent> targetPermanents)
  232. {
  233. if (targetPermanents == null)
  234. {
  235. return true;
  236. }
  237. else
  238. {
  239. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  240. {
  241. return true;
  242. }
  243. }
  244. return false;
  245. }
  246. bool CardSourceCondition(CardSource cardSource)
  247. {
  248. if (cardSource != null)
  249. {
  250. if (cardSource.Owner == card.Owner)
  251. {
  252. if (cardSource.IsDigimon)
  253. {
  254. if (cardSource.HasRoyalKnightTraits)
  255. {
  256. return true;
  257. }
  258. if (cardSource.CardColors.Contains(CardColor.Green))
  259. {
  260. return true;
  261. }
  262. }
  263. }
  264. }
  265. return false;
  266. }
  267. bool RootCondition(SelectCardEffect.Root root)
  268. {
  269. return true;
  270. }
  271. bool isUpDown()
  272. {
  273. return true;
  274. }
  275. #endregion
  276. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  277. {
  278. canPlay = true;
  279. }
  280. #region 登場コスト-4解除
  281. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  282. #endregion
  283. if (canPlay)
  284. {
  285. return true;
  286. }
  287. }
  288. return false;
  289. }
  290. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  291. {
  292. #region 登場コスト-4
  293. ChangeCostClass changeCostClass = new ChangeCostClass();
  294. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  295. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  296. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  297. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  298. ICardEffect GetCardEffect(EffectTiming _timing)
  299. {
  300. if (_timing == EffectTiming.None)
  301. {
  302. return changeCostClass;
  303. }
  304. return null;
  305. }
  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 -= 4;
  319. }
  320. }
  321. }
  322. return Cost;
  323. }
  324. bool PermanentsCondition(List<Permanent> targetPermanents)
  325. {
  326. if (targetPermanents == null)
  327. {
  328. return true;
  329. }
  330. else
  331. {
  332. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  333. {
  334. return true;
  335. }
  336. }
  337. return false;
  338. }
  339. bool CardSourceCondition(CardSource cardSource)
  340. {
  341. if (cardSource != null)
  342. {
  343. if (cardSource.Owner == card.Owner)
  344. {
  345. if (cardSource.IsDigimon)
  346. {
  347. if (cardSource.HasRoyalKnightTraits)
  348. {
  349. return true;
  350. }
  351. if (cardSource.CardColors.Contains(CardColor.Green))
  352. {
  353. return true;
  354. }
  355. }
  356. }
  357. }
  358. return false;
  359. }
  360. bool RootCondition(SelectCardEffect.Root root)
  361. {
  362. return true;
  363. }
  364. bool isUpDown()
  365. {
  366. return true;
  367. }
  368. #endregion
  369. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  370. {
  371. List<CardSource> selectedCards = new List<CardSource>();
  372. int maxCount = 1;
  373. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  374. selectHandEffect.SetUp(
  375. selectPlayer: card.Owner,
  376. canTargetCondition: CanSelectCardCondition,
  377. canTargetCondition_ByPreSelecetedList: null,
  378. canEndSelectCondition: null,
  379. maxCount: maxCount,
  380. canNoSelect: true,
  381. canEndNotMax: false,
  382. isShowOpponent: true,
  383. selectCardCoroutine: SelectCardCoroutine,
  384. afterSelectCardCoroutine: null,
  385. mode: SelectHandEffect.Mode.Custom,
  386. cardEffect: activateClass);
  387. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  388. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  389. yield return StartCoroutine(selectHandEffect.Activate());
  390. IEnumerator SelectCardCoroutine(CardSource cardSource)
  391. {
  392. selectedCards.Add(cardSource);
  393. yield return null;
  394. }
  395. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: true, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  396. }
  397. #region 登場コスト-4解除
  398. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  399. #endregion
  400. }
  401. }
  402. if (timing == EffectTiming.OnEnterFieldAnyone)
  403. {
  404. ActivateClass activateClass = new ActivateClass();
  405. activateClass.SetUpICardEffect("Your Digimon gain Blocker", CanUseCondition, card);
  406. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  407. activateClass.SetHashString("GetEffects_BT13_056");
  408. cardEffects.Add(activateClass);
  409. string EffectDiscription()
  410. {
  411. return "[All Turns] When you play another Digimon, all of your green and [Royal Knight] trait Digimon gain <Blocker> until the end of your opponent's turn.";
  412. }
  413. bool PermanentCondition(Permanent permanent)
  414. {
  415. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  416. {
  417. if (permanent != card.PermanentOfThisCard())
  418. {
  419. return true;
  420. }
  421. }
  422. return false;
  423. }
  424. bool CanUseCondition(Hashtable hashtable)
  425. {
  426. if (CardEffectCommons.IsExistOnBattleArea(card))
  427. {
  428. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  429. {
  430. return true;
  431. }
  432. }
  433. return false;
  434. }
  435. bool CanActivateCondition(Hashtable hashtable)
  436. {
  437. if (CardEffectCommons.IsExistOnBattleArea(card))
  438. {
  439. return true;
  440. }
  441. return false;
  442. }
  443. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  444. {
  445. bool PermanentCondition(Permanent permanent)
  446. {
  447. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  448. {
  449. if (permanent.TopCard.HasRoyalKnightTraits)
  450. {
  451. return true;
  452. }
  453. if (permanent.TopCard.CardColors.Contains(CardColor.Green))
  454. {
  455. return true;
  456. }
  457. }
  458. return false;
  459. }
  460. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlockerPlayerEffect(permanentCondition: PermanentCondition, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  461. }
  462. }
  463. return cardEffects;
  464. }
  465. }
  466. }