BT22_080.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Eater (Human Form)
  7. namespace DCGO.CardEffects.BT22
  8. {
  9. public class BT22_080 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternative Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.EqualsCardName("Eater (Species Form)");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 2,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null)
  27. );
  28. }
  29. #endregion
  30. #region When Digivolving
  31. if (timing == EffectTiming.OnEnterFieldAnyone)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("Move 1 [Eater (Species Form)] from sources under [Mother Eater] in breeding", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  36. cardEffects.Add(activateClass);
  37. string EffectDiscription()
  38. {
  39. return "[When Digivolving] You may place 1 [Eater (Species Form)] from this Digimon's digivolution cards as the bottom digivolution card of your [Mother Eater] in the breeding area.";
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  48. && CardEffectCommons.HasMatchConditionOwnersBreedingPermanent(card, IsMotherEater)
  49. && CardEffectCommons.HasMatchConditionPermanentDigivolutionCards(card, isEaterSpeciesForm);
  50. }
  51. bool IsMotherEater(Permanent permanent)
  52. {
  53. return permanent.TopCard.EqualsCardName("Mother Eater");
  54. }
  55. bool isEaterSpeciesForm(CardSource cardSource)
  56. {
  57. return cardSource.IsDigimon && cardSource.EqualsCardName("Eater (Species Form)");
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable hashtable)
  60. {
  61. if (CardEffectCommons.HasMatchConditionPermanentDigivolutionCards(card, isEaterSpeciesForm) && CardEffectCommons.HasMatchConditionOwnersBreedingPermanent(card, IsMotherEater))
  62. {
  63. Permanent thisPermanent = card.PermanentOfThisCard();
  64. CardSource selectedCard = null;
  65. int maxCount = Math.Min(1, thisPermanent.DigivolutionCards.Count(isEaterSpeciesForm));
  66. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  67. selectCardEffect.SetUp(
  68. canTargetCondition: isEaterSpeciesForm,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. canNoSelect: () => false,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. message: "Select 1 digivolution card to move under Mother Eater.",
  75. maxCount: maxCount,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. mode: SelectCardEffect.Mode.Custom,
  79. root: SelectCardEffect.Root.Custom,
  80. customRootCardList: thisPermanent.DigivolutionCards,
  81. canLookReverseCard: true,
  82. selectPlayer: card.Owner,
  83. cardEffect: activateClass);
  84. IEnumerator SelectCardCoroutine(CardSource cardSource)
  85. {
  86. selectedCard = cardSource;
  87. yield return null;
  88. }
  89. selectCardEffect.SetUpCustomMessage("Select 1 [Eater (Species Form)] to move under Mother Eater.", "The opponent is selecting 1 [Eater (Species Form)] to move under Mother Eater.");
  90. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  91. yield return StartCoroutine(selectCardEffect.Activate());
  92. if (selectedCard != null && card.Owner.GetBreedingAreaPermanents().FirstOrDefault(IsMotherEater) != null)
  93. {
  94. Permanent motherEater = card.Owner.GetBreedingAreaPermanents().FirstOrDefault(IsMotherEater);
  95. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  96. yield return ContinuousController.instance.StartCoroutine(motherEater.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  97. }
  98. }
  99. }
  100. }
  101. #endregion
  102. #region On Security Check
  103. if (timing == EffectTiming.OnSecurityCheck)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("Play 1 [CS] Tamer", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  108. activateClass.SetHashString("BT22_080_Play_Tamer");
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. return "[Your Turn] [Once Per Turn] When this Digimon checks your opponent's security stack, you may play 1 Tamer card with the [CS] trait from your hand without paying the cost.";
  113. }
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  117. && CardEffectCommons.IsOwnerTurn(card);
  118. }
  119. bool CanActivateCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.IsExistOnBattleArea(card)
  122. && CardEffectCommons.HasMatchConditionOwnersHand(card, IsCSTamer);
  123. }
  124. bool IsCSTamer(CardSource cardSource)
  125. {
  126. return cardSource.IsTamer
  127. && cardSource.HasCSTraits
  128. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  129. }
  130. IEnumerator ActivateCoroutine(Hashtable hashtable)
  131. {
  132. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsCSTamer))
  133. {
  134. CardSource selectedCard = null;
  135. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsCSTamer));
  136. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  137. selectHandEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: IsCSTamer,
  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. IEnumerator SelectCardCoroutine(CardSource cardSource)
  151. {
  152. selectedCard = cardSource;
  153. yield return null;
  154. }
  155. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  156. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  157. yield return StartCoroutine(selectHandEffect.Activate());
  158. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  159. }
  160. }
  161. }
  162. #endregion
  163. #region ESS
  164. #region Reduce Cost Effect
  165. ActivateClass activateClass2 = new ActivateClass();
  166. activateClass2.SetUpICardEffect("Reduce play cost", CanUseCondition2, card);
  167. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, true, EffectDiscription2());
  168. activateClass2.SetHashString("Reduce_BT22_080");
  169. activateClass2.SetIsInheritedEffect(true);
  170. string EffectDiscription2()
  171. {
  172. return "[Breeding] [Your Turn] [Once Per Turn] When any of your Digimon cards with the [Eater] trait would be played, you may reduce the play costs by 1.";
  173. }
  174. bool CardCondition(CardSource cardSource)
  175. {
  176. if (cardSource.Owner == card.Owner)
  177. {
  178. if (cardSource.IsDigimon)
  179. {
  180. if (cardSource.HasEaterTraits)
  181. {
  182. return true;
  183. }
  184. }
  185. }
  186. return false;
  187. }
  188. bool CanUseCondition2(Hashtable hashtable)
  189. {
  190. if (CardEffectCommons.IsExistOnBreedingArea(card))
  191. {
  192. if (CardEffectCommons.IsOwnerTurn(card))
  193. {
  194. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  195. {
  196. return true;
  197. }
  198. }
  199. }
  200. return false;
  201. }
  202. bool CanActivateCondition2(Hashtable hashtable)
  203. {
  204. if (CardEffectCommons.IsExistOnBreedingArea(card))
  205. {
  206. PlayCardClass playCardClass = CardEffectCommons.GetPlayCardClassFromHashtable(hashtable);
  207. if (playCardClass != null)
  208. {
  209. if (playCardClass.PayCost)
  210. {
  211. return true;
  212. }
  213. }
  214. }
  215. return false;
  216. }
  217. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  218. {
  219. if (CardEffectCommons.IsExistOnBreedingArea(card))
  220. {
  221. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  222. ChangeCostClass changeCostClass = new ChangeCostClass();
  223. changeCostClass.SetUpICardEffect($"Play Cost -1", CanUseCondition1, card);
  224. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  225. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  226. yield return new WaitForSeconds(0.4f);
  227. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  228. bool CanUseCondition1(Hashtable hashtable)
  229. {
  230. return true;
  231. }
  232. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  233. {
  234. if (CardSourceCondition(cardSource))
  235. {
  236. if (RootCondition(root))
  237. {
  238. if (PermanentsCondition(targetPermanents))
  239. {
  240. Cost -= 1;
  241. }
  242. }
  243. }
  244. return Cost;
  245. }
  246. bool PermanentsCondition(List<Permanent> targetPermanents)
  247. {
  248. if (targetPermanents == null)
  249. {
  250. return true;
  251. }
  252. else
  253. {
  254. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  255. {
  256. return true;
  257. }
  258. }
  259. return false;
  260. }
  261. bool CardSourceCondition(CardSource cardSource)
  262. {
  263. CardSource Card = CardEffectCommons.GetCardFromHashtable(_hashtable);
  264. if (Card != null)
  265. {
  266. if (cardSource == Card)
  267. {
  268. return true;
  269. }
  270. }
  271. return false;
  272. }
  273. bool RootCondition(SelectCardEffect.Root root)
  274. {
  275. return true;
  276. }
  277. bool isUpDown()
  278. {
  279. return true;
  280. }
  281. }
  282. }
  283. #endregion
  284. #region Before Pay Cost
  285. if (timing == EffectTiming.BeforePayCost)
  286. {
  287. cardEffects.Add(activateClass2);
  288. }
  289. #endregion
  290. #region Before Pay Cost (Not Shown)
  291. if (timing == EffectTiming.None)
  292. {
  293. ChangeCostClass changeCostClass = new ChangeCostClass();
  294. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card);
  295. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  296. changeCostClass.SetNotShowUI(true);
  297. cardEffects.Add(changeCostClass);
  298. bool CanUseCondition(Hashtable hashtable)
  299. {
  300. if (!card.Owner.isYou && GManager.instance.IsAI)
  301. {
  302. return false;
  303. }
  304. if (CardEffectCommons.IsExistOnBreedingArea(card))
  305. {
  306. if (CardEffectCommons.IsOwnerTurn(card))
  307. {
  308. if (activateClass2 != null)
  309. {
  310. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  311. {
  312. return true;
  313. }
  314. }
  315. }
  316. }
  317. return false;
  318. }
  319. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  320. {
  321. if (CardSourceCondition(cardSource))
  322. {
  323. if (RootCondition(root))
  324. {
  325. if (PermanentsCondition(targetPermanents))
  326. {
  327. Cost -= 1;
  328. }
  329. }
  330. }
  331. return Cost;
  332. }
  333. bool PermanentsCondition(List<Permanent> targetPermanents)
  334. {
  335. if (targetPermanents == null)
  336. {
  337. return true;
  338. }
  339. else
  340. {
  341. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  342. {
  343. return true;
  344. }
  345. }
  346. return false;
  347. }
  348. bool CardSourceCondition(CardSource cardSource)
  349. {
  350. if (cardSource.IsDigimon)
  351. {
  352. if (cardSource.HasEaterTraits)
  353. {
  354. return true;
  355. }
  356. }
  357. return false;
  358. }
  359. bool RootCondition(SelectCardEffect.Root root)
  360. {
  361. return true;
  362. }
  363. bool isUpDown()
  364. {
  365. return true;
  366. }
  367. }
  368. #endregion
  369. #endregion
  370. return cardEffects;
  371. }
  372. }
  373. }