BT23_036.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // BanchoLeomon
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_036 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel5
  19. && (targetPermanent.TopCard.ContainsCardName("Leomon") || targetPermanent.TopCard.HasCSTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null)
  27. );
  28. }
  29. #endregion
  30. #region Reduce Play Cost
  31. bool HasValidDigimon(Permanent permanent)
  32. {
  33. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  34. {
  35. if (permanent.DP >= 10000)
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. #region Before Pay Cost - Condition Effect
  43. if (timing == EffectTiming.BeforePayCost)
  44. {
  45. ActivateClass activateClass = new ActivateClass();
  46. activateClass.SetUpICardEffect("Reduce the play cost by 5", CanUseCondition, card);
  47. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  48. activateClass.SetHashString("PlayCost-5_BT23_036");
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "When this card would be played, if your opponent has a Digimon with 10000 DP or more, reduce the play cost by 5.";
  53. }
  54. bool CardCondition(CardSource cardSource)
  55. {
  56. return cardSource == card
  57. && CardEffectCommons.HasMatchConditionPermanent(HasValidDigimon);
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  62. }
  63. bool CanActivateCondition(Hashtable hashtable)
  64. {
  65. return CardEffectCommons.HasMatchConditionPermanent(HasValidDigimon);
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. if (card.Owner.CanReduceCost(null, card))
  70. {
  71. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  72. }
  73. ChangeCostClass changeCostClass = new ChangeCostClass();
  74. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition1, card);
  75. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  76. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  77. bool CanUseCondition1(Hashtable hashtable)
  78. {
  79. return true;
  80. }
  81. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  82. {
  83. if (CardSourceCondition(cardSource))
  84. {
  85. if (RootCondition(root))
  86. {
  87. if (PermanentsCondition(targetPermanents))
  88. {
  89. int targetCost = 0;
  90. if (CardEffectCommons.HasMatchConditionPermanent(HasValidDigimon))
  91. targetCost += 5;
  92. Cost -= targetCost;
  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. return cardSource == card;
  116. }
  117. bool RootCondition(SelectCardEffect.Root root)
  118. {
  119. return true;
  120. }
  121. bool isUpDown()
  122. {
  123. return true;
  124. }
  125. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  126. }
  127. }
  128. #endregion
  129. #region Reduce Play Cost - Not Shown
  130. if (timing == EffectTiming.None)
  131. {
  132. ChangeCostClass changeCostClass = new ChangeCostClass();
  133. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
  134. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  135. changeCostClass.SetNotShowUI(true);
  136. cardEffects.Add(changeCostClass);
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Reduce the play cost by 5");
  140. if (activateClass != null)
  141. {
  142. return CardEffectCommons.HasMatchConditionPermanent(HasValidDigimon);
  143. }
  144. return false;
  145. }
  146. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  147. {
  148. if (CardSourceCondition(cardSource))
  149. {
  150. if (RootCondition(root))
  151. {
  152. if (PermanentsCondition(targetPermanents))
  153. {
  154. int targetCount = 0;
  155. if (CardEffectCommons.HasMatchConditionPermanent(HasValidDigimon))
  156. targetCount += 5;
  157. Cost -= targetCount;
  158. }
  159. }
  160. }
  161. return Cost;
  162. }
  163. bool PermanentsCondition(List<Permanent> targetPermanents)
  164. {
  165. if (targetPermanents == null)
  166. {
  167. return true;
  168. }
  169. else
  170. {
  171. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  172. {
  173. return true;
  174. }
  175. }
  176. return false;
  177. }
  178. bool CardSourceCondition(CardSource cardSource)
  179. {
  180. if (cardSource != null)
  181. {
  182. if (cardSource == card)
  183. {
  184. return true;
  185. }
  186. }
  187. return false;
  188. }
  189. bool RootCondition(SelectCardEffect.Root root)
  190. {
  191. return true;
  192. }
  193. bool isUpDown()
  194. {
  195. return true;
  196. }
  197. }
  198. #endregion
  199. #endregion
  200. #region OP/WD Shared
  201. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  202. {
  203. bool CanSelectPermanentCondition(Permanent permanent)
  204. {
  205. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  206. && permanent != card.PermanentOfThisCard();;
  207. }
  208. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  209. {
  210. Permanent selectedPermament = null;
  211. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  212. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  213. selectPermanentEffect.SetUp(
  214. selectPlayer: card.Owner,
  215. canTargetCondition: CanSelectPermanentCondition,
  216. canTargetCondition_ByPreSelecetedList: null,
  217. canEndSelectCondition: null,
  218. maxCount: maxCount,
  219. canNoSelect: true,
  220. canEndNotMax: false,
  221. selectPermanentCoroutine: SelectPermanentCoroutine,
  222. afterSelectPermanentCoroutine: null,
  223. mode: SelectPermanentEffect.Mode.Custom,
  224. cardEffect: activateClass);
  225. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  226. {
  227. selectedPermament = permanent;
  228. yield return null;
  229. }
  230. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon.");
  231. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  232. bool CardCondition(CardSource cardSource)
  233. {
  234. return cardSource.IsDigimon
  235. && cardSource.HasLevel && cardSource.Level <= 6
  236. && (cardSource.ContainsCardName("Leomon") || cardSource.HasCSTraits)
  237. && cardSource.CanPlayCardTargetFrame(selectedPermament.PermanentFrame, false, activateClass);
  238. }
  239. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  240. targetPermanent: selectedPermament,
  241. cardCondition: CardCondition,
  242. payCost: false,
  243. reduceCostTuple: null,
  244. fixedCostTuple: null,
  245. ignoreDigivolutionRequirementFixedCost: -1,
  246. isHand: true,
  247. activateClass: activateClass,
  248. successProcess: null,
  249. isOptional: true));
  250. }
  251. }
  252. #endregion
  253. #region On Play
  254. if (timing == EffectTiming.OnEnterFieldAnyone)
  255. {
  256. ActivateClass activateClass = new ActivateClass();
  257. activateClass.SetUpICardEffect("Digivolve into a level 6 with [Leomon] in name or [CS] trait", CanUseCondition, card);
  258. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  259. cardEffects.Add(activateClass);
  260. string EffectDiscription()
  261. {
  262. return "[On Play] 1 of your other Digimon may digivolve into a level 6 or lower Digimon card with [Leomon] in its name or the [CS] trait in the hand without paying the cost.";
  263. }
  264. bool CanUseCondition(Hashtable hashtable)
  265. {
  266. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  267. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  268. }
  269. bool CanActivateCondition(Hashtable hashtable)
  270. {
  271. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  272. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, OtherDigimon);
  273. }
  274. bool OtherDigimon(Permanent permanent)
  275. {
  276. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  277. permanent != card.PermanentOfThisCard();
  278. }
  279. }
  280. #endregion
  281. #region When Digivolving
  282. if (timing == EffectTiming.OnEnterFieldAnyone)
  283. {
  284. ActivateClass activateClass = new ActivateClass();
  285. activateClass.SetUpICardEffect("Digivolve into a level 6 with [Leomon] in name or [CS] trait", CanUseCondition, card);
  286. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  287. cardEffects.Add(activateClass);
  288. string EffectDiscription()
  289. {
  290. return "[When Digivolving] 1 of your other Digimon may digivolve into a level 6 or lower Digimon card with [Leomon] in its name or the [CS] trait in the hand without paying the cost.";
  291. }
  292. bool CanUseCondition(Hashtable hashtable)
  293. {
  294. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  295. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  296. }
  297. bool CanActivateCondition(Hashtable hashtable)
  298. {
  299. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  300. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, OtherDigimon);
  301. }
  302. bool OtherDigimon(Permanent permanent)
  303. {
  304. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  305. permanent != card.PermanentOfThisCard();
  306. }
  307. }
  308. #endregion
  309. #region End of Your Turn - OPT
  310. if (timing == EffectTiming.OnEndTurn)
  311. {
  312. ActivateClass activateClass = new ActivateClass();
  313. activateClass.SetUpICardEffect("Give 1 digimon raid, then it may attack", CanUseCondition, card);
  314. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  315. activateClass.SetHashString("BT23_036_EOYT");
  316. cardEffects.Add(activateClass);
  317. string EffectDiscription()
  318. {
  319. return "[End of Your Turn] [Once Per Turn] 1 of your Digimon gains <Raid> for the turn, Then that Digimon may attack.";
  320. }
  321. bool CanUseCondition(Hashtable hashtable)
  322. {
  323. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  324. }
  325. bool CanActivateCondition(Hashtable hashtable)
  326. {
  327. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  328. && CardEffectCommons.IsOwnerTurn(card);
  329. }
  330. bool CanSelectPermamentCondition(Permanent permanent)
  331. {
  332. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  333. }
  334. IEnumerator ActivateCoroutine(Hashtable hashtable)
  335. {
  336. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentCondition))
  337. {
  338. Permanent selectedPermament = null;
  339. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  340. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermamentCondition));
  341. selectPermanentEffect.SetUp(
  342. selectPlayer: card.Owner,
  343. canTargetCondition: CanSelectPermamentCondition,
  344. canTargetCondition_ByPreSelecetedList: null,
  345. canEndSelectCondition: null,
  346. maxCount: maxCount,
  347. canNoSelect: false,
  348. canEndNotMax: false,
  349. selectPermanentCoroutine: SelectPermanentCoroutine,
  350. afterSelectPermanentCoroutine: null,
  351. mode: SelectPermanentEffect.Mode.Custom,
  352. cardEffect: activateClass);
  353. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  354. {
  355. selectedPermament = permanent;
  356. yield return null;
  357. }
  358. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain raid and attack", "The opponent is selecting 1 Digimon to gain raid and attack.");
  359. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  360. if (selectedPermament != null)
  361. {
  362. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRaid(
  363. targetPermanent: selectedPermament,
  364. effectDuration: EffectDuration.UntilEachTurnEnd,
  365. activateClass: activateClass));
  366. if (selectedPermament.CanAttack(activateClass))
  367. {
  368. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  369. selectAttackEffect.SetUp(
  370. attacker: selectedPermament,
  371. canAttackPlayerCondition: () => true,
  372. defenderCondition: _ => true,
  373. cardEffect: activateClass);
  374. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  375. }
  376. }
  377. }
  378. }
  379. }
  380. #endregion
  381. return cardEffects;
  382. }
  383. }
  384. }