desktop support

This commit is contained in:
2025-07-29 12:50:35 -07:00
parent b08eab62cc
commit 68ef7c1591
23 changed files with 385 additions and 61 deletions

View File

@@ -7,7 +7,11 @@ import flask
from . import core
def generate_flavor_text():
proc_rant = subprocess.run(["rant", "/app/rant/flavor.rant"], capture_output=True)
if core.desktop_mode:
rant_path = core.path_appdir / "opt/rant/bin/rant"
else:
rant_path = "rant" # rely on OS PATH
proc_rant = subprocess.run([rant_path, (core.path_appdir / "rant/flavor.rant").as_posix()], capture_output=True)
return proc_rant.stdout.decode()
class TickEvent(object):
@@ -36,11 +40,13 @@ def tick():
result["event_type"] = random.choices(ticktypes, weights=tickweights)[0]
match result["event_type"]:
case 0:
pass
case 1: # FLAVOR
result["log"] = generate_flavor_text()
case 10: # ENCHUMAN
result["items"] = [] # TODO: implement items
result["items"] = {} # TODO: implement items
case _:
print("undefined tick: {0}".format(result["event_type"]))
core.log.warning("undefined tick: {0}".format(result["event_type"]))
return flask.Response(json.dumps(result), status=200, content_type="application/json")