state sync

This commit is contained in:
2025-11-23 14:59:17 -08:00
parent 537bdf1ad7
commit 39f4a8d3fc
812 changed files with 373062 additions and 84 deletions

View File

@@ -7,7 +7,6 @@ from collections import namedtuple
import flask
import lxml.etree as xmltree
import mermaid
from . import core, gamedata, jsonizer, util
@@ -130,16 +129,19 @@ def get_upgrade_tree(tree):
buf_mmd.write(f" class {upgrade.id} unlocked\n")
else:
buf_mmd.write(f" class {upgrade.id} open\n")
buf_mmd.write(f" click {upgrade.id} call purchase_upgrade('{tree}','{upgrade.id}')\n")
buf_mmd.write(f" click {upgrade.id} call purchase_upgrade({tree},{upgrade.id})\n")
for line in dependency_lines:
buf_mmd.write(line)
buf_mmd.seek(0)
mmd_str = buf_mmd.read()
mmd_upgradetree = mermaid.Mermaid(mmd_str, height=400)
retval = flask.make_response(mmd_str, 200)
retval.headers["Content-Type"] = "text/plain"
return retval
#mmd_upgradetree = mermaid.Mermaid(mmd_str, height=400)
#print(mmd_str)
return mmd_upgradetree.svg_response.content
#return mmd_upgradetree.svg_response.content
@core.app.route("/upgrades/<tree>/<upgrade>")
def get_upgrade_data(tree, upgrade):
@@ -163,11 +165,26 @@ def get_upgrade_data(tree, upgrade):
hnd_food = hnd_requires.xpath("./upgrades:Food", namespaces=core.xml_namespaces)[0]
except IndexError:
hnd_food = None
try:
hnd_agility = hnd_requires.xpath("./upgrades:Agility", namespaces=core.xml_namespaces)[0]
except IndexError:
hnd_agility = None
try:
hnd_instinct = hnd_requires.xpath("./upgrades:Instinct", namespaces=core.xml_namespaces)[0]
except IndexError:
hnd_instinct = None
try:
hnd_leadership = hnd_requires.xpath("./upgrades:Leadership", namespaces=core.xml_namespaces)[0]
except IndexError:
hnd_leadership = None
try:
hnd_shinies = hnd_requires.xpath("./upgrades:Shinies", namespaces=core.xml_namespaces)[0]
except IndexError:
hnd_shinies = None
except IndexError:
hnd_agility = None
hnd_instinct = None
hnd_leadership = None
hnd_requires = None
hnd_shinies = None
hnd_food = None
@@ -177,15 +194,10 @@ def get_upgrade_data(tree, upgrade):
"id": hnd_id.text,
"name": hnd_name.text,
"desc": hnd_desc.text,
"food": int(hnd_food.text) if hnd_food else 0,
"shinies": int(hnd_shinies.text) if hnd_shinies else 0,
"food": int(hnd_food.text) if hnd_food is not None else 0,
"shinies": int(hnd_shinies.text) if hnd_shinies is not None else 0,
"agility": int(hnd_agility.text) if hnd_agility is not None else 0,
"instinct": int(hnd_instinct.text) if hnd_instinct is not None else 0,
"leadership": int(hnd_leadership.text) if hnd_leadership is not None else 0,
"requires": require_list
}, cls=jsonizer.JSONizer), 200)
def get_upgrade_tree_mmd(tree):
if not gamedata.vfs.exists(f"upgrades/{tree}.mmd"):
return flask.make_response("No Upgrade Tree", 404)
with gamedata.vfs.open(f"upgrades/{tree}.mmd") as fd_upgradetree:
mmd_upgradetree = mermaid.Mermaid(fd_upgradetree.read(), height=400)
return mmd_upgradetree.svg_response.content