Zones instead of road timers: journeys, flights, meeting stone
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7150b2f89c
commit
0e396ee5d4
7 changed files with 363 additions and 230 deletions
15
app.py
15
app.py
|
|
@ -59,7 +59,7 @@ class Store:
|
|||
with closing(sqlite3.connect(path)) as db, db:
|
||||
db.execute("CREATE TABLE IF NOT EXISTS world (id INTEGER PRIMARY KEY CHECK (id = 1), data TEXT NOT NULL)")
|
||||
row = db.execute("SELECT data FROM world WHERE id = 1").fetchone()
|
||||
self.world = json.loads(row[0]) if row else game.new_world(time.time())
|
||||
self.world = game.migrate(json.loads(row[0])) if row else game.new_world(time.time())
|
||||
self.world["config"]["dev"] = dev
|
||||
self.save()
|
||||
|
||||
|
|
@ -99,7 +99,8 @@ def static_content() -> dict:
|
|||
referenced.update(quest.get("choice", []))
|
||||
return {
|
||||
"classes": content.CLASSES, "specs": content.SPECS, "abilities": content.ABILITIES, "unlock": content.UNLOCK,
|
||||
"places": content.PLACES, "quests": content.QUESTS, "dungeons": content.DUNGEONS,
|
||||
"places": content.PLACES, "zones": content.ZONES, "roads": content.ROADS, "flight_cost": content.FLIGHT_COST,
|
||||
"quests": content.QUESTS, "dungeons": content.DUNGEONS,
|
||||
"mobs": {k: {"name": m["name"], "lv": m["lv"], "rare": m.get("rare", False), "boss": m.get("boss", False),
|
||||
"elite": m.get("elite", False)} for k, m in content.MOBS.items()},
|
||||
"enemy_abilities": content.ENEMY_ABILITIES, "slots": content.SLOTS, "slot_names": content.SLOT_NAMES,
|
||||
|
|
@ -115,7 +116,7 @@ CONTENT = json.dumps(static_content(), separators=(",", ":")).encode()
|
|||
def player_view(world: dict, player: dict, now: float) -> dict:
|
||||
st = game.stats(player)
|
||||
hp, mana = game.hp_now(player, now)
|
||||
view = {key: player[key] for key in ("id", "name", "cls", "level", "xp", "copper", "place", "activity",
|
||||
view = {key: player[key] for key in ("id", "name", "cls", "level", "xp", "copper", "place", "zones", "activity",
|
||||
"quests", "done", "manual", "group", "dead_until", "next_pull")}
|
||||
view["hp"], view["mana"] = round(hp), round(mana, 3)
|
||||
view["stats"] = st
|
||||
|
|
@ -290,8 +291,10 @@ class Handler(BaseHTTPRequestHandler):
|
|||
return game.start_hunt(world, player, arg, now)
|
||||
if path == "/api/stop":
|
||||
return game.stop(world, player, now)
|
||||
if path == "/api/travel":
|
||||
return game.travel(world, player, arg, now)
|
||||
if path == "/api/journey":
|
||||
return game.journey(world, player, arg, now)
|
||||
if path == "/api/fly":
|
||||
return game.fly(world, player, arg, now)
|
||||
if path == "/api/equip":
|
||||
return game.equip(player, arg)
|
||||
if path == "/api/unequip":
|
||||
|
|
@ -351,6 +354,8 @@ class Handler(BaseHTTPRequestHandler):
|
|||
return "No such place"
|
||||
game.stop(world, player, now)
|
||||
player["place"] = str(body["id"])
|
||||
if game.zone_of(player["place"]) not in player["zones"]:
|
||||
player["zones"].append(game.zone_of(player["place"]))
|
||||
return None
|
||||
return "Not found"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue