refactor(logic): 과도한 수치 호환 보정을 제거한다

Core 수치 상태는 JavaScript와 PostgreSQL의 자연 정밀도를 유지한다. 정수 상태 경계와 절삭, 수입 배분 및 사망자 분할 순서는 보존한다.
This commit is contained in:
2026-08-24 19:17:06 +00:00
parent fc9fa0c9a6
commit 60dcf815ea
32 changed files with 148 additions and 522 deletions
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
import type { City, Nation, NationTraitModule } from '@sammo-ts/logic';
import { InMemoryTurnWorld } from '../src/turn/inMemoryWorld.js';
import { createProcessSemiAnnualHandler, storeLegacySemiAnnualTrust } from '../src/turn/monthlySemiAnnualAction.js';
import { clampSemiAnnualTrust, createProcessSemiAnnualHandler } from '../src/turn/monthlySemiAnnualAction.js';
import type { TurnEvent, TurnGeneral, TurnWorldSnapshot, TurnWorldState } from '../src/turn/types.js';
const buildCity = (id: number, patch: Partial<City> = {}): City => ({
@@ -151,9 +151,8 @@ const environment = {
};
describe('ProcessSemiAnnual monthly action', () => {
it('stores the adjusted trust at the MariaDB FLOAT boundary', () => {
expect(storeLegacySemiAnnualTrust(88.30675 + 10)).toBe(Math.fround(98.30675));
expect(storeLegacySemiAnnualTrust(88.30675 + 10)).not.toBe(98.30675);
it('keeps adjusted trust at full precision', () => {
expect(clampSemiAnnualTrust(88.30675 + 10)).toBe(98.30675);
});
it('preserves the global popIncrease order, neutral double decay, supplied filtering, and nation trait', async () => {
@@ -254,7 +253,7 @@ describe('ProcessSemiAnnual monthly action', () => {
await handler(['gold'], environment, event);
expect(world.getCityById(1)).toMatchObject({ defence: 2_030, wall: 2_030 });
expect(world.getCityById(1)).toMatchObject({ defence: 2_029, wall: 2_029 });
});
it('applies strict legacy resource thresholds to generals and nations for either resource', async () => {