Combat: refresh at every kill, seamless countdown to the next enemy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-20 12:54:42 +01:00
parent 35491c6f4d
commit 57bcd812ee
2 changed files with 26 additions and 21 deletions

3
app.py
View file

@ -113,6 +113,8 @@ def player_view(world: dict, player: dict, now: float) -> dict:
action, fight = game.growing(player), player["action"].get("fight")
duration = fight["duration"] if fight else game.action_time(world, player, action)
view["action"] = {**player["action"], "growing": action["id"], "duration": duration}
if fight:
view["action"]["respawn"] = game.RESPAWN / game.speed(world)
# A fight takes as long as it takes: show the average time to a kill.
view["times"] = {action["id"]: (view["fight_odds"][action["id"]]["kill_time"] + game.RESPAWN) / game.speed(world)
if "enemy" in action else game.action_time(world, player, action) for action in game.ACTIONS}
@ -289,6 +291,7 @@ class Handler(BaseHTTPRequestHandler):
player["last_active"] = now
error = self.player_route(path, player, body, now)
if error is None:
game.process_player(world, player, now, self.store.rng) # a new fight is drawn up at once
game.tick(world, now, self.store.rng)
self.store.save()
if error: