Add inline comments across client and server codebase
Full-codebase commenting pass focused on the tricky, fragile, and non-obvious spots: animation coordination flags in app.js, AI decision safety checks in ai.py, scoring evaluation order in game.py, animation engine magic numbers in card-animations.js, and server infrastructure coupling in main.py/handlers.py/room.py. No logic changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,9 @@ class Room:
|
||||
Returns:
|
||||
The created RoomPlayer object.
|
||||
"""
|
||||
# First player in becomes host. On reconnection, the player gets a new
|
||||
# connection_id, so they rejoin as a "new" player — host status may shift
|
||||
# if the original host disconnected and someone else was promoted.
|
||||
is_host = len(self.players) == 0
|
||||
room_player = RoomPlayer(
|
||||
id=player_id,
|
||||
@@ -173,7 +176,9 @@ class Room:
|
||||
if room_player.is_cpu:
|
||||
release_profile(room_player.name, self.code)
|
||||
|
||||
# Assign new host if needed
|
||||
# Assign new host if needed. next(iter(...)) gives us the first value in
|
||||
# insertion order (Python 3.7+ dict guarantee). This means the longest-tenured
|
||||
# player becomes host, which is the least surprising behavior.
|
||||
if room_player.is_host and self.players:
|
||||
next_host = next(iter(self.players.values()))
|
||||
next_host.is_host = True
|
||||
|
||||
Reference in New Issue
Block a user