Fix swap animation stutter and remove 1s server-side dead delay

- Remove unused card_revealed broadcast + 1s asyncio.sleep in swap handler
  (client never handled this message, causing pure dead wait before game_state)
- Defer swap-out (opacity:0) on hand cards to onStart callback so overlay
  covers the card before hiding it — eliminates visual gap for all players
- Defer heldCardFloating visibility hide to onStart — held card stays visible
  until animation overlay replaces it
- Thread onStart callback through animateUnifiedSwap → _runUnifiedSwap

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-03-05 23:47:26 -05:00
parent 5408867921
commit ea34ddf8e4
3 changed files with 74 additions and 30 deletions

View File

@@ -313,22 +313,6 @@ async def handle_swap(data: dict, ctx: ConnectionContext, *, broadcast_game_stat
reason=f"swapped {drawn_card.rank.value} into position {position}, replaced {old_rank}",
)
# Broadcast reveal of old face-down card before state update
if old_card_data:
reveal_msg = {
"type": "card_revealed",
"player_id": ctx.player_id,
"position": position,
"card": old_card_data,
}
for pid, p in ctx.current_room.players.items():
if not p.is_cpu and p.websocket:
try:
await p.websocket.send_json(reveal_msg)
except Exception:
pass
await asyncio.sleep(1.0)
await broadcast_game_state(ctx.current_room)
await asyncio.sleep(1.0)
check_and_run_cpu_turn(ctx.current_room)