Skip to content

Commit

Permalink
fix: degrade system health at the end of a round instead of the start
Browse files Browse the repository at this point in the history
previously, system health would get subtracted at the start of each
round after the first, which led to the last round acting as a freebie

this maintains virtually the same gameplay and data recording, with the
exception of the final round

resolves #970
  • Loading branch information
sgfost committed Nov 5, 2024
1 parent e7e3512 commit d782cb4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions server/src/rooms/sologame/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ export class InvestCmd extends Cmd<{ systemHealthInvestment: number }> {
await new Promise(resolve =>
setTimeout(resolve, this.defaultParams.roundTransitionDuration * 1000)
);
this.state.systemHealth = Math.max(
0,
this.state.systemHealth - this.defaultParams.systemHealthWear
);
if (this.state.systemHealth <= 0) {
return new EndGameCmd().setPayload({ status: "defeat" });
}
return [
new PersistRoundCmd().setPayload({
systemHealthInvestment,
Expand Down Expand Up @@ -302,13 +309,8 @@ export class SetNextRoundCmd extends CmdWithoutPayload {
}

this.state.round += 1;
this.state.systemHealth = Math.max(0, this.state.systemHealth - defaults.systemHealthWear);
this.state.updateRoundInitialValues();

if (this.state.systemHealth <= 0) {
return new EndGameCmd().setPayload({ status: "defeat" });
}

this.state.player.resources = defaults.resources;
this.state.timeRemaining = defaults.timeRemaining;

Expand Down

0 comments on commit d782cb4

Please sign in to comment.