From b960f99a7f3eaa249ffb79957ee4828475e44d4e Mon Sep 17 00:00:00 2001 From: Mike Rosack Date: Wed, 3 Jan 2024 12:30:20 -0600 Subject: [PATCH] only update first/last turn end dates when not skipping or undoing --- lib/util/statsUtil.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/util/statsUtil.ts b/lib/util/statsUtil.ts index cdb84bb..bccd3ec 100644 --- a/lib/util/statsUtil.ts +++ b/lib/util/statsUtil.ts @@ -57,20 +57,22 @@ export class StatsUtil { const undoInc = undo ? -1 : 1; if (gameTurn.endDate) { - if (!turnData.firstTurnEndDate || gameTurn.endDate < turnData.firstTurnEndDate) { - turnData.firstTurnEndDate = gameTurn.endDate; - } - - if (!turnData.lastTurnEndDate || gameTurn.endDate > turnData.lastTurnEndDate) { - turnData.lastTurnEndDate = gameTurn.endDate; - } - turnData.turnLengthBuckets = turnData.turnLengthBuckets || {}; turnData.yearBuckets = turnData.yearBuckets || {}; if (gameTurn.skipped) { turnData.turnsSkipped = (turnData.turnsSkipped || 0) + undoInc; } else { + if (!undo) { + if (!turnData.firstTurnEndDate || gameTurn.endDate < turnData.firstTurnEndDate) { + turnData.firstTurnEndDate = gameTurn.endDate; + } + + if (!turnData.lastTurnEndDate || gameTurn.endDate > turnData.lastTurnEndDate) { + turnData.lastTurnEndDate = gameTurn.endDate; + } + } + turnData.turnsPlayed = (turnData.turnsPlayed || 0) + undoInc; const timeTaken = gameTurn.endDate.getTime() - gameTurn.startDate.getTime();