refine ranged combat

This commit is contained in:
2026-05-16 21:35:35 +02:00
parent 866c0a9f2d
commit 97ba4bf478
7 changed files with 183 additions and 91 deletions
+23 -3
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { atBasis, fkBasis, lepMax, paBasis, computeDerived } from '$lib/engine/derived';
import { aspMax, atBasis, aupMax, fkBasis, lepMax, paBasis, computeDerived } from '$lib/engine/derived';
import { newCharacter } from '$lib/characters/default';
describe('derived', () => {
@@ -7,7 +7,7 @@ describe('derived', () => {
const c = newCharacter({ name: 'Test', id: '00000000-0000-4000-8000-000000000001' });
expect(atBasis(c)).toBe(Math.round((11 + 11 + 11) / 5));
expect(paBasis(c)).toBe(Math.round((11 + 11 + 11) / 5));
expect(fkBasis(c)).toBe(Math.round((11 + 11 + 11) / 4));
expect(fkBasis(c)).toBe(Math.round((11 + 11 + 11) / 5));
});
it('includes race LeP bonus for human', () => {
@@ -17,10 +17,30 @@ describe('derived', () => {
const kk = 13;
c.eigenschaften.KO = { startwert: ko, mod: 0 };
c.eigenschaften.KK = { startwert: kk, mod: 0 };
const base = Math.floor((2 * ko + kk) / 2);
const base = Math.round((2 * ko + kk) / 2);
expect(lepMax(c)).toBe(base + 10 + c.energien.lep.mod);
});
it('computes aspMax as round((MU+IN+CH)/2) plus race and mod', () => {
const c = newCharacter({ id: '00000000-0000-4000-8000-000000000004' });
c.energien.asp = { mod: 0 };
c.eigenschaften.MU = { startwert: 12, mod: 0 };
c.eigenschaften.IN = { startwert: 14, mod: 0 };
c.eigenschaften.CH = { startwert: 10, mod: 0 };
const base = Math.round((12 + 14 + 10) / 2);
expect(aspMax(c)).toBe(base + c.energien.asp.mod);
});
it('computes aupMax as round((MU+KO+GE)/2) plus race and mod', () => {
const c = newCharacter({ id: '00000000-0000-4000-8000-000000000005' });
c.meta.rasse = 'mensch01';
c.eigenschaften.MU = { startwert: 13, mod: 0 };
c.eigenschaften.KO = { startwert: 12, mod: 0 };
c.eigenschaften.GE = { startwert: 11, mod: 0 };
const base = Math.round((13 + 12 + 11) / 2);
expect(aupMax(c)).toBe(base + 10 + c.energien.aup.mod);
});
it('computeDerived returns all keys', () => {
const c = newCharacter({ id: '00000000-0000-4000-8000-000000000003' });
const d = computeDerived(c);