Skip to content

Claude/fix ai player stuck 9o81v#1155

Merged
braedonsaunders merged 2 commits into
mainfrom
claude/fix-ai-player-stuck-9o81v
Jan 30, 2026
Merged

Claude/fix ai player stuck 9o81v#1155
braedonsaunders merged 2 commits into
mainfrom
claude/fix-ai-player-stuck-9o81v

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

No description provided.

Root cause: In worker context, the Zustand store's localPlayerId defaults
to 'player1' and isn't synchronized with the main thread. When player1 is
set to AI, isLocalPlayer('player1') incorrectly returns true.

This caused:
- BuildingPlacementSystem to treat player1 AI as local human player
- Resource checks/deductions used wrong player store
- AI couldn't build structures after initial fabricators

Fix:
- Check if player is AI FIRST before checking isLocalPlayer
- AI players are never treated as local players for resource management
- Also fixed ProductionSystem to properly refund AI resources on cancel

https://claude.ai/code/session_01YXBQcx4CzdxB1d1umVjjyR
Continue fixing isLocalPlayer checks in worker context where the
Zustand store's localPlayerId defaults to 'player1' and may incorrectly
identify AI players as the local human player.

Fixed systems:
- SpawnSystem: Unit death supply reduction now checks AI first
- WallSystem: Wall upgrade resource handling checks AI first
- BuildingPlacementSystem:
  - Wall line placement checks AI first
  - Addon building checks AI first
  - Building completion supply checks AI first
  - Blueprint cancellation refund checks AI first

Pattern: Always check if player is AI before checking isLocalPlayer()
to prevent AI player1 from being incorrectly treated as local human.

https://claude.ai/code/session_01YXBQcx4CzdxB1d1umVjjyR
@braedonsaunders braedonsaunders merged commit 064ef38 into main Jan 30, 2026
@braedonsaunders braedonsaunders deleted the claude/fix-ai-player-stuck-9o81v branch January 31, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants