2.9 KiB
D3 — Equipment, identification, consumable use, and inventory UI
Scope
D3 adds persistent equipment and item-identification state to the run, supports equipping and swapping gear, consumable use, ally-target handoff, dropping stack units, and a keyboard-driven inventory presentation. D4 economy/shops/paid rest and D5 crafting remain out of scope.
Design and implementation
EquipmentStateowns the declared equipment slots, moves instances between inventory and equipment, rejects unsupported slots without mutation, swaps displaced equipment back into inventory, and recomputesPlayerStateattribute/skill modifiers.ItemIdentificationmasks names, descriptions, and combat modifiers for unidentified instances. Equipping and consuming reveal the relevant instance.InventoryStatenow provides instance lookup/removal, stack-aware dropping, and data-backedheal,heal_pct,cure_status, andapply_statuseffects. It supports both the domainPlayerState.max_hp()contract and the live combatActorState.max_hit_pointscontract.InventoryPanelpresents selection, item details, equipment comparison, equipped summary, and keyboard actions (Eequip,Uuse,Ddrop, arrows select,I/Escape close). The game records accepted/refused equip, use, and drop events and keeps ranged main-hand equipment synchronized with the existing combat actor.- Ally-target consumables expose
submit_inventory_ally_target()as a UI-neutral seam for a future party selector; D3 does not introduce a party UI.
Root cause and fix
The D3 keyboard integration initially exercised live ActorState healing while InventoryState.use_item() only assumed the PlayerState.max_hp() method. The resulting runtime failure was an invalid max_hp call on ActorState. The fix centralizes maximum-health resolution in InventoryState: use max_hp() for PlayerState, otherwise use the supported max_hit_points property, and reject invalid recipients before applying effects or consuming an item. A unit regression test covers the ActorState path; the end-to-end test covers the live keyboard flow.
Verification
Executed with Godot 4.5.0 (/snap/bin/godot4):
GODOT_BIN=/snap/bin/godot4 ./scripts/test-unit.sh PASS — 129/129 tests, 998 assertions
GODOT_BIN=/snap/bin/godot4 ./scripts/test-integration.sh PASS — 7/7 tests, 9,255 assertions
GODOT_BIN=/snap/bin/godot4 ./scripts/test-e2e.sh PASS — 31/31 tests, 326 assertions
git diff --check PASS
The test runners emitted pre-existing GUT invalid-UID and resource-cleanup warnings, but no SCRIPT ERROR or parse error. No push or PR was performed.
Files
Production changes are limited to the game scene, domain actor/player/inventory/run state, equipment and identification domain services, game integration, and inventory presentation. New unit and E2E coverage is included for D3 behavior.