Fix Placement-phase move attempts; case-insensitive player ID matching; hand debug

- Block unit selection in Placement phase (prevents sending game.move_unit
  when opponent hasn't placed yet)
- All accountId comparisons now case-insensitive (Guid serialization may
  differ between auth response and state DTO)
- Add debug log in _on_state_updated: phase, player found, hand size

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-07 11:38:48 -05:00
co-authored by Claude Happy
parent 30c7bef445
commit 036738e44d
2 changed files with 11 additions and 5 deletions
+1 -1
View File
@@ -238,7 +238,7 @@ func _apply_state_from_payload(p: Variant) -> void:
func _player_by_id(account_id: String) -> Dictionary:
for p: Dictionary in state.get("players", []):
if str(p.get("accountId", "")) == account_id:
if str(p.get("accountId", "")).to_lower() == account_id.to_lower():
return p
return {}
@@ -339,7 +339,7 @@ func _rebuild_ownership(state: Dictionary) -> void:
_friendly_unit_ids.clear()
var my_id := Auth.user_id
for p: Dictionary in state.get("players", []):
var is_mine : bool = str(p.get("accountId", "")) == my_id
var is_mine : bool = str(p.get("accountId", "")).to_lower() == my_id.to_lower()
var target : Dictionary = _enemy_unit_ids if not is_mine else _friendly_unit_ids
for u: Dictionary in p.get("field", []):
var iid : String = u.get("instanceId", "")
@@ -404,7 +404,7 @@ func _rebuild_units(state: Dictionary) -> void:
_unit_meshes.clear()
var my_id := Auth.user_id
for player: Dictionary in state.get("players", []):
var is_mine : bool = str(player.get("accountId", "")) == my_id
var is_mine : bool = str(player.get("accountId", "")).to_lower() == my_id.to_lower()
var color : Color = Color(0.3, 0.5, 1.0) if is_mine else Color(1.0, 0.35, 0.35)
var arch : Dictionary = player.get("archSpirit", {})
if not arch.is_empty() and arch.get("position") != null:
@@ -655,7 +655,8 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
match _mode:
Mode.NONE:
if not unit_id.is_empty() and _is_friendly_unit(unit_id) and Game.is_my_turn():
if not unit_id.is_empty() and _is_friendly_unit(unit_id) \
and Game.is_my_turn() and Game.get_phase() != "Placement":
_select_unit(unit_id)
Mode.CARD_FROM_HAND:
@@ -1264,7 +1265,12 @@ func _on_state_updated(state: Dictionary) -> void:
tile.get("resolvedAffinity", "Void"))
_rebuild_units(state)
_rebuild_hand(Game.get_hand())
var hand := Game.get_hand()
print("[GameScreen] state phase=", state.get("phase","?"),
" my_player_found=", not Game.get_my_player().is_empty(),
" hand_size=", hand.size(),
" my_id=", Auth.user_id.substr(0,8))
_rebuild_hand(hand)
_update_hud(state)
# Clear non-PLACEMENT selection after state change.