Build 29068563

This commit is contained in:
Renan LE CARO 2025-04-08 14:03:38 +02:00
parent 6ef13f2d19
commit df8bfbb350
25 changed files with 384 additions and 336 deletions

View file

@ -2,8 +2,8 @@ import { RunHistoryItem } from "./types";
import _appVersion from "./data/version.json";
import { generateSaveFileContent } from "./generateSaveFileContent";
import {getLevelUnlockCondition, reasonLevelIsLocked} from "./game_utils";
import {allLevels} from "./loadGameData";
import { getLevelUnlockCondition, reasonLevelIsLocked } from "./game_utils";
import { allLevels } from "./loadGameData";
// The page will be reloaded if any migrations were run
let migrationsRun = 0;
@ -19,16 +19,16 @@ function migrate(name: string, cb: () => void) {
}
}
}
function afterMigration(){
// Avoid a boot loop by setting the hash before reloading
// We can't set the query string as it is used for other things
if (migrationsRun && !window.location.hash) {
window.location.hash = "#reloadAfterMigration";
window.location.reload();
}
if (!migrationsRun) {
window.location.hash = "";
}
function afterMigration() {
// Avoid a boot loop by setting the hash before reloading
// We can't set the query string as it is used for other things
if (migrationsRun && !window.location.hash) {
window.location.hash = "#reloadAfterMigration";
window.location.reload();
}
if (!migrationsRun) {
window.location.hash = "";
}
}
migrate("save_data_before_upgrade_to_" + _appVersion, () => {
@ -103,25 +103,27 @@ migrate("compact_runs_data", () => {
localStorage.setItem("breakout_71_runs_history", JSON.stringify(runsHistory));
});
migrate("set_breakout_71_unlocked_levels"+_appVersion, () => {
migrate("set_breakout_71_unlocked_levels" + _appVersion, () => {
// We want to lock any level unlocked by an app upgrade too
let runsHistory = JSON.parse(
let runsHistory = JSON.parse(
localStorage.getItem("breakout_71_runs_history") || "[]",
) as RunHistoryItem[];
let breakout_71_unlocked_levels = JSON.parse(
let breakout_71_unlocked_levels = JSON.parse(
localStorage.getItem("breakout_71_unlocked_levels") || "[]",
) as string[];
allLevels.filter((l,li)=>!reasonLevelIsLocked(li,runsHistory,false)).forEach(l=>{
if(!breakout_71_unlocked_levels.includes(l.name)){
breakout_71_unlocked_levels.push(l.name)
allLevels
.filter((l, li) => !reasonLevelIsLocked(li, runsHistory, false))
.forEach((l) => {
if (!breakout_71_unlocked_levels.includes(l.name)) {
breakout_71_unlocked_levels.push(l.name);
}
})
localStorage.setItem("breakout_71_unlocked_levels", JSON.stringify(breakout_71_unlocked_levels));
});
localStorage.setItem(
"breakout_71_unlocked_levels",
JSON.stringify(breakout_71_unlocked_levels),
);
});
afterMigration()
afterMigration();