BT23_073.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. //Eater Bit
  7. namespace DCGO.CardEffects.BT23
  8. {
  9. public class BT23_073 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region On Play
  15. if (timing == EffectTiming.OnEnterFieldAnyone)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Delete 1 level 3 Digimon", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[On Play] Delete 1 of your opponent's level 3 Digimon.";
  24. }
  25. bool CanSelectPermanentCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  28. {
  29. if (permanent.Level == 3)
  30. {
  31. if (permanent.TopCard.HasLevel)
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  57. {
  58. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  59. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  60. selectPermanentEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: CanSelectPermanentCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: maxCount,
  66. canNoSelect: false,
  67. canEndNotMax: false,
  68. selectPermanentCoroutine: null,
  69. afterSelectPermanentCoroutine: null,
  70. mode: SelectPermanentEffect.Mode.Destroy,
  71. cardEffect: activateClass);
  72. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  73. }
  74. }
  75. }
  76. #endregion
  77. #region All Turns
  78. if (timing == EffectTiming.WhenRemoveField)
  79. {
  80. List<Permanent> wouldBeRemovedPermaments = new List<Permanent>();
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("Prevent a Digimon from leaving battle area", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  84. activateClass.SetHashString("Substitute_BT23_073");
  85. cardEffects.Add(activateClass);
  86. string EffectDiscription()
  87. {
  88. return "[All Turns] [Once Per Turn] When any of your other Digimon with the [Eater] or [Hudie] trait would leave the battle area, by deleting this Digimon or placing it as the bottom digivolution card of your [Mother Eater] in the breeding area, 1 of those Digimon doesn't leave.";
  89. }
  90. bool RemovedFromPlayPermanent(Permanent permanent)
  91. {
  92. wouldBeRemovedPermaments.Add(permanent);
  93. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  94. && (permanent.TopCard.HasEaterTraits || permanent.TopCard.HasHudieTraits)
  95. && permanent != card.PermanentOfThisCard())
  96. {
  97. wouldBeRemovedPermaments.Add(permanent);
  98. return true;
  99. }
  100. return false;
  101. }
  102. bool HasMother(Permanent permanent)
  103. {
  104. return CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card) &&
  105. permanent.TopCard.EqualsCardName("Mother Eater");
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  110. CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, RemovedFromPlayPermanent);
  111. }
  112. bool CanActivateCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  115. }
  116. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  117. {
  118. bool canAddSource = CardEffectCommons.HasMatchConditionOwnersBreedingPermanent(card, HasMother);
  119. bool canDestroy = card.PermanentOfThisCard().CanBeDestroyed();
  120. if (canAddSource || canDestroy)
  121. {
  122. bool willDestroy = false;
  123. if (canAddSource && canDestroy)
  124. {
  125. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  126. {
  127. new SelectionElement<bool>(message: $"Delete", value : true, spriteIndex: 0),
  128. new SelectionElement<bool>(message: $"Add to Sources", value : false, spriteIndex: 1),
  129. };
  130. string selectPlayerMessage = "Will you delete or add to sources?";
  131. string notSelectPlayerMessage = "The opponent is choosing whether to delete or add to sources.";
  132. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  133. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  134. willDestroy = GManager.instance.userSelectionManager.SelectedBoolValue;
  135. }
  136. else
  137. {
  138. willDestroy = canDestroy;
  139. }
  140. if (willDestroy)
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(
  143. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  144. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  145. activateClass: activateClass,
  146. successProcess: permanents => SuccessProcess(),
  147. failureProcess: null));
  148. }
  149. else
  150. {
  151. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { card.PermanentOfThisCard(), card.Owner.GetBreedingAreaPermanents()[0] } }, false, activateClass).PlacePermanentToDigivolutionCards());
  152. yield return ContinuousController.instance.StartCoroutine(SuccessProcess());
  153. }
  154. IEnumerator SuccessProcess()
  155. {
  156. Permanent selectedPermanent = wouldBeRemovedPermaments[0];
  157. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  158. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(perm => wouldBeRemovedPermaments.Contains(perm)));
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: perm => wouldBeRemovedPermaments.Contains(perm),
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: false,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: SelectPermanentCoroutine,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  172. {
  173. selectedPermanent = permanent;
  174. yield return null;
  175. }
  176. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will not be removed from battle area.", "The opponent is selecting 1 Digimon that will not be removed from battle area.");
  177. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  178. if (selectedPermanent != null)
  179. {
  180. selectedPermanent.willBeRemoveField = false;
  181. selectedPermanent.HideDeleteEffect();
  182. selectedPermanent.HideHandBounceEffect();
  183. selectedPermanent.HideDeckBounceEffect();
  184. selectedPermanent.HideWillRemoveFieldEffect();
  185. yield return null;
  186. }
  187. }
  188. }
  189. }
  190. }
  191. #endregion
  192. #region ESS
  193. #region Reduce Cost Effect
  194. ActivateClass activateClass2 = new ActivateClass();
  195. activateClass2.SetUpICardEffect("Reduce play cost", CanUseCondition2, card);
  196. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, true, EffectDiscription2());
  197. activateClass2.SetHashString("Reduce_BT22_079");
  198. activateClass2.SetIsInheritedEffect(true);
  199. string EffectDiscription2()
  200. {
  201. 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.";
  202. }
  203. bool CardCondition(CardSource cardSource)
  204. {
  205. if (cardSource.Owner == card.Owner)
  206. {
  207. if (cardSource.IsDigimon)
  208. {
  209. if (cardSource.HasEaterTraits)
  210. {
  211. return true;
  212. }
  213. }
  214. }
  215. return false;
  216. }
  217. bool CanUseCondition2(Hashtable hashtable)
  218. {
  219. if (CardEffectCommons.IsExistOnBreedingArea(card))
  220. {
  221. if (CardEffectCommons.IsOwnerTurn(card))
  222. {
  223. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  224. {
  225. return true;
  226. }
  227. }
  228. }
  229. return false;
  230. }
  231. bool CanActivateCondition2(Hashtable hashtable)
  232. {
  233. if (CardEffectCommons.IsExistOnBreedingArea(card))
  234. {
  235. PlayCardClass playCardClass = CardEffectCommons.GetPlayCardClassFromHashtable(hashtable);
  236. if (playCardClass != null)
  237. {
  238. if (playCardClass.PayCost)
  239. {
  240. return true;
  241. }
  242. }
  243. }
  244. return false;
  245. }
  246. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  247. {
  248. if (CardEffectCommons.IsExistOnBreedingArea(card))
  249. {
  250. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  251. ChangeCostClass changeCostClass = new ChangeCostClass();
  252. changeCostClass.SetUpICardEffect($"Play Cost -1", CanUseCondition1, card);
  253. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  254. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  255. yield return new WaitForSeconds(0.4f);
  256. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  257. bool CanUseCondition1(Hashtable hashtable)
  258. {
  259. return true;
  260. }
  261. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  262. {
  263. if (CardSourceCondition(cardSource))
  264. {
  265. if (RootCondition(root))
  266. {
  267. if (PermanentsCondition(targetPermanents))
  268. {
  269. Cost -= 1;
  270. }
  271. }
  272. }
  273. return Cost;
  274. }
  275. bool PermanentsCondition(List<Permanent> targetPermanents)
  276. {
  277. if (targetPermanents == null)
  278. {
  279. return true;
  280. }
  281. else
  282. {
  283. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  284. {
  285. return true;
  286. }
  287. }
  288. return false;
  289. }
  290. bool CardSourceCondition(CardSource cardSource)
  291. {
  292. CardSource Card = CardEffectCommons.GetCardFromHashtable(_hashtable);
  293. if (Card != null)
  294. {
  295. if (cardSource == Card)
  296. {
  297. return true;
  298. }
  299. }
  300. return false;
  301. }
  302. bool RootCondition(SelectCardEffect.Root root)
  303. {
  304. return true;
  305. }
  306. bool isUpDown()
  307. {
  308. return true;
  309. }
  310. }
  311. }
  312. #endregion
  313. #region Before Pay Cost
  314. if (timing == EffectTiming.BeforePayCost)
  315. {
  316. cardEffects.Add(activateClass2);
  317. }
  318. #endregion
  319. #region Before Pay Cost (Not Shown)
  320. if (timing == EffectTiming.None)
  321. {
  322. ChangeCostClass changeCostClass = new ChangeCostClass();
  323. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card);
  324. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  325. changeCostClass.SetNotShowUI(true);
  326. cardEffects.Add(changeCostClass);
  327. bool CanUseCondition(Hashtable hashtable)
  328. {
  329. if (!card.Owner.isYou && GManager.instance.IsAI)
  330. {
  331. return false;
  332. }
  333. if (CardEffectCommons.IsExistOnBreedingArea(card))
  334. {
  335. if (CardEffectCommons.IsOwnerTurn(card))
  336. {
  337. if (activateClass2 != null)
  338. {
  339. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  340. {
  341. return true;
  342. }
  343. }
  344. }
  345. }
  346. return false;
  347. }
  348. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  349. {
  350. if (CardSourceCondition(cardSource))
  351. {
  352. if (RootCondition(root))
  353. {
  354. if (PermanentsCondition(targetPermanents))
  355. {
  356. Cost -= 1;
  357. }
  358. }
  359. }
  360. return Cost;
  361. }
  362. bool PermanentsCondition(List<Permanent> targetPermanents)
  363. {
  364. if (targetPermanents == null)
  365. {
  366. return true;
  367. }
  368. else
  369. {
  370. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  371. {
  372. return true;
  373. }
  374. }
  375. return false;
  376. }
  377. bool CardSourceCondition(CardSource cardSource)
  378. {
  379. if (cardSource.IsDigimon)
  380. {
  381. if (cardSource.HasEaterTraits)
  382. {
  383. return true;
  384. }
  385. }
  386. return false;
  387. }
  388. bool RootCondition(SelectCardEffect.Root root)
  389. {
  390. return true;
  391. }
  392. bool isUpDown()
  393. {
  394. return true;
  395. }
  396. }
  397. #endregion
  398. #endregion
  399. return cardEffects;
  400. }
  401. }
  402. }