30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
RESIST_PENALTY_BY_DIFFICULTY,
|
|
computeCharacterSheetDerived,
|
|
} from '../../src/client/ui-model/derived-stats.ts'
|
|
|
|
function statsOf(entries: Record<number, number>) {
|
|
return { get: (id: number) => entries[id] ?? 0 }
|
|
}
|
|
|
|
describe('character sheet derived values (1.13c tables)', () => {
|
|
it('reads ResistPenalty from DifficultyLevels.txt', () => {
|
|
expect(RESIST_PENALTY_BY_DIFFICULTY).toEqual([0, -40, -100])
|
|
})
|
|
|
|
it('level-1 Assassin (dex 20, no bonuses)', () => {
|
|
const d = computeCharacterSheetDerived('ass', statsOf({ 2: 20 }), 0)
|
|
expect(d.attackRating).toBe((20 - 7) * 5 + 15)
|
|
expect(d.defense).toBe(5)
|
|
expect([d.fireRes, d.coldRes, d.lightRes, d.poisRes]).toEqual([0, 0, 0, 0])
|
|
})
|
|
|
|
it('applies difficulty penalty and the 75 + max-resist cap', () => {
|
|
const d = computeCharacterSheetDerived('sor', statsOf({ 2: 25, 39: 200, 40: 5, 43: 30 }), 2)
|
|
expect(d.fireRes).toBe(80)
|
|
expect(d.coldRes).toBe(-70)
|
|
expect(d.attackRating).toBe((25 - 7) * 5 - 15)
|
|
})
|
|
})
|