Skip to content

fix: Handle statePort access in worker context for building placement#1117

Merged
braedonsaunders merged 1 commit into
mainfrom
claude/debug-ai-worker-refactor-7qcPd
Jan 30, 2026
Merged

fix: Handle statePort access in worker context for building placement#1117
braedonsaunders merged 1 commit into
mainfrom
claude/debug-ai-worker-refactor-7qcPd

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

The BuildingPlacementSystem.findWorkerForConstruction() was calling this.game.statePort.getSelectedUnits() which throws in the worker because WorkerGame doesn't have statePort (only Game does).

This caused AI building placement to silently fail - the event was received, player type was detected, but then an exception was thrown before the worker could be assigned.

Fix: Use optional chaining with fallback to empty array, since worker context has no selected units anyway (AI players don't select).

https://claude.ai/code/session_01V4RhCiDvDJ7FmwSPYT74Y7

The BuildingPlacementSystem.findWorkerForConstruction() was calling
this.game.statePort.getSelectedUnits() which throws in the worker
because WorkerGame doesn't have statePort (only Game does).

This caused AI building placement to silently fail - the event was
received, player type was detected, but then an exception was thrown
before the worker could be assigned.

Fix: Use optional chaining with fallback to empty array, since worker
context has no selected units anyway (AI players don't select).

https://claude.ai/code/session_01V4RhCiDvDJ7FmwSPYT74Y7
@braedonsaunders
braedonsaunders merged commit 8e0188c into main Jan 30, 2026
4 checks passed
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