The user wants a git commit message based on the provided diff.

**Analysis of the Diff:**
1.  **Binary Files:** `walls.png` and `walls.psd` are updated. This suggests an asset update, likely related to the "wolfenstein" theme mentioned in the paths.
2.  **JavaScript File:** `tools/verifyWolfenstein.js` is modified.
    *   A new test case is added under `section('4. Enemy AI');`.
    *   The test verifies that an enemy (guard) alerts when hit by a projectile, specifically in a scenario where:
        *   Visual detection (LOS+FOV) is blocked/blind (guard facing away).
        *   "Heard gunfire" alert path is blocked (different room/door logic).
    *   The test sets up a specific level layout, forces a door open, fires a pistol, and checks if the enemy's state changes from 'idle' to something else (alerted) and health drops.
    *   It explicitly mentions fixing an issue with `stepDoors` auto-close countdown underflow by setting `timer`.

**Synthesis:**
The primary functional change is adding a test case to ensure that direct hits alert enemies even when other alert mechanisms (vision, sound through doors) fail. The asset changes are likely incidental or part of the same feature branch (Wolfenstein theme).

**Drafting the Commit Message:**
*   **Subject:** Add test for enemy alert on direct hit bypassing vision/sound checks
*   **Body:**
    *   Update Wolfenstein wall assets (PNG/PSD).
    *   Add verification test in `verifyWolfenstein.js` ensuring enemies alert when shot, even if they cannot see the player or hear gunfire through doors.
    *   Fix door timer initialization in the test to prevent auto-close interference during projectile flight.

**Refining for Conciseness:**
Subject: Add enemy hit-alert test and update Wolfenstein assets

Body:
- Update `walls.png` and `walls.psd`.
- Add a test case in `verifyWolfenstein.js` verifying that direct hits alert enemies unconditionally, independent of vision cone or room-based sound alerts.
- Ensure door state is correctly initialized in the test to prevent auto-close interference with projectile simulation.

Let's make it standard conventional commit style if possible, or just clear and descriptive.

**Final Polish:**
Subject: Add test for unconditional enemy alert on direct hit

Body:
Update Wolfenstein wall assets (`walls.png`, `walls.psd`).

Add a new test case in `verifyWolfenstein.js` to verify that enemies alert when directly hit by a projectile, even when visual detection (LOS/FOV) and sound-based alerts (through doors) are inactive. This ensures the direct-hit alert path works independently.

Also fixes door timer initialization in the test setup to prevent auto-close logic from interfering with the projectile simulation.

This looks good. I will provide just the message as requested.
This commit is contained in:
Brian Fertig 2026-08-22 10:51:42 -06:00
parent c0ab9155a3
commit aa685dc505
3 changed files with 38 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

View File

@ -331,6 +331,44 @@ section('4. Enemy AI');
L.fireWeapon(state, rules);
check('gunshot does not alert a guard through an open door either', state.enemies[0].state === 'idle', state.enemies[0].state);
}
// Actually landing a hit alerts an enemy unconditionally, independent
// of BOTH other alert paths above: visual detection (LOS+FOV+range) and
// "heard gunfire in the room" (which the door-forced-open case just
// proved does NOT reach across a door, open or not). Guard sits on the
// same row as the door gap (y=2.5) so a bullet fired straight down that
// row travels through the open door and can actually connect, but
// facing east (away from the westward player) keeps it outside its own
// vision cone, and it's in the room-alert-blind "other room" the whole
// time — so alerting here can only be the direct-hit path itself.
{
const level = {
width: W, height: H, cellSize: 64, walls, doors, items: [],
playerStart: { x: 2.5, y: 2.5, angle: 0 },
enemies: [{ type: 'guard', x: 7.5, y: 2.5, facing: 0 }],
exit: { x: 9.5, y: 1.5, radius: 0.6 },
};
const state = L.createState(level, rules);
// Forcing the door open (unlike the fireWeapon-only sub-tests above,
// this one calls L.tick(), which runs stepDoors) also needs `timer`
// set — left at its createState default of 0, stepDoors' auto-close
// countdown underflows on the very first tick and starts sliding the
// door shut again right under the in-flight bullet.
state.doors[0].slide = 1; state.doors[0].target = 1; state.doors[0].timer = rules.constants.doorAutoCloseMs;
state.map.walls[2][5] = 0;
L.switchWeapon(state, 'pistol');
L.setFireHeld(state, true);
L.tick(state, rules); // fires — projectile now in flight through the open door
let alerted = false, healthDropped = false;
for (let i = 0; i < 60 && !alerted; i++) {
L.setFireHeld(state, false); // one shot only — a second room-alert-free shot isn't the point here
L.tick(state, rules);
if (state.enemies[0].health < rules.enemyById.guard.health) healthDropped = true;
alerted = state.enemies[0].state !== 'idle';
}
check('the shot actually connected (sanity check for the assertion below)', healthDropped);
check('being shot alerts a guard even with room-alert and vision-cone both blind to it', alerted, state.enemies[0].state);
}
}
// A dead guard stops acting and can't be hit/killed twice. The pistol is