print version on startup, and whether the game has loaded

This commit is contained in:
Nicole O'Connor 2023-02-27 17:12:27 -08:00
parent fbf8830b31
commit e3d022df68
2 changed files with 13 additions and 4 deletions

View File

@ -36,7 +36,7 @@ def render_base_context():
base_context["scripts"] = ["https://cdn.otl-hga.net/seagull/js/seagull.js"]
base_context["seagull_pic"] = "https://cdn.otl-hga.net/seagull/image/seagull.jpg"
else: # dev, serve files from here
print(base_domain)
#print(base_domain)
base_context["styles"] = [app.url_for("static", filename="css/seagull.css")]
base_context["scripts"] = [app.url_for("static", filename="js/seagull.js")]
base_context["seagull_pic"] = app.url_for("static", filename="image/seagull.jpg")

View File

@ -1,3 +1,6 @@
const ver_numeric = 0;
const ver_string = "pre alpha";
const sleep = ms => new Promise(r => setTimeout(r, ms)); // sleep(int ms)
var page_elements = {};
@ -16,8 +19,14 @@ const gamestate_default = {
function prepare_gamestate() {
var gamestate_loaded = window.localStorage.getItem("gamestate");
if (gamestate_loaded == null) { gamestate = structuredClone(gamestate_default); }
else { gamestate = JSON.parse(gamestate_loaded); }
if (gamestate_loaded == null) {
record_log("Welcome to Seagull Game! We haven't found a save in your browser storage, so we're starting a new game!");
gamestate = structuredClone(gamestate_default);
}
else {
gamestate = JSON.parse(gamestate_loaded);
record_log("Welcome back! Game loaded.")
}
}
function record_log(text) {
@ -95,7 +104,7 @@ document.addEventListener("DOMContentLoaded", function (ev) {
prepare_gamestate();
record_log("It works!");
record_log("seagull game ver. " + ver_string);
page_elements["lbl_name"].innerHTML = gamestate["name"];
page_elements["lbl_tick"].innerHTML = gamestate["tick"];