Phase 3: object tracker

Game-file footprint unchanged: still one line in main.lua.

Three-level navigation as specified in D2: Ctrl+PageUp/Down cycles categories,
PageUp/Down cycles kinds, Shift+PageUp/Down cycles instances of that kind, Home
announces where it is.

- categories.lua: flag-first classification into Creatures, Items, Alchemy,
  Interactables, Exits and Terrain features, reusing the game's own 'exit' tag
  and excluding the six nameless mechanical templates.
- tracker.lua: scan, cache, navigation, announcements.

Caching keys on level name, player position and turn: position because
everything sorts by distance to the player, turn because creatures move and
containers empty. Scans run on keypress, never per frame.

FoV is respected throughout -- creatures only when currently visible, tiles when
visible or remembered -- so the tracker never becomes a cheat.

Home reports path length alongside the offset, via the game's own
calculatePathFromPlayer. Straight-line distance is misleading indoors, where a
chest three tiles north through a wall can be twenty steps away.

Corrects D4 in docs/05-decisions.md. I had claimed tile.tryInteract cleanly
separates 'the player can do something here' from scenery. It does not: 'wall'
carries a flavour-only tryInteractFunction ('You touch the wall. It's cold and
rough.'), so every wall segment was promoted into Interactables -- 13 in the
starting house, burying the chest and cauldron. Structural tiles
(blocksMovement and blocksVision) are now excluded before the tryInteract test;
containers and furniture block movement but not sight, so they survive.
12 kinds/19 instances instead of 13/32.

13/13 testbed checks, history unit tests passing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Accessibility Mod
2026-08-01 21:34:13 +02:00
co-authored by Claude Opus 5
parent 8b1eb44c38
commit c17c5277d4
6 changed files with 687 additions and 7 deletions
+62 -1
View File
@@ -224,7 +224,68 @@ local function scenario()
press("kp6", "probe east", {ctrl = true})
press("kp5", "probe standing-on", {ctrl = true})
-- The game's own examine mode, now narrated via levelCursorPopup.
-- Phase 3: object tracker.
local tracker = require("accessibility.tracker")
local scanData = tracker.rescan(true)
check("tracker scan returns data", scanData ~= nil,
"scan = " .. tostring(scanData))
if scanData then
local summary = {}
for _, category in ipairs(require("accessibility.categories").list) do
local bucket = scanData[category.key]
local kinds = bucket and #bucket.kinds or 0
local instances = 0
for _, kind in ipairs(bucket and bucket.kinds or {}) do
instances = instances + #kind.instances
end
summary[#summary + 1] = string.format("%s=%dk/%di", category.key, kinds, instances)
if kinds > 0 then
local names = {}
for _, kind in ipairs(bucket.kinds) do
names[#names + 1] = kind.name .. "(" .. kind.key .. ")x" .. #kind.instances
end
print("[testbed] " .. category.key .. ": " .. table.concat(names, ", "))
end
end
print("[testbed] tracker contents: " .. table.concat(summary, " "))
local found = false
for _, category in ipairs(require("accessibility.categories").list) do
local bucket = scanData[category.key]
if bucket and #bucket.kinds > 0 then
found = true
end
end
check("tracker found something", found, "at least one non-empty category")
end
-- Cycle every category so each announcement path runs, including empties.
for i = 1, 6 do
press("pagedown", "tracker: category " .. i, {ctrl = true})
end
-- Land on a populated category before exercising kind/instance navigation,
-- otherwise every announcement is just "none" and proves nothing.
local trackerCategories = require("accessibility.categories").list
for i, category in ipairs(trackerCategories) do
local bucket = scanData and scanData[category.key]
if bucket and #bucket.kinds > 0 then
-- Cycling wrapped back to index 1, so step forward to this one.
for _ = 2, i do
press("pagedown", "tracker: to " .. category.key, {ctrl = true})
end
break
end
end
press("pagedown", "tracker: next kind")
press("pagedown", "tracker: next kind")
press("pagedown", "tracker: next instance", {shift = true})
press("pagedown", "tracker: next instance", {shift = true})
press("home", "tracker: announce location")
-- The game's own examine mode.
press("x", "enter examine mode")
wait(10)
check("entered examine mode", currentState() == "ingame_observe",