Skip to content

Commit 442f644

Browse files
committed
fix: address Codex review — build errors, snapshot ordering, wander markers (#24)
1 parent 8bd3209 commit 442f644

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

client/src/game/entities/HeroSprite.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export class HeroSprite {
7575
readonly heroClass: HeroClass;
7676
private scene: Phaser.Scene;
7777
private sprite: Phaser.GameObjects.Sprite;
78-
private source: AgentSource;
7978
private isSubagent: boolean;
8079
private nameText: Phaser.GameObjects.Text;
8180
private taskText: Phaser.GameObjects.Text;
@@ -125,12 +124,11 @@ export class HeroSprite {
125124
x: number,
126125
y: number,
127126
isSubagent = false,
128-
source: AgentSource = 'claude',
127+
_source: AgentSource = 'claude',
129128
) {
130129
this.scene = scene;
131130
this.id = id;
132131
this.heroClass = heroClass;
133-
this.source = source;
134132
this.isSubagent = isSubagent;
135133
this._x = x;
136134
this._y = y;
@@ -525,6 +523,9 @@ export class HeroSprite {
525523
this.indexText.setPosition(this._x + this.indexOffsetX, this._y + this.indexOffsetY);
526524
this.updateBubble();
527525
if (this.selectionHalo !== null) this.selectionHalo.setPosition(this._x, this._y);
526+
if (this.isSubagent) {
527+
this.repositionSubagentMarkers();
528+
}
528529
this.updateDepth();
529530
},
530531
onComplete: () => {

client/src/game/scenes/BootScene.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export class BootScene extends Phaser.Scene {
3636
// key AND src lets the reader pair a 30%-stuck moment with the exact
3737
// path that landed last (the stuck file is in flight, not this one).
3838
this.load.on(Phaser.Loader.Events.FILE_COMPLETE, (key: string, type: string, _data: unknown) => {
39-
const file = this.load.list?.entries?.find?.((f: Phaser.Loader.File) => f.key === key);
39+
const file = this.load.list
40+
? Array.from(this.load.list.values()).find((f: Phaser.Loader.File) => f.key === key)
41+
: undefined;
4042
const src = file?.src ?? '?';
4143
console.log(`[BOOT] filecomplete type=${type} key=${key} src=${src}`);
4244
});

client/src/game/scenes/VillageScene.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,17 @@ export class VillageScene extends Phaser.Scene {
879879
}
880880
}
881881

882-
for (const agent of visible) {
882+
// Process parent heroes before sub-agents so that `canAttachSubagent`
883+
// sees the parent in `this.heroes` when the child is spawned. A single
884+
// sort pass is O(n log n) and avoids a two-pass loop for the common case
885+
// where parents and children arrive in the same snapshot.
886+
const orderedVisible = [...visible].sort((a, b) => {
887+
const aIsChild = a.isSubagent ? 1 : 0;
888+
const bIsChild = b.isSubagent ? 1 : 0;
889+
return aIsChild - bIsChild;
890+
});
891+
892+
for (const agent of orderedVisible) {
883893
const existing = this.heroes.get(agent.id);
884894
const buildingDef = getBuildingForActivity(agent.currentActivity);
885895
const attachable = this.canAttachSubagent(agent);

0 commit comments

Comments
 (0)