perf: 전투 시뮬레이터 시작 payload를 줄인다
권위 실행 context를 화면 진입 때 한 번 전달하고 준비 응답은 seed base만 반환한다. 반복별 seed 배열은 결정적 파생값으로 대체하되 구형 queue seed 우선순위와 고정 seed 동작을 보존한다.
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
createCrewTypeWarTriggerRegistry,
|
||||
resolveDefenderOrder,
|
||||
resolveWarBattle,
|
||||
simpleSerialize,
|
||||
type WarBattleOutcome,
|
||||
type WarActionModule,
|
||||
type WarUnitReport,
|
||||
@@ -264,6 +265,17 @@ const resolveRandomSeed = (): string => {
|
||||
return globalThis.crypto.randomUUID();
|
||||
};
|
||||
|
||||
const resolveRepeatSeed = (payload: BattleSimJobPayload, index: number): string => {
|
||||
const legacySeed = payload.seeds?.[index];
|
||||
if (legacySeed) {
|
||||
return legacySeed;
|
||||
}
|
||||
if (payload.seedBase) {
|
||||
return simpleSerialize(payload.seedBase, 'battle-simulator', index);
|
||||
}
|
||||
return resolveRandomSeed();
|
||||
};
|
||||
|
||||
const resolveCityTrainAtmos = (year: number, startYear: number): number =>
|
||||
Math.min(110, Math.max(60, year - startYear + 59));
|
||||
|
||||
@@ -369,7 +381,7 @@ export const processBattleSimJob = (
|
||||
const weight = 1 / Math.max(1, repeatCnt);
|
||||
|
||||
for (let idx = 0; idx < repeatCnt; idx += 1) {
|
||||
const seed = baseSeed || payload.seeds?.[idx] || resolveRandomSeed();
|
||||
const seed = baseSeed || resolveRepeatSeed(payload, idx);
|
||||
const attackerNation = mapNationPayload(payload.attackerNation);
|
||||
const defenderNation = mapNationPayload(payload.defenderNation);
|
||||
const attackerCity = mapCityPayload(payload.attackerCity);
|
||||
|
||||
@@ -103,7 +103,9 @@ export interface BattleSimJobPayload extends BattleSimRequestPayload {
|
||||
config: WarEngineConfig;
|
||||
time: WarTimeContext;
|
||||
scenarioEffect?: string | null;
|
||||
/** Server-issued seeds make a repeated run exactly reproducible in Node and browser runtimes. */
|
||||
/** One secure random value expands deterministically into every repeated battle seed. */
|
||||
seedBase?: string;
|
||||
/** Legacy queue payload compatibility. New jobs use seedBase instead of an O(repeatCnt) array. */
|
||||
seeds?: string[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user