diff --git a/packages-user/data-base/src/hero/equipment.test.ts b/packages-user/data-base/src/hero/equipment.test.ts index 66ec220..cb76bef 100644 --- a/packages-user/data-base/src/hero/equipment.test.ts +++ b/packages-user/data-base/src/hero/equipment.test.ts @@ -286,8 +286,8 @@ describe('HeroEquipment equip and unequip', () => { expect(equips[1]).toBeNull(); }); - // 疑似 bug:字符串槽位空槽判断条件写反导致总是替换首个匹配槽位,详见 06-TEST-FINDINGS.md #06-05-2 - it.skip('uses the first empty named slot instead of replacing an occupant', () => { + // 验证字符串槽位优先占用首个空槽而非替换占用者(#06-05-2) + it('uses the first empty named slot instead of replacing an occupant', () => { const env = createEnv(); registerItem(env, createItem(10, 'sword', ['weapon'], [['atk', 5]])); registerItem(env, createItem(11, 'axe', ['weapon'], [['atk', 12]])); diff --git a/packages-user/data-base/src/hero/equipment.ts b/packages-user/data-base/src/hero/equipment.ts index f776b66..376eeeb 100644 --- a/packages-user/data-base/src/hero/equipment.ts +++ b/packages-user/data-base/src/hero/equipment.ts @@ -138,7 +138,7 @@ export class HeroEquipment implements IHeroEquipment { this.slots.forEach((name, index) => { if (name !== slot) return; if (first === -1) first = index; - if (empty !== -1 && !this.equips.has(index)) { + if (empty === -1 && !this.equips.has(index)) { empty = index; } });