Throwing an item shouldnt trigger wait
This commit is contained in:
@@ -11,6 +11,7 @@ export type EnemyAIState = "wandering" | "alerted" | "pursuing" | "searching";
|
|||||||
export type Action =
|
export type Action =
|
||||||
| { type: "move"; dx: number; dy: number }
|
| { type: "move"; dx: number; dy: number }
|
||||||
| { type: "attack"; targetId: EntityId }
|
| { type: "attack"; targetId: EntityId }
|
||||||
|
| { type: "throw" }
|
||||||
| { type: "wait" };
|
| { type: "wait" };
|
||||||
|
|
||||||
export type SimEvent =
|
export type SimEvent =
|
||||||
|
|||||||
@@ -113,6 +113,15 @@ describe('Combat Simulation', () => {
|
|||||||
const events = applyAction(world, 1, { type: "unknown_hack" } as any, new EntityManager(world));
|
const events = applyAction(world, 1, { type: "unknown_hack" } as any, new EntityManager(world));
|
||||||
expect(events).toEqual([{ type: "waited", actorId: 1 }]);
|
expect(events).toEqual([{ type: "waited", actorId: 1 }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should NOT emit wait event for throw action", () => {
|
||||||
|
const actors = new Map<EntityId, Actor>();
|
||||||
|
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", () => {
|
describe("decideEnemyAction - AI Logic", () => {
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ export function applyAction(w: World, actorId: EntityId, action: Action, em?: En
|
|||||||
case "attack":
|
case "attack":
|
||||||
events.push(...handleAttack(w, actor, action, em));
|
events.push(...handleAttack(w, actor, action, em));
|
||||||
break;
|
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":
|
case "wait":
|
||||||
default:
|
default:
|
||||||
events.push({ type: "waited", actorId });
|
events.push({ type: "waited", actorId });
|
||||||
|
|||||||
@@ -623,7 +623,7 @@ export class GameScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.cancelTargeting();
|
this.cancelTargeting();
|
||||||
this.commitPlayerAction({ type: "wait" });
|
this.commitPlayerAction({ type: "throw" });
|
||||||
this.emitUIUpdate();
|
this.emitUIUpdate();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user