diff --git a/server/src/rooms/sologame/commands.ts b/server/src/rooms/sologame/commands.ts index ba508f9fe..c2e76fd52 100644 --- a/server/src/rooms/sologame/commands.ts +++ b/server/src/rooms/sologame/commands.ts @@ -253,13 +253,18 @@ export class DrawCardsCmd extends CmdWithoutPayload { } } -export class InvestCmd extends Cmd<{ systemHealthInvestment: number }> { +export class InvestCmd extends Cmd<{ systemHealthInvestment: number; clockRanOut?: boolean }> { validate({ systemHealthInvestment } = this.payload) { return this.state.canInvest && systemHealthInvestment <= this.state.resources; } - async execute({ systemHealthInvestment } = this.payload) { - const surplus = this.state.resources - systemHealthInvestment; + async execute({ systemHealthInvestment, clockRanOut } = this.payload) { + let surplus = 0; + // if the clock ran out (as opposed to player-triggered investment), they get + // 0 points and 0 system health + if (!clockRanOut) { + surplus = this.state.resources - systemHealthInvestment; + } this.state.systemHealth = Math.min( this.defaultParams.systemHealthMax, this.state.systemHealth + systemHealthInvestment diff --git a/server/src/rooms/sologame/index.ts b/server/src/rooms/sologame/index.ts index bc8fe381d..63597dade 100644 --- a/server/src/rooms/sologame/index.ts +++ b/server/src/rooms/sologame/index.ts @@ -36,12 +36,11 @@ export class SoloGameRoom extends Room { this.state.timeRemaining -= 1; } else if (!this.state.isRoundTransitioning) { this.dispatcher.dispatch( - new PersistRoundCmd().setPayload({ + new InvestCmd().setPayload({ systemHealthInvestment: 0, - pointsInvestment: 0, + clockRanOut: true, }) ); - this.dispatcher.dispatch(new SetNextRoundCmd()); } }, 1000); } diff --git a/server/src/services/study.ts b/server/src/services/study.ts index b81399793..7faf50b20 100644 --- a/server/src/services/study.ts +++ b/server/src/services/study.ts @@ -187,8 +187,10 @@ export class StudyService extends BaseService { p => p.prolificBaselinePlayer?.game && p.prolificVariablePlayer?.game && - p.prolificBaselinePlayer.points && - p.prolificVariablePlayer.points + p.prolificBaselinePlayer.points !== null && + p.prolificBaselinePlayer.points !== undefined && + p.prolificVariablePlayer.points !== null && + p.prolificVariablePlayer.points !== undefined ) // return an array of prolificId and total points earned, if they lost they get 0 points .map(p => {