test(inventory): pin equip-slot/exclusivity/stack/drop invariants in Inventories.bb (22 tests)#571
Merged
Merged
Conversation
Adds InventoryEquipRulesTest.bb -- first direct test coverage for the equip-slot fork logic in Inventories.bb (ActorHasSlot's race/class exclusivity checks and per-slot disabled-flag gating, SlotsMatch's item-type -> slot-index mapping) plus the InventorySwap / InventoryAdd / InventoryDrop callers and the equipped-range readers (GetArmourLevel, InventoryMass, InventoryHasItem). The module is included for real (Items.bb supplies ItemInstance, same stub pattern as ItemsTest.bb), so these pins exercise the production code, not a replica. Pinned current behavior, flagged for human review (not 'fixed' -- these are regression pins): - ActorHasSlot's exclusivity fork gates on SlotI < Slot_Backpack (the 1-based slot NAME constant, 11) instead of SlotI_Backpack (the slot INDEX, 14), so indices 11-13 (Ring4, Amulet1, Amulet2) skip the ExclusiveRace$/ExclusiveClass$ checks entirely: a wrong-race ring is denied in Ring1-3 but allowed in Ring4. - A matching ExclusiveRace$ returns True immediately, skipping both the ExclusiveClass$ check and the disabled-slot flag check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
src/Tests/Modules/InventoryEquipRulesTest.bb(733 lines, 22 test blocks / ~170 asserts) — the first gameplay-correctness coverage forInventories.bb. The testIncludes the realItems.bb+Inventories.bb(ItemsTest stub pattern), so assertions exercise production code, not a replica.Pinned invariants:
ActorHasSlotflag/race/class gating,SlotsMatchslot routing (weapon/armour/ring/amulet/backpack/potion),InventorySwapequip/unequip round-trip + displacement + stack-into-equip rejection + split/relocate + dupe guards,InventoryAddmerge/drain + 16-bit non-lossy ceiling,InventoryDroppartial/final/overdraw,GetArmourLevel(broken armour = 0, Shield..Feet range only),InventoryMass,InventoryHasItem.⚠ Two engine-bug findings (PINNED, not fixed — these tests assert current behavior so a fix PR can flip the assertions deliberately)
Exclusivity bypass on equip indices 11–13 — real bug (runtime-confirmed, independently verified).
Inventories.bb:229gates the race/class exclusivity fork onSlotI < Slot_Backpack— butSlot_Backpack(= 11) is the 1-based slot name constant whileSlotIis a slot index (equip indices run 0..13;SlotI_Backpack= 14). Net effect: Ring4, Amulet1, Amulet2 skip race/class exclusivity entirely — a wrong-race ring equips fine in Ring4. The comment above ("If it's an equipped slot") shows intent was all 14 equip indices. Fix would beSlotI < SlotI_Backpack+ updating the pinned assertions.Race-match short-circuits the class check — likely bug, owner call. A matching
ExclusiveRace$returns True beforeExclusiveClass$is checked, so an "Elf Mage only" item equips on an Elf Warrior. Skipping the disabled-slot flag on race match is documented as intentional (:231), but nothing sanctions skipping the class check — and the comment at:240is a copy-pasted race comment over the class block. OR-vs-AND exclusivity semantics needs a maintainer decision before fixing.Verification (independent verifier ≠ implementer)
git diff --stat develop...HEAD= the one new test file only; no engine modules, none of the CI-generator-gated files..\test.bat InventoryEquipRules→[PASS]; full suite →Ran 55 files: 55 passed, 0 failed.;compile.bat -texit 0.TellServer=False).🤖 Generated with Claude Code