fix(parity): preserve legacy monthly turn ordering

This commit is contained in:
2026-08-15 09:40:14 +00:00
parent 47e629eb4b
commit b9e45c6e76
26 changed files with 393 additions and 58 deletions
@@ -1,4 +1,4 @@
import { LiteHashDRBG, RandUtil, asRecord } from '@sammo-ts/common';
import { GAME_TICKS_PER_TURN, LiteHashDRBG, RandUtil, asRecord } from '@sammo-ts/common';
import {
LogCategory,
LogFormat,
@@ -145,9 +145,12 @@ const createNpcGeneral = (options: {
}
const turnSecond = rng.nextRangeInt(0, turnMinutes * 60 - 1);
const turnFraction = rng.nextRangeInt(0, 999_999);
const turnTime = new Date(
environment.turnTime.getTime() + turnSecond * 1_000 + Math.floor(turnFraction / 1_000)
);
const ticksPerSecond = GAME_TICKS_PER_TURN / world.getState().tickSeconds;
const turnTick =
world.dateToGameTick(environment.turnTime) +
turnSecond * ticksPerSecond +
Math.floor((turnFraction * ticksPerSecond) / 1_000_000);
const turnTime = world.gameTickToDate(turnTick);
const killturn =
options.killturn ??
(options.deadYear - environment.year) * 12 +
@@ -188,6 +191,7 @@ const createNpcGeneral = (options: {
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
lastTurn: { command: '휴식' },
turnTime,
turnTick,
recentWarTime: null,
meta: {
killturn,