parent
35f522fd99
commit
781e25848d
|
@ -635,13 +635,13 @@ export class GameData {
|
||||||
async saveRunHistory(scene: BattleScene, runEntry : SessionSaveData, isVictory: boolean): Promise<boolean> {
|
async saveRunHistory(scene: BattleScene, runEntry : SessionSaveData, isVictory: boolean): Promise<boolean> {
|
||||||
const runHistoryData = await this.getRunHistoryData(scene);
|
const runHistoryData = await this.getRunHistoryData(scene);
|
||||||
// runHistoryData should always return run history or {} empty object
|
// runHistoryData should always return run history or {} empty object
|
||||||
const timestamps = Object.keys(runHistoryData);
|
let timestamps = Object.keys(runHistoryData).map(Number);
|
||||||
const timestampsNo = timestamps.map(Number);
|
|
||||||
|
|
||||||
// Arbitrary limit of 25 entries per user --> Can increase or decrease
|
// Arbitrary limit of 25 entries per user --> Can increase or decrease
|
||||||
while (timestamps.length >= RUN_HISTORY_LIMIT ) {
|
while (timestamps.length >= RUN_HISTORY_LIMIT ) {
|
||||||
const oldestTimestamp = Math.min.apply(Math, timestampsNo);
|
const oldestTimestamp = (Math.min.apply(Math, timestamps)).toString();
|
||||||
delete runHistoryData[oldestTimestamp];
|
delete runHistoryData[oldestTimestamp];
|
||||||
|
timestamps = Object.keys(runHistoryData).map(Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamp = (runEntry.timestamp).toString();
|
const timestamp = (runEntry.timestamp).toString();
|
||||||
|
|
Loading…
Reference in New Issue