fix: Ref 유산 포인트 적립 조건을 전면 정합화한다

능동 행동 31개 호출 지점과 소유자·NPC·통일 경계를 고정하고 사용자 저장값을 함께 갱신한다.\n\n최대 내정·임관, 천통 기여, 토너먼트, 숙련·베팅·랭크 계산과 환생 정산을 공통 계산기로 통합한다.
This commit is contained in:
2026-08-23 12:06:59 +00:00
parent 2f793a9518
commit 18e0bed30a
19 changed files with 712 additions and 245 deletions
@@ -0,0 +1,107 @@
import { describe, expect, it } from 'vitest';
import {
ALL_MERGED_INHERITANCE_KEYS,
computeActiveInheritancePoint,
computeInheritanceSettlementBreakdown,
} from '../src/inheritance/pointCalculation.js';
describe('Ref inheritance point calculation', () => {
const general = {
meta: {
inherit_lived_month: 12,
max_domestic_critical: 20,
inherit_active_action: 0.5,
belong: 7,
max_belong: 9,
rank_warnum: 3,
firenum: 2,
dex1: 1_275_978,
dex2: 100,
event100_allstar: { granted: { dex2: 40 } },
betwin: 2,
betgold: 2_000,
betwingold: 1_000,
},
inheritancePoints: {
max_domestic_critical: 80,
unifier: 250,
tournament: 50,
},
};
it('keeps all ten Ref sources distinct', () => {
expect(ALL_MERGED_INHERITANCE_KEYS).toEqual([
'lived_month',
'max_domestic_critical',
'active_action',
'unifier',
'tournament',
'max_belong',
'combat',
'sabotage',
'dex',
'betting',
]);
expect(
Object.fromEntries(
ALL_MERGED_INHERITANCE_KEYS.map((key) => [key, computeActiveInheritancePoint(general, key)])
)
).toEqual({
lived_month: 12,
max_domestic_critical: 80,
active_action: 1.5,
unifier: 250,
tournament: 50,
max_belong: 90,
combat: 15,
sabotage: 40,
dex: 1_276.036,
betting: 5,
});
});
it('pays only Ref rebirth-enabled sources and retains the three delayed sources', () => {
const settlement = computeInheritanceSettlementBreakdown(general, true);
expect(settlement.earned).toEqual({
lived_month: 12,
max_domestic_critical: 0,
active_action: 1.5,
unifier: 0,
tournament: 50,
max_belong: 0,
combat: 15,
sabotage: 40,
dex: 638.018,
betting: 5,
});
expect(settlement.retained).toEqual({
max_domestic_critical: 80,
unifier: 250,
max_belong: 90,
});
expect(settlement.totalEarned).toBeCloseTo(761.518, 8);
});
it('uses the current domestic streak only as a live upgrade candidate for the stored maximum', () => {
expect(
computeActiveInheritancePoint(
{
meta: { max_domestic_critical: 120 },
inheritancePoints: { max_domestic_critical: 80 },
},
'max_domestic_critical'
)
).toBe(120);
expect(
computeActiveInheritancePoint(
{
meta: { max_domestic_critical: 0 },
inheritancePoints: { max_domestic_critical: 80 },
},
'max_domestic_critical'
)
).toBe(80);
});
});
@@ -251,7 +251,7 @@ describe('General Commands New Scenario', () => {
items: { horse: null, weapon: null, book: null, item: null },
},
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: { killturn: 24 },
meta: { killturn: 24, belong: 18, max_belong: 12 },
};
const snapshot: WorldSnapshot = {
@@ -390,6 +390,7 @@ describe('General Commands New Scenario', () => {
const g1_after_resign = world.getGeneral(1)!;
expect(g1_after_resign.nationId).toBe(0);
expect(g1_after_resign.meta.max_belong).toBe(18);
// 6. Retire (Needs age >= 60)
// Manually set age