This commit is contained in:
2025-10-05 03:31:45 +02:00
parent c39ab3ac41
commit e9585f8570
3 changed files with 287 additions and 35 deletions
+9 -1
View File
@@ -113,9 +113,17 @@ async def websocket_endpoint(websocket: WebSocket, nickname: str):
player_id = await ws_manager.get_player_id(websocket)
if player_id:
player = game_state.get_or_create_player(nickname, player_id)
# Trigger economy update on login to ensure player stats are current
# This is especially important after server restarts
logger.info(f"Player {player_id} connected, triggering economy update to sync stats.")
await trigger_economy_update_and_save()
# Send updated player data after economy sync
updated_player = game_state.players.get(player_id, player)
await websocket.send_json({
"type": "init",
"player": player.to_dict(),
"player": updated_player.to_dict(),
"game_state": game_state.get_state()
})
while True: