Add the whip to the office toolbar: slackers hustle back to their desks
- New bottom toolbar on the pixel office floor with a Whip tool; toggling it turns the cursor to a crosshair, clicks whip instead of opening the detail card, Escape puts the whip away - Simulation.whip(): an agent inside the snack bar or restroom drops whatever they are carrying and hustles back to their desk at 1.8x speed for a few seconds; agents at their desks, in the CEO office, or in the meeting room are working and stay untouched - Room membership decides the outcome (rectContains against the same floor-plan rooms the renderer draws), so the rule matches what the player sees - Unit tests cover the whip matrix; e2e drives the toolbar toggle in the live shell
This commit is contained in:
1 parent
2bb2acd635
commit
4ab20e679c
6 files changed
+161
-4
No files matched your search
@@ -189,6 +189,56 @@ describe("office simulation", () => {
|
||||
expect(sim.agents[0].behavior.kind).toBe("seated");
|
||||
});
|
||||
|
||||
test("the whip sends snack-bar and restroom slackers hustling home, snack abandoned", () => {
|
||||
const sim = new OfficeSimulation(() => 0);
|
||||
sim.sync([agentInput("a"), agentInput("b")]);
|
||||
const snacker = sim.agents[0];
|
||||
const snackSpot = sim.plan.amenities.find((spot) => spot.kind === "snack")!;
|
||||
snacker.x = snackSpot.stand.x;
|
||||
snacker.y = snackSpot.stand.y;
|
||||
snacker.carrying = "snack";
|
||||
snacker.behavior = { kind: "dwelling", spot: snackSpot, remainingMs: 60_000 };
|
||||
|
||||
expect(sim.whip("a")).toBe(true);
|
||||
expect(snacker.behavior.kind).toBe("walking");
|
||||
expect(snacker.carrying).toBeNull();
|
||||
expect(snacker.hustleMs).toBeGreaterThan(0);
|
||||
|
||||
const restroomSpot = sim.plan.amenities.find((spot) => spot.kind === "restroom")!;
|
||||
const rester = sim.agents[1];
|
||||
rester.x = restroomSpot.stand.x;
|
||||
rester.y = restroomSpot.stand.y;
|
||||
rester.behavior = { kind: "dwelling", spot: restroomSpot, remainingMs: 60_000 };
|
||||
expect(sim.whip("b")).toBe(true);
|
||||
expect(rester.behavior.kind).toBe("walking");
|
||||
|
||||
// The whipped walker makes it back to their desk.
|
||||
for (let i = 0; i < 4000 && sim.agents[0].behavior.kind !== "seated"; i++) sim.step(16, IDLE);
|
||||
expect(snacker.x).toBe(snacker.seat.x);
|
||||
expect(snacker.y).toBe(snacker.seat.y);
|
||||
});
|
||||
|
||||
test("the whip does nothing to agents at their desk or in a meeting", () => {
|
||||
const sim = new OfficeSimulation(() => 0);
|
||||
sim.sync([agentInput("a"), agentInput("b"), agentInput("ceo", "c_suite")]);
|
||||
// Seated at the desk: working, untouched.
|
||||
expect(sim.whip("a")).toBe(false);
|
||||
expect(sim.agents[0].behavior.kind).toBe("seated");
|
||||
|
||||
// Dwelling in the meeting room: in a meeting, untouched.
|
||||
const meetingSpot = sim.plan.amenities.find((spot) => spot.kind === "meeting")!;
|
||||
const attendee = sim.agents[1];
|
||||
attendee.x = meetingSpot.stand.x;
|
||||
attendee.y = meetingSpot.stand.y;
|
||||
attendee.behavior = { kind: "dwelling", spot: meetingSpot, remainingMs: 20_000 };
|
||||
expect(sim.whip("b")).toBe(false);
|
||||
expect(attendee.behavior.kind).toBe("dwelling");
|
||||
|
||||
// The CEO in their own office is working, untouched.
|
||||
expect(sim.whip("ceo")).toBe(false);
|
||||
expect(sim.whip("nobody")).toBe(false);
|
||||
});
|
||||
|
||||
test("clicks hit the agent drawn at that spot, frontmost first", () => {
|
||||
const sim = new OfficeSimulation();
|
||||
sim.sync([agentInput("a"), agentInput("b")]);
|
||||
|
||||
Reference in new issue
Block a user