From 621d65b9e5c4a185706d7e77788b888ab8cc8362 Mon Sep 17 00:00:00 2001 From: Nicole O'Connor Date: Fri, 22 Aug 2025 13:01:58 -0700 Subject: [PATCH] some work done on character sheets --- app/desktop.py | 1 + app/pylocal/core.py | 10 +++++++++- app/pylocal/items.py | 3 --- app/rules/schemas/catalog.xml | 1 + app/rules/schemas/upgrades.xsd | 32 ++++++++++++++++++++++++++++++ app/rules/upgrades/agility.xml | 19 ++++++++++++++++++ app/templates/charsheet.j2 | 20 +++++++++++++++++++ app/upgrades/agility.mmd | 12 ++++++++++++ static/css/seagull.css | 36 ++++++++++++++++++++++++++++++++++ static/js/seagull.js | 36 +++++++++++++++++++++++++++++++++- 10 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 app/rules/schemas/upgrades.xsd create mode 100644 app/rules/upgrades/agility.xml create mode 100644 app/templates/charsheet.j2 create mode 100644 app/upgrades/agility.mmd diff --git a/app/desktop.py b/app/desktop.py index d623af1..189df0a 100755 --- a/app/desktop.py +++ b/app/desktop.py @@ -33,6 +33,7 @@ if __name__ == "__main__": elif sys.platform.startswith("darwin"): # macos storage_dir = pathlib.Path(os.environ["HOME"]) / "Library/Application Support/seagull" else: + # TODO: check if XDG env vars are set and prioritize those storage_dir = pathlib.Path(os.environ["HOME"]) / ".local/share/seagull" desktop.path_storagedir = storage_dir diff --git a/app/pylocal/core.py b/app/pylocal/core.py index 0b80967..440aae3 100644 --- a/app/pylocal/core.py +++ b/app/pylocal/core.py @@ -22,7 +22,8 @@ app = flask.Flask("seagull-game", root_path=path_appdir) orig_url_for = app.url_for xml_namespaces = { - "items": "seagull:rules/items" + "items": "seagull:rules/items", + "upgrades": "seagull:rules/upgrades" } #REDIS_HOST="stub-implementation.example.net" @@ -45,6 +46,13 @@ app.url_for = url_for_override base_context = {} base_context_live = False +@app.route("/dialog/") +def render_dialog(dialog): + if os.path.exists(path_appdir / f"templates/{dialog}.j2"): + return flask.render_template(f"{dialog}.j2") + else: + return "", 404 + def render_base_context(): global base_context global base_context_live diff --git a/app/pylocal/items.py b/app/pylocal/items.py index 20ee43c..a1a55c6 100644 --- a/app/pylocal/items.py +++ b/app/pylocal/items.py @@ -6,9 +6,6 @@ import lxml.etree as xmltree from . import core -# NOTE: due to how XML libraries handle namespaces, you have to prepend "{seagull:rules/items}" to every tag value -# this is merely the price you pay for editor autocompletions - valid_resources = [ "food", "shinies", "psi" # early game ] diff --git a/app/rules/schemas/catalog.xml b/app/rules/schemas/catalog.xml index dfda357..3732d3f 100644 --- a/app/rules/schemas/catalog.xml +++ b/app/rules/schemas/catalog.xml @@ -1,4 +1,5 @@ + \ No newline at end of file diff --git a/app/rules/schemas/upgrades.xsd b/app/rules/schemas/upgrades.xsd new file mode 100644 index 0000000..31e7600 --- /dev/null +++ b/app/rules/schemas/upgrades.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/rules/upgrades/agility.xml b/app/rules/upgrades/agility.xml new file mode 100644 index 0000000..ce4f8c9 --- /dev/null +++ b/app/rules/upgrades/agility.xml @@ -0,0 +1,19 @@ + + + + speed1 + Speedier Seagull + + + + You become just a little bit faster, which makes it easier to steal things before your prey's previous owners notice you're coming. + + + theft_chance1 + Swooping Techniques + + + + It's all in the neck. The wings are just the steering wheel. You gain a bonus on all dice rolls for stealing. + + \ No newline at end of file diff --git a/app/templates/charsheet.j2 b/app/templates/charsheet.j2 new file mode 100644 index 0000000..4f51b38 --- /dev/null +++ b/app/templates/charsheet.j2 @@ -0,0 +1,20 @@ +
+
+ Agility: 0 +
+
+ Instinct: 0 +
+
+
+
+ +
+
+
+        
+
+
\ No newline at end of file diff --git a/app/upgrades/agility.mmd b/app/upgrades/agility.mmd new file mode 100644 index 0000000..abb86fb --- /dev/null +++ b/app/upgrades/agility.mmd @@ -0,0 +1,12 @@ +--- +title: Agility Upgrades +--- +flowchart LR + speed1["Speedier Seagull"] + speed2["Greased Wings"] + theft_chance1["Swooping Techniques"] + theft_chance2["The Element of Surprise"] + + speed1-->speed2 + theft_chance1-->speed1 + theft_chance1-->theft_chance2 \ No newline at end of file diff --git a/static/css/seagull.css b/static/css/seagull.css index 5fa8114..31c8b8d 100644 --- a/static/css/seagull.css +++ b/static/css/seagull.css @@ -4,6 +4,7 @@ div#root { display: flex; width: 100%; height: 100%; + z-index: 0; font-family: sans-serif; } @@ -73,4 +74,39 @@ div.log-tick { div.log-msg { margin-left: 0.2em; +} + +div#charsheet { + display: flex; + flex-direction: row; + width: 100%; + + background-color: rgb(240, 240, 240); +} + +div#charsheet-leftside { + display: flex; + flex-direction: column; +} + +div#charsheet-rightside { + display: flex; + flex-direction: column; +} + +div.attr { + font-size: larger; +} + +div#modal-background { + z-index: -10; + background-color: rgba(0, 0, 0, 168); + visibility: hidden; +} + +div#modal { + width: 90%; + height: 90%; + border: 1.25em double rgba(192, 192, 192, 255); + background-color: rgba(255, 255, 255, 255); } \ No newline at end of file diff --git a/static/js/seagull.js b/static/js/seagull.js index bcc4496..7fafefd 100644 --- a/static/js/seagull.js +++ b/static/js/seagull.js @@ -22,7 +22,9 @@ const gamestate_default = { "xp": 0, "xp_next": 50, "enc_human": "pause", - "enc_seagull": "pause" + "enc_seagull": "pause", + "agility": 0, + "instinct": 0 }; var bool_log_alt = false @@ -84,6 +86,38 @@ function record_log_with_choices() { tick_meter_running = false; } +var modal_dialog_open = false; +var dialog_queue = []; + +function modal_no_prop(event) { event.stopPropagation(); } + +async function open_modal_dialog(dialog) { + var modal_background = document.getElementById("modal-background"); + if (!modal_background) { + modal_background = document.createElement("div"); + modal_background.setAttribute("id", "modal-background"); + } + + var modal_root = document.getElementById("modal"); + if (!modal_root) { + modal_root = document.createElement("div"); + modal_root.setAttribute("id", "modal"); + modal_root.onclick = modal_no_prop; + modal_background.appendChild(modal_root); + } + + if (!modal_dialog_open) { + tick_meter_running = false; + modal_dialog_open = true; + modal_background.style = "z-index: 10 !important; visibility: visible !important;"; + } + + dialog_data = await fetch(`/dialog/${dialog}`) + .then(res => { return res.text(); }); + + modal_root.innerHTML = dialog_data; +} + function update_ui() { page_elements["lbl_name"].innerHTML = gamestate["name"]; page_elements["lbl_tick"].innerHTML = gamestate["tick"];