BT16_048.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_048 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolve Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.GetCostItself <= 13 && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 6 && targetPermanent.TopCard.CardTraits.Contains("Insectoid");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: true, card: card, condition: null));
  20. }
  21. #endregion
  22. #region When Digivolving
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  28. activateClass.SetHashString("PlayDigimon_BT16_048");
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[When Digivolving][Once Per Turn] You may play 1 Digimon card with the [Insectoid] or [Larva] trait from your hand with the play cost reduced by 8.";
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource.IsDigimon)
  37. {
  38. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass))
  39. {
  40. if (cardSource.CardTraits.Contains("Insectoid"))
  41. {
  42. return true;
  43. }
  44. if (cardSource.CardTraits.Contains("Larva"))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. return true;
  61. }
  62. return false;
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. #region 登場コスト-8
  67. ChangeCostClass changeCostClass = new ChangeCostClass();
  68. changeCostClass.SetUpICardEffect("Play Cost -8", CanUseCondition1, card);
  69. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  70. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  71. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  72. ICardEffect GetCardEffect(EffectTiming _timing)
  73. {
  74. if (_timing == EffectTiming.None)
  75. {
  76. return changeCostClass;
  77. }
  78. return null;
  79. }
  80. bool CanUseCondition1(Hashtable hashtable)
  81. {
  82. return true;
  83. }
  84. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  85. {
  86. if (CardSourceCondition(cardSource))
  87. {
  88. if (RootCondition(root))
  89. {
  90. if (PermanentsCondition(targetPermanents))
  91. {
  92. Cost -= 8;
  93. }
  94. }
  95. }
  96. return Cost;
  97. }
  98. bool PermanentsCondition(List<Permanent> targetPermanents)
  99. {
  100. if (targetPermanents == null)
  101. {
  102. return true;
  103. }
  104. else
  105. {
  106. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. bool CardSourceCondition(CardSource cardSource)
  114. {
  115. if (cardSource != null)
  116. {
  117. if (cardSource.Owner == card.Owner)
  118. {
  119. if (cardSource.IsDigimon)
  120. {
  121. if (cardSource.CardTraits.Contains("Insectoid"))
  122. {
  123. return true;
  124. }
  125. if (cardSource.CardTraits.Contains("Larva"))
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. bool RootCondition(SelectCardEffect.Root root)
  135. {
  136. return true;
  137. }
  138. bool isUpDown()
  139. {
  140. return true;
  141. }
  142. #endregion
  143. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  144. {
  145. List<CardSource> selectedCards = new List<CardSource>();
  146. int maxCount = 1;
  147. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  148. selectHandEffect.SetUp(
  149. selectPlayer: card.Owner,
  150. canTargetCondition: CanSelectCardCondition,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. maxCount: maxCount,
  154. canNoSelect: true,
  155. canEndNotMax: false,
  156. isShowOpponent: true,
  157. selectCardCoroutine: SelectCardCoroutine,
  158. afterSelectCardCoroutine: null,
  159. mode: SelectHandEffect.Mode.Custom,
  160. cardEffect: activateClass);
  161. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  162. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  163. yield return StartCoroutine(selectHandEffect.Activate());
  164. IEnumerator SelectCardCoroutine(CardSource cardSource)
  165. {
  166. selectedCards.Add(cardSource);
  167. yield return null;
  168. }
  169. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: true, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  170. }
  171. #region 登場コスト-4解除
  172. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  173. #endregion
  174. }
  175. }
  176. #endregion
  177. #region All Turns
  178. if (timing == EffectTiming.None)
  179. {
  180. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  181. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseCondition, card);
  182. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  183. cardEffects.Add(canNotAffectedClass);
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. if (CardEffectCommons.IsExistOnBattleArea(card))
  187. {
  188. if (card.PermanentOfThisCard().IsSuspended)
  189. {
  190. return true;
  191. }
  192. }
  193. return false;
  194. }
  195. bool CardCondition(CardSource cardSource)
  196. {
  197. if (cardSource == card)
  198. {
  199. if (CardEffectCommons.IsExistOnBattleArea(card))
  200. {
  201. if (cardSource == card.PermanentOfThisCard().TopCard)
  202. {
  203. return true;
  204. }
  205. }
  206. }
  207. return false;
  208. }
  209. bool SkillCondition(ICardEffect cardEffect)
  210. {
  211. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  212. {
  213. if (cardEffect.IsDigimonEffect)
  214. {
  215. return true;
  216. }
  217. }
  218. return false;
  219. }
  220. }
  221. #endregion
  222. #region End of Your Turn
  223. if (timing == EffectTiming.OnEndTurn)
  224. {
  225. ActivateClass activateClass = new ActivateClass();
  226. activateClass.SetUpICardEffect("Suspend your 1 Digimon to return an opponent's Digimon to the bottom of the deck.", CanUseCondition, card);
  227. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  228. activateClass.SetHashString("EOT_BT16-048");
  229. cardEffects.Add(activateClass);
  230. string EffectDiscription()
  231. {
  232. return "[End of Your Turn] [Once Per Turn] By suspending 1 of your other Digimon, return 1 of your opponent's Digimon with DP less than or equal to the DP of the Digimon suspended by this effect to the bottom of the deck..";
  233. }
  234. bool CanSelectPermanentCondition(Permanent permanent)
  235. {
  236. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  237. {
  238. if (permanent != card.PermanentOfThisCard())
  239. {
  240. if (!permanent.IsSuspended && permanent.CanSuspend)
  241. {
  242. return true;
  243. }
  244. }
  245. }
  246. return false;
  247. }
  248. bool CanUseCondition(Hashtable hashtable)
  249. {
  250. if (CardEffectCommons.IsExistOnBattleArea(card))
  251. {
  252. if (CardEffectCommons.IsOwnerTurn(card))
  253. {
  254. return true;
  255. }
  256. }
  257. return false;
  258. }
  259. bool CanActivateCondition(Hashtable hashtable)
  260. {
  261. if (CardEffectCommons.IsExistOnBattleArea(card))
  262. {
  263. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  264. {
  265. return true;
  266. }
  267. }
  268. return false;
  269. }
  270. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  271. {
  272. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  273. {
  274. Permanent selectedPermanent = null;
  275. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  276. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  277. selectPermanentEffect.SetUp(
  278. selectPlayer: card.Owner,
  279. canTargetCondition: CanSelectPermanentCondition,
  280. canTargetCondition_ByPreSelecetedList: null,
  281. canEndSelectCondition: null,
  282. maxCount: maxCount,
  283. canNoSelect: true,
  284. canEndNotMax: false,
  285. selectPermanentCoroutine: SelectPermanentCoroutine,
  286. afterSelectPermanentCoroutine: null,
  287. mode: SelectPermanentEffect.Mode.Custom,
  288. cardEffect: activateClass);
  289. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  290. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  291. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  292. {
  293. selectedPermanent = permanent;
  294. yield return null;
  295. }
  296. if (selectedPermanent != null)
  297. {
  298. if (selectedPermanent.TopCard != null)
  299. {
  300. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  301. {
  302. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  303. {
  304. Permanent tapPermanent = selectedPermanent;
  305. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { tapPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  306. if (tapPermanent.TopCard != null)
  307. {
  308. if (tapPermanent.IsSuspended)
  309. {
  310. bool CanSelectPermanentToBounce(Permanent permanent)
  311. {
  312. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  313. {
  314. if (tapPermanent.DP >= permanent.DP)
  315. {
  316. return true;
  317. }
  318. }
  319. return false;
  320. }
  321. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentToBounce));
  322. SelectPermanentEffect selectPermanentEffectBounce = GManager.instance.GetComponent<SelectPermanentEffect>();
  323. selectPermanentEffect.SetUp(
  324. selectPlayer: card.Owner,
  325. canTargetCondition: CanSelectPermanentToBounce,
  326. canTargetCondition_ByPreSelecetedList: null,
  327. canEndSelectCondition: null,
  328. maxCount: maxCount,
  329. canNoSelect: false,
  330. canEndNotMax: false,
  331. selectPermanentCoroutine: null,
  332. afterSelectPermanentCoroutine: null,
  333. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  334. cardEffect: activateClass);
  335. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to the bottom of the deck.", "The opponent is selecting 1 Digimon to return to the bottom of the deck.");
  336. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  337. }
  338. }
  339. }
  340. }
  341. }
  342. }
  343. }
  344. }
  345. }
  346. #endregion
  347. return cardEffects;
  348. }
  349. }
  350. }