From d782cb419d792b50697b81530e4e659c56a74d1d Mon Sep 17 00:00:00 2001 From: sgfost Date: Tue, 5 Nov 2024 14:54:32 -0700 Subject: [PATCH] fix: degrade system health at the end of a round instead of the start 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 --- server/src/rooms/sologame/commands.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/src/rooms/sologame/commands.ts b/server/src/rooms/sologame/commands.ts index 6cacdeca0..d767beef5 100644 --- a/server/src/rooms/sologame/commands.ts +++ b/server/src/rooms/sologame/commands.ts @@ -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, @@ -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;