mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-22 04:56:15 -04:00
Build 29060103
This commit is contained in:
parent
a215237c17
commit
b46f745310
8 changed files with 74 additions and 23 deletions
|
@ -1,5 +1,5 @@
|
|||
// The version of the cache.
|
||||
const VERSION = "29060048";
|
||||
const VERSION = "29060103";
|
||||
|
||||
// The name of the cache
|
||||
const CACHE_NAME = `breakout-71-${VERSION}`;
|
||||
|
|
|
@ -1 +1 @@
|
|||
"29060048"
|
||||
"29060103"
|
||||
|
|
|
@ -69,6 +69,7 @@ import { helpMenuEntry } from "./help";
|
|||
import { creativeMode } from "./creative";
|
||||
import { setupTooltips } from "./tooltip";
|
||||
import { startingPerkMenuButton } from "./startingPerks";
|
||||
import "./migrations";
|
||||
|
||||
export async function play() {
|
||||
if (await applyFullScreenChoice()) return;
|
||||
|
|
|
@ -268,11 +268,3 @@ export function highScoreForMode(mode: GameState["mode"]) {
|
|||
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
const old = localStorage.getItem("breakout-3-hs");
|
||||
if (old) {
|
||||
localStorage.setItem("breakout-3-hs-short", old);
|
||||
localStorage.removeItem("breakout-3-hs");
|
||||
}
|
||||
} catch (e) {}
|
||||
|
|
37
src/migrations.ts
Normal file
37
src/migrations.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { RunHistoryItem } from "./types";
|
||||
|
||||
function migrate(name: string, cb: () => void) {
|
||||
if (!localStorage.getItem(name)) {
|
||||
try {
|
||||
cb();
|
||||
console.debug("Ran migration : " + name);
|
||||
localStorage.setItem(name, "" + Date.now());
|
||||
} catch (e) {
|
||||
console.warn("Migration " + name + " failed : ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
migrate("migrate_high_scores", () => {
|
||||
const old = localStorage.getItem("breakout-3-hs");
|
||||
if (old) {
|
||||
localStorage.setItem("breakout-3-hs-short", old);
|
||||
localStorage.removeItem("breakout-3-hs");
|
||||
}
|
||||
});
|
||||
migrate("recover_high_scores", () => {
|
||||
let runsHistory = JSON.parse(
|
||||
localStorage.getItem("breakout_71_runs_history") || "[]",
|
||||
) as RunHistoryItem[];
|
||||
runsHistory.forEach((r) => {
|
||||
const currentHS = parseInt(
|
||||
localStorage.getItem("breakout-3-hs-" + (r.mode || "short")) || "0",
|
||||
);
|
||||
if (r.score > currentHS) {
|
||||
localStorage.setItem(
|
||||
"breakout-3-hs-" + (r.mode || "short"),
|
||||
"" + r.score,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue