feat: add thirst stat penalties (perception -2, constitution -1)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-10 20:38:57 +00:00
parent 27353e9ef3
commit b5c8bdeea9
2 changed files with 16 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ function setupEntity(
world.addComponent<Stats>(e, 'stats', base);
world.addComponent<StatModifiers>(e, 'statModifiers', { modifiers: [...modifiers] });
if (needs) {
world.addComponent<Needs>(e, 'needs', { hunger: 80, energy: 80, productivity: 80, ...needs });
world.addComponent<Needs>(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<StatModifiers>(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 });

View File

@@ -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;
}