diff --git a/server/src/systems/__tests__/statModifierSystem.test.ts b/server/src/systems/__tests__/statModifierSystem.test.ts index 8c2953b..fd9051c 100644 --- a/server/src/systems/__tests__/statModifierSystem.test.ts +++ b/server/src/systems/__tests__/statModifierSystem.test.ts @@ -21,7 +21,7 @@ function setupEntity( world.addComponent(e, 'stats', base); world.addComponent(e, 'statModifiers', { modifiers: [...modifiers] }); if (needs) { - world.addComponent(e, 'needs', { hunger: 80, energy: 80, productivity: 80, ...needs }); + world.addComponent(e, 'needs', { hunger: 80, energy: 80, thirst: 80, productivity: 80, ...needs }); } return e; } @@ -97,6 +97,17 @@ describe('statModifierSystem', () => { expect(needsMods).toHaveLength(0); }); + it('applies perception -2 and constitution -1 when thirst < threshold', () => { + const world = new World(); + const e = setupEntity(world, {}, { thirst: 20, hunger: 80, energy: 80 }); + statModifierSystem(world, rc); + const mods = world.getComponent(e, 'statModifiers')!; + const perMod = mods.modifiers.find(m => m.stat === 'perception' && m.remaining === -1); + const conMod = mods.modifiers.find(m => m.stat === 'constitution' && m.remaining === -1); + expect(perMod?.value).toBe(-2); + expect(conMod?.value).toBe(-1); + }); + it('does not stack needs-based modifiers across ticks', () => { const world = new World(); const e = setupEntity(world, {}, { hunger: 20, energy: 80 }); diff --git a/server/src/systems/statModifierSystem.ts b/server/src/systems/statModifierSystem.ts index b2f9a16..b9583f3 100644 --- a/server/src/systems/statModifierSystem.ts +++ b/server/src/systems/statModifierSystem.ts @@ -15,6 +15,10 @@ function applyNeedsModifiers(needs: Needs, modifiers: StatModifier[], rc: Runtim filtered.push({ stat: 'dexterity', value: -2, remaining: -1 }); filtered.push({ stat: 'temperament', value: -2, remaining: -1 }); } + if (needs.thirst < rc.get('THIRST_THRESHOLD')) { + filtered.push({ stat: 'perception', value: -2, remaining: -1 }); + filtered.push({ stat: 'constitution', value: -1, remaining: -1 }); + } return filtered; }