seagull-game/static/js/seagull-desktop.js

39 lines
1.0 KiB
JavaScript
Raw Normal View History

2025-07-29 12:50:35 -07:00
var desktop_mode = true;
2025-07-31 11:28:09 -07:00
var tick_meter_running = false;
2025-07-29 12:50:35 -07:00
async function prepare_gamestate() {
var gamestate_loaded = null;
try {
gamestate_loaded = await window.pywebview.api.load_data("gamestate");
} catch (exc) {
console.error("no gamestate");
gamestate_loaded = null;
}
if (gamestate_loaded == null) {
record_log("Welcome to Seagull Game! We haven't found a save in your app data, so we're starting a new game!");
gamestate = structuredClone(gamestate_default);
}
else {
console.log(gamestate_loaded);
gamestate = JSON.parse(gamestate_loaded);
record_log("Welcome back! Game loaded.")
}
2025-07-31 11:28:09 -07:00
tick_meter_running = true;
2025-08-05 17:57:43 -07:00
if (window.pywebview.api.debug_mode) {
dev_toolbox(true);
}
2025-07-29 12:50:35 -07:00
}
function save_game() {
window.pywebview.api.save_data("gamestate", JSON.stringify(gamestate));
record_log("Game saved.");
}
function reset_game() {
tick_meter_running = false;
window.pywebview.api.delete_data("gamestate");
window.location.reload();
}