Ensure enemies only lock onto player once they have line of sight

This commit is contained in:
Peter Stockings
2026-01-05 14:46:04 +11:00
parent dba0f054db
commit 45a1ed2253
6 changed files with 199 additions and 33 deletions

View File

@@ -77,9 +77,9 @@ describe('Combat Simulation', () => {
world.tiles[3 * 10 + 4] = 4; // Wall
entityManager = new EntityManager(world);
const action = decideEnemyAction(world, enemy, player, entityManager);
const decision = decideEnemyAction(world, enemy, player, entityManager);
expect(action.type).toBe("move");
expect(decision.action.type).toBe("move");
});
it("should attack if player is adjacent", () => {
@@ -92,8 +92,8 @@ describe('Combat Simulation', () => {
const world = createTestWorld(actors);
entityManager = new EntityManager(world);
const action = decideEnemyAction(world, enemy, player, entityManager);
expect(action).toEqual({ type: "attack", targetId: 1 });
const decision = decideEnemyAction(world, enemy, player, entityManager);
expect(decision.action).toEqual({ type: "attack", targetId: 1 });
});
});
});