diff --git a/src/system/game-data.ts b/src/system/game-data.ts index e7bc85d9037..d10d6288696 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -635,13 +635,13 @@ export class GameData { async saveRunHistory(scene: BattleScene, runEntry : SessionSaveData, isVictory: boolean): Promise { const runHistoryData = await this.getRunHistoryData(scene); // runHistoryData should always return run history or {} empty object - const timestamps = Object.keys(runHistoryData); - const timestampsNo = timestamps.map(Number); + let timestamps = Object.keys(runHistoryData).map(Number); // Arbitrary limit of 25 entries per user --> Can increase or decrease while (timestamps.length >= RUN_HISTORY_LIMIT ) { - const oldestTimestamp = Math.min.apply(Math, timestampsNo); + const oldestTimestamp = (Math.min.apply(Math, timestamps)).toString(); delete runHistoryData[oldestTimestamp]; + timestamps = Object.keys(runHistoryData).map(Number); } const timestamp = (runEntry.timestamp).toString();