giant freakin documentation and reorganization pass, it also uses cmake because all the building was getting too complicated for shell scripts
This commit is contained in:
@@ -5,7 +5,7 @@ import subprocess
|
||||
|
||||
import flask
|
||||
|
||||
from . import core, items, jsonizer
|
||||
from . import core, gamedata, items, jsonizer
|
||||
|
||||
rant_env = os.environ.copy()
|
||||
rant_env["RANT_MODULES_PATH"] = (core.path_appdir / "basepak/rant").as_posix()
|
||||
@@ -15,7 +15,8 @@ def generate_flavor_text():
|
||||
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 / "basepak/rant/flavor.rant").as_posix()], env=rant_env, capture_output=True)
|
||||
flavor_file = gamedata.vfs.copy_out("rant/flavor.rant")
|
||||
proc_rant = subprocess.run([rant_path, flavor_file], env=rant_env, capture_output=True)
|
||||
return proc_rant.stdout.decode()
|
||||
|
||||
class TickEvent(object):
|
||||
@@ -30,6 +31,9 @@ tick_event_list.append(TickEvent(1, 1, "FLAVOR")) # procedurally generated
|
||||
tick_event_list.append(TickEvent(10, 2, "ENCHUMAN")) # encounter: human
|
||||
tick_event_list.append(TickEvent(11, 2, "ENCGULL"))
|
||||
|
||||
## \brief Returns the results of a game tick.
|
||||
# \api{GET} /tick
|
||||
# \return Game tick events and results.
|
||||
@core.app.route("/tick")
|
||||
def tick():
|
||||
#return random.choices([json.dumps({"code": 200, "event_type": 0}), json.dumps({"code": 200, "event_type": 1, "log": generate_flavor_text()})], weights=[16, 1])[0]
|
||||
@@ -67,10 +71,28 @@ def tick():
|
||||
|
||||
return flask.Response(json.dumps(result, cls=jsonizer.JSONizer), status=200, content_type="application/json")
|
||||
|
||||
## \brief Returns the results of a colony tick.
|
||||
# \api{GET} /tick/colony
|
||||
# \return The result of a colony tick.
|
||||
@core.app.route("/tick/colony", methods=["POST"])
|
||||
def tick_colony() -> flask.Response:
|
||||
req = flask.request.json
|
||||
if not req:
|
||||
return flask.make_response("Bad request", 400)
|
||||
|
||||
colony = req["colony"]
|
||||
modifiers = req["modifiers"]
|
||||
inc_food = req["avg_food"]
|
||||
inc_shinies = req["avg_shinies"]
|
||||
|
||||
out_food = (inc_food * 0.35) * (colony / 2)
|
||||
out_shinies = (inc_shinies * 0.25) * (colony / 3)
|
||||
|
||||
result = {
|
||||
"success": True,
|
||||
"food": out_food,
|
||||
"shinies": out_shinies
|
||||
}
|
||||
|
||||
return flask.Response(json.dumps(result, cls=jsonizer.JSONizer), status=200, content_type="application/json")
|
||||
|
Reference in New Issue
Block a user