Skip to content

Commit

Permalink
Merge pull request #1077 from solaris-games/fix/scheduled-upgrades-ne…
Browse files Browse the repository at this point in the history
…gative-tick

Fix scheduled upgrades negative tick
  • Loading branch information
SpacialCircumstances authored Jul 9, 2024
2 parents 4f03b57 + f0fa484 commit 5052f66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions server/api/requests/star.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down

0 comments on commit 5052f66

Please sign in to comment.