From 6e060013f705d521fe2320354b76e15770c6de40 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Tue, 6 Jan 2026 21:14:25 +1100 Subject: [PATCH] Throwing an item shouldnt trigger wait --- src/core/types.ts | 1 + src/engine/__tests__/simulation.test.ts | 9 +++++++++ src/engine/simulation/simulation.ts | 4 ++++ src/scenes/GameScene.ts | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/types.ts b/src/core/types.ts index c30e467..0135a08 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -11,6 +11,7 @@ export type EnemyAIState = "wandering" | "alerted" | "pursuing" | "searching"; export type Action = | { type: "move"; dx: number; dy: number } | { type: "attack"; targetId: EntityId } + | { type: "throw" } | { type: "wait" }; export type SimEvent = diff --git a/src/engine/__tests__/simulation.test.ts b/src/engine/__tests__/simulation.test.ts index 8453c2a..be141b2 100644 --- a/src/engine/__tests__/simulation.test.ts +++ b/src/engine/__tests__/simulation.test.ts @@ -113,6 +113,15 @@ describe('Combat Simulation', () => { const events = applyAction(world, 1, { type: "unknown_hack" } as any, new EntityManager(world)); expect(events).toEqual([{ type: "waited", actorId: 1 }]); }); + + it("should NOT emit wait event for throw action", () => { + const actors = new Map(); + actors.set(1, { id: 1, category: "combatant", isPlayer: true, pos: { x: 0, y: 0 } } as any); + const world = createTestWorld(actors); + + const events = applyAction(world, 1, { type: "throw" }, new EntityManager(world)); + expect(events).toEqual([]); + }); }); describe("decideEnemyAction - AI Logic", () => { diff --git a/src/engine/simulation/simulation.ts b/src/engine/simulation/simulation.ts index c04f6da..aa2d45e 100644 --- a/src/engine/simulation/simulation.ts +++ b/src/engine/simulation/simulation.ts @@ -20,6 +20,10 @@ export function applyAction(w: World, actorId: EntityId, action: Action, em?: En case "attack": events.push(...handleAttack(w, actor, action, em)); break; + case "throw": + // Throwing consumes a turn but visuals are handled by the renderer/scene directly + // so we do NOT emit a "waited" event. + break; case "wait": default: events.push({ type: "waited", actorId }); diff --git a/src/scenes/GameScene.ts b/src/scenes/GameScene.ts index 253ed1f..d0413a6 100644 --- a/src/scenes/GameScene.ts +++ b/src/scenes/GameScene.ts @@ -623,7 +623,7 @@ export class GameScene extends Phaser.Scene { } this.cancelTargeting(); - this.commitPlayerAction({ type: "wait" }); + this.commitPlayerAction({ type: "throw" }); this.emitUIUpdate(); } );