diff --git a/routes/api.py b/routes/api.py index 7de9525..4f7eb92 100644 --- a/routes/api.py +++ b/routes/api.py @@ -369,10 +369,13 @@ def command_result(cmd_id): # When an explicit farm_loot command succeeds, record the timestamp if cmd and cmd['type'] == 'farm_loot' and status == 'done' and cmd['player_id']: + town_id = str(cmd['town_id']) + world_id = town_id.split('_')[1] if '_' in town_id else None + lf_key = f'last_farmed_{cmd["player_id"]}_{world_id}' if world_id else f'last_farmed_{cmd["player_id"]}' conn.execute(''' INSERT INTO kv_store (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at - ''', (f'last_farmed_{cmd["player_id"]}', now, now)) + ''', (lf_key, now, now)) conn.commit() conn.close() @@ -456,7 +459,7 @@ def farm_status(): conn.execute(''' INSERT INTO kv_store (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at - ''', (f'last_farmed_{player_id}', now, now)) + ''', (f'last_farmed_{player_key}', now, now)) conn.commit() conn.close() return jsonify({'ok': True})