From f92711f71402c3040fa7bea0560b8e2a4361e6b5 Mon Sep 17 00:00:00 2001 From: SpacialCircumstances Date: Tue, 9 Jul 2024 21:14:03 +0200 Subject: [PATCH 1/2] Fix validation --- server/api/requests/star.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/api/requests/star.ts b/server/api/requests/star.ts index 12912f560..4b0e4be90 100644 --- a/server/api/requests/star.ts +++ b/server/api/requests/star.ts @@ -97,10 +97,6 @@ export const mapToScheduledStarUpgradeInfrastructureBulkRequest = (body: any): S errors.push('Tick is required.'); } - if (errors.length) { - throw new ValidationError(errors); - } - body.amount = +body.amount; body.tick = +body.tick; @@ -112,6 +108,10 @@ export const mapToScheduledStarUpgradeInfrastructureBulkRequest = (body: any): S errors.push('Tick must be greater than 0.'); } + if (errors.length) { + throw new ValidationError(errors); + } + return { infrastructureType: body.infrastructureType, buyType: body.buyType, From f0fa484631e7a499271c64ddb8b2250f01fb34c4 Mon Sep 17 00:00:00 2001 From: SpacialCircumstances Date: Tue, 9 Jul 2024 21:54:59 +0200 Subject: [PATCH 2/2] Fix calculation of cycle start and end for scheduled bulk upgrades --- .../game/components/star/BulkInfrastructureUpgrade.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/views/game/components/star/BulkInfrastructureUpgrade.vue b/client/src/views/game/components/star/BulkInfrastructureUpgrade.vue index 0b146c170..5aa79d572 100644 --- a/client/src/views/game/components/star/BulkInfrastructureUpgrade.vue +++ b/client/src/views/game/components/star/BulkInfrastructureUpgrade.vue @@ -304,11 +304,13 @@ export default { if (this.selectedScheduleStrategy === 'cycle-end') { const cycleTicks = this.$store.state.game.settings.galaxy.productionTicks; const currentTick = this.$store.state.game.state.tick; - this.tick = Math.ceil(currentTick / cycleTicks) * cycleTicks - 1; + const cycle = Math.ceil(Math.max(currentTick / cycleTicks, 1)); + this.tick = cycle * cycleTicks - 1; } else if (this.selectedScheduleStrategy === 'cycle-start') { const cycleTicks = this.$store.state.game.settings.galaxy.productionTicks; const currentTick = this.$store.state.game.state.tick; - this.tick = Math.ceil(currentTick / cycleTicks) * cycleTicks; + const cycle = Math.ceil(Math.max(currentTick / cycleTicks, 1)); + this.tick = cycle * cycleTicks; } // When actions are scheduled in the future, they get added to the scheduled list.