BT17_035.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_035 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Barrier
  13. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  14. {
  15. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region When Digivolving
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Play 1 [Plug-In] Option", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[When Digivolving] You may use 1 option card that has [Plug-In] in its name or that's yellow from the hand with the cost reduced by 2.";
  28. }
  29. bool OptionCondition(CardSource cardSource)
  30. {
  31. if (cardSource.IsOption)
  32. {
  33. if (cardSource.ContainsCardName("Plug-In") || cardSource.HasCardColor(CardColor.Yellow))
  34. {
  35. return true;
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. if (OptionCondition(cardSource))
  43. {
  44. if (!cardSource.CanNotPlayThisOption)
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. if (card.Owner.HandCards.Count >= 1)
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  67. {
  68. #region reduce play cost
  69. ChangeCostClass changeCostClass = new ChangeCostClass();
  70. changeCostClass.SetUpICardEffect($"Play Cost -2", CanUseCondition1, card);
  71. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: OptionCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  72. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  73. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  74. ICardEffect GetCardEffect(EffectTiming _timing)
  75. {
  76. if (_timing == EffectTiming.None)
  77. {
  78. return changeCostClass;
  79. }
  80. return null;
  81. }
  82. bool CanUseCondition1(Hashtable hashtable)
  83. {
  84. return true;
  85. }
  86. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  87. {
  88. if (OptionCondition(cardSource))
  89. {
  90. if (RootCondition(root))
  91. {
  92. if (PermanentsCondition(targetPermanents))
  93. {
  94. Cost -= 2;
  95. }
  96. }
  97. }
  98. return Cost;
  99. }
  100. bool PermanentsCondition(List<Permanent> targetPermanents)
  101. {
  102. if (targetPermanents == null)
  103. {
  104. return true;
  105. }
  106. else
  107. {
  108. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  109. {
  110. return true;
  111. }
  112. }
  113. return false;
  114. }
  115. bool RootCondition(SelectCardEffect.Root root)
  116. {
  117. return true;
  118. }
  119. bool isUpDown()
  120. {
  121. return true;
  122. }
  123. #endregion
  124. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  125. {
  126. List<CardSource> selectedCards = new List<CardSource>();
  127. int maxCount = 1;
  128. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  129. selectHandEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: CanSelectCardCondition,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount,
  135. canNoSelect: true,
  136. canEndNotMax: false,
  137. isShowOpponent: true,
  138. selectCardCoroutine: SelectCardCoroutine,
  139. afterSelectCardCoroutine: null,
  140. mode: SelectHandEffect.Mode.Custom,
  141. cardEffect: activateClass);
  142. selectHandEffect.SetUpCustomMessage(
  143. "Select 1 option card to use.",
  144. "The opponent is selecting 1 option card to use.");
  145. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  146. yield return StartCoroutine(selectHandEffect.Activate());
  147. IEnumerator SelectCardCoroutine(CardSource cardSource)
  148. {
  149. selectedCards.Add(cardSource);
  150. yield return null;
  151. }
  152. yield return ContinuousController.instance.StartCoroutine(
  153. CardEffectCommons.PlayOptionCards(
  154. cardSources: selectedCards,
  155. activateClass: activateClass,
  156. payCost: true,
  157. root: SelectCardEffect.Root.Hand
  158. )
  159. );
  160. }
  161. #region release effect
  162. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  163. #endregion
  164. }
  165. }
  166. #endregion
  167. #region Inherit
  168. if (timing == EffectTiming.OnAllyAttack)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("Play 1 [Plug-In] Option", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  173. activateClass.SetIsInheritedEffect(true);
  174. activateClass.SetHashString("ESS_BT17_035");
  175. cardEffects.Add(activateClass);
  176. string EffectDiscription()
  177. {
  178. return "[When Attacking] [Once Per Turn] If this Digimon has [Sakuyamon] in its name, you may use 1 option card that has [Plug-In] in its name or that's yellow from the hand with the cost reduced by 2.";
  179. }
  180. bool OptionCondition(CardSource cardSource)
  181. {
  182. if (cardSource.IsOption)
  183. {
  184. if (cardSource.ContainsCardName("Plug-In") || cardSource.HasCardColor(CardColor.Yellow))
  185. {
  186. return true;
  187. }
  188. }
  189. return false;
  190. }
  191. bool CanSelectCardCondition(CardSource cardSource)
  192. {
  193. if (OptionCondition(cardSource))
  194. {
  195. if (!cardSource.CanNotPlayThisOption)
  196. {
  197. return true;
  198. }
  199. }
  200. return false;
  201. }
  202. bool CanUseCondition(Hashtable hashtable)
  203. {
  204. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. if (CardEffectCommons.IsExistOnBattleArea(card))
  209. {
  210. if (card.Owner.HandCards.Count >= 1)
  211. {
  212. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Sakuyamon"))
  213. {
  214. return true;
  215. }
  216. }
  217. }
  218. return false;
  219. }
  220. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  221. {
  222. if(card.PermanentOfThisCard().TopCard.ContainsCardName("Sakuyamon"))
  223. {
  224. #region reduce play cost
  225. ChangeCostClass changeCostClass = new ChangeCostClass();
  226. changeCostClass.SetUpICardEffect($"Play Cost -2", CanUseCondition1, card);
  227. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: OptionCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  228. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  229. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  230. ICardEffect GetCardEffect(EffectTiming _timing)
  231. {
  232. if (_timing == EffectTiming.None)
  233. {
  234. return changeCostClass;
  235. }
  236. return null;
  237. }
  238. bool CanUseCondition1(Hashtable hashtable)
  239. {
  240. return true;
  241. }
  242. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  243. {
  244. if (OptionCondition(cardSource))
  245. {
  246. if (RootCondition(root))
  247. {
  248. if (PermanentsCondition(targetPermanents))
  249. {
  250. Cost -= 2;
  251. }
  252. }
  253. }
  254. return Cost;
  255. }
  256. bool PermanentsCondition(List<Permanent> targetPermanents)
  257. {
  258. if (targetPermanents == null)
  259. {
  260. return true;
  261. }
  262. else
  263. {
  264. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  265. {
  266. return true;
  267. }
  268. }
  269. return false;
  270. }
  271. bool RootCondition(SelectCardEffect.Root root)
  272. {
  273. return true;
  274. }
  275. bool isUpDown()
  276. {
  277. return true;
  278. }
  279. #endregion
  280. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  281. {
  282. List<CardSource> selectedCards = new List<CardSource>();
  283. int maxCount = 1;
  284. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  285. selectHandEffect.SetUp(
  286. selectPlayer: card.Owner,
  287. canTargetCondition: CanSelectCardCondition,
  288. canTargetCondition_ByPreSelecetedList: null,
  289. canEndSelectCondition: null,
  290. maxCount: maxCount,
  291. canNoSelect: true,
  292. canEndNotMax: false,
  293. isShowOpponent: true,
  294. selectCardCoroutine: SelectCardCoroutine,
  295. afterSelectCardCoroutine: null,
  296. mode: SelectHandEffect.Mode.Custom,
  297. cardEffect: activateClass);
  298. selectHandEffect.SetUpCustomMessage(
  299. "Select 1 option card to use.",
  300. "The opponent is selecting 1 option card to use.");
  301. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  302. yield return StartCoroutine(selectHandEffect.Activate());
  303. IEnumerator SelectCardCoroutine(CardSource cardSource)
  304. {
  305. selectedCards.Add(cardSource);
  306. yield return null;
  307. }
  308. yield return ContinuousController.instance.StartCoroutine(
  309. CardEffectCommons.PlayOptionCards(
  310. cardSources: selectedCards,
  311. activateClass: activateClass,
  312. payCost: true,
  313. root: SelectCardEffect.Root.Hand
  314. )
  315. );
  316. }
  317. #region release effect
  318. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  319. #endregion
  320. }
  321. }
  322. }
  323. #endregion
  324. return cardEffects;
  325. }
  326. }
  327. }