Files
agentic-labs-challenge-subm…/body-snatcher/build/_contract.md
T
2026-08-13 07:25:35 +02:00

4.3 KiB

You are building "Body Snatcher" — a single index.html browser possession roguelike. STEP 0: Read AGENTS.md in THIS directory COMPLETELY. It is the authoritative spec. Then, if index.html already exists, read ALL of the current index.html before editing. After phase 1, NEVER rewrite index.html from scratch — edit it incrementally and PRESERVE every working system from earlier phases.

HARD CONSTRAINTS (every phase):

  • Single index.html. Zero external dependencies: no CDN, no npm, no ES import, no <script src=>. All CSS and JS inline.
  • The game MUST NOT auto-start play on load. It sits on the title screen until start() or a valid user key.
  • MUST NOT crash if Canvas.getContext('2d') or AudioContext are no-op mocks. Guard every canvas/audio call.
  • Core game logic is DETERMINISTIC and step-driven, NOT wall-clock. tick(n) advances enemy AI AND decrements the ghost timer by exactly n steps. 1 step = 1 second. Base ghost timer = 15 steps; Ghost T1 = 20 steps. (Visuals/audio may use real time; the timer and AI must not.)
  • Expose window.GAME = { state, player, enemies, grid, floor, essence, upgrades, achievements, projectiles, log, start, input, tick, spawn, setFloor, newRun, save, load, openShop, buy }.
    • state is one of: title, playing, possessed, shop, paused, won, lost.
    • player = { x, y, ghost(bool), timer, host, facing }.
    • enemy = { type, hp, maxHp, damage, speed, x, y, ... }.
    • grid[y][x] = number (0 floor, 1 wall, 2 door, 3 exit, 4 shop, 5 chest) OR an object { type, solid }. Pick one shape and stay consistent.
  • input(key) accepts: ArrowUp/Down/Left/Right, w a s d, ' ' and 'Space', q e, x (abandon host), Enter, Escape, l (legend toggle).
  • spawn(type, tx, ty) creates and returns the enemy. setFloor(n) regenerates floor n and places the ghost at spawn (state playing). newRun() starts a fresh floor-1 run with a NEW random layout. openShop() (debug) enters shop state AND grants a test stipend (set essence >= 30) so buy() can succeed; the real between-floor shop uses earned essence. buy(index) purchases; hard-block if essence is insufficient; enforce per-tree prerequisites (T1 -> T2 -> T3 -> T4). After openShop and after the between-floor shop, expose the 3 choices on GAME as G.choices (the harness also accepts G.shopChoices / G.upgradeChoices); make choice[0] a prereq-met, unowned item.
  • Title screen MUST visibly explain WASD/arrows, SPACE, Q/E (facing), ENTER, ESC. It MUST offer an enemy Legend/Bestiary panel (toggle 'l') listing each enemy's behavior AND its possessed kit. The live HUD shows a contextual SPACE hint (possess while ghost; attack/special while possessed; press X to abandon host while possessed). Pause (ESC) and shop screens show their own controls.

PACING RULES — these are completion criteria and verify.js checks them directly:

  • NO friendly fire between enemies. Enemy melee, AoE explosions, charges, and projectiles damage the PLAYER ONLY and never reduce another enemy's HP. (Your possessed host's attacks and your host's AoE still damage enemies normally, and you still gain essence for those kills.) verify.js places a "meat" enemy on the line of an enemy Sentinel/Turret shot, inside an enemy Bomber's blast, and on an enemy Charger's charge line, and asserts that enemy's HP is unchanged WHILE confirming the AoE/projectile actually happened.
  • Aggro radius ~6 tiles, line-of-sight gated. Enemies start DOCILE and only chase / attack when the player is within radius AND visible. Outside it they idle and do NOT path toward the player. The whole floor MUST NOT swarm on spawn. Keep the spawn area clear (place enemies at least 6 manhattan tiles from spawn).
  • Sentinel and Turret fire a 3-shot BURST then OVERHEAT into a forced multi-turn (>=3) no-fire window during which they cannot shoot (Turret is also fully vulnerable then). verify.js places them 5-7 tiles away along a cleared corridor and asserts a burst followed by >=3 consecutive no-fire turns. No infinite-fire enemies.

SELF-CHECK before you report done: run node verify.js <this phase> and every lower phase too (to confirm no regression), and FIX every failure. The harness is headless: it evals your inline <script> with mocked DOM/canvas/audio/localStorage and drives the game exclusively through window.GAME. If a check fails, read its message — it names the exact expectation.