fix: align scenario 2400 long-run parity

This commit is contained in:
2026-08-04 18:15:32 +00:00
parent 8b8a285bc7
commit cef6a90452
30 changed files with 521 additions and 184 deletions
@@ -6,6 +6,8 @@ import type { WorldSnapshot } from '../../src/world/types.js';
import {
commandSpec as procureSpec,
roundLegacyAccumulatedInteger,
resolveLegacyDedicationLevel,
resolveLegacyExperienceLevel,
} from '../../src/actions/turn/general/che_물자조달.js';
import { commandSpec as donateSpec } from '../../src/actions/turn/general/che_헌납.js';
import { commandSpec as moveSpec } from '../../src/actions/turn/general/che_이동.js';
@@ -37,11 +39,9 @@ import {
readLegacyStoredTech,
toLegacyStoredTech,
} from '../../src/actions/turn/general/che_기술연구.js';
import {
readLegacyCityTrust,
storeLegacyCityTrust,
} from '../../src/actions/turn/general/legacyCityTrust.js';
import { readLegacyCityTrust, storeLegacyCityTrust } from '../../src/actions/turn/general/legacyCityTrust.js';
import { roundLegacyRecruitCost } from '../../src/actions/turn/general/che_징병.js';
import { resolveLegacyDomesticTrust } from '../../src/actions/turn/general/che_상업투자.js';
describe('General Commands New Scenario', () => {
it('truncates generated NPC dex like GeneralBuilder integer arguments', () => {
@@ -55,6 +55,14 @@ describe('General Commands New Scenario', () => {
expect(roundLegacyAccumulatedInteger(4554, delta)).toBe(4565);
});
it('calculates procurement levels before MariaDB rounds the INT columns', () => {
expect(Math.round(5_759.5)).toBe(5_760);
expect(resolveLegacyExperienceLevel(5_759.5)).toBe(23);
expect(Math.round(6_249.5)).toBe(6_250);
expect(resolveLegacyExperienceLevel(6_249.5)).toBe(24);
expect(resolveLegacyDedicationLevel(6_400.4)).toBe(9);
});
it('persists generated NPC speciality ages from the legacy creation date', () => {
expect(resolveLegacySpecialityAge(80, 22, 12)).toBe(27);
expect(resolveLegacySpecialityAge(80, 22, 6)).toBe(32);
@@ -86,6 +94,12 @@ describe('General Commands New Scenario', () => {
expect(roundLegacyRecruitCost(cavalryCost)).toBe(886);
});
it('uses the legacy minimum trust for domestic calculations', () => {
expect(resolveLegacyDomesticTrust(44.5321)).toBe(50);
expect(resolveLegacyDomesticTrust(80)).toBe(80);
expect(resolveLegacyDomesticTrust(null)).toBe(50);
});
// 1. Setup Environment
const systemEnv: TurnCommandEnv = {
develCost: 100,
+2
View File
@@ -6,6 +6,8 @@ describe('legacy war rounding', () => {
it('matches PHP round() at drifted positive and negative half boundaries', () => {
expect(round(4159.499999999999)).toBe(4160);
expect(round(-4159.499999999999)).toBe(-4160);
expect(round(8719.4999999999945)).toBe(8720);
expect(round(-8719.4999999999945)).toBe(-8720);
});
it('keeps values meaningfully below a half boundary on the lower integer', () => {
+8 -1
View File
@@ -175,9 +175,16 @@ describe('scenario bootstrap', () => {
specialDomestic: 'che_event_돌격',
specialWar: null,
});
expect(result.snapshot.generals[0]?.meta).toMatchObject({ specage: 25, specage2: 30 });
expect(result.snapshot.generals[0]?.meta).toMatchObject({
explevel: 0,
dedlevel: 1,
specage: 25,
specage2: 30,
});
expect(result.seed.generals[0]?.meta).toMatchObject({
deathMonth: expect.any(Number),
explevel: 0,
dedlevel: 1,
specage: 25,
specage2: 30,
});