feat: port scenario action effects
This commit is contained in:
@@ -2,6 +2,7 @@ import { LiteHashDRBG, RandUtil, type RNG } from '@sammo-ts/common';
|
||||
import {
|
||||
GENERAL_TURN_COMMAND_KEYS,
|
||||
NATION_TURN_COMMAND_KEYS,
|
||||
normalizeScenarioEffect,
|
||||
type MapDefinition,
|
||||
type Nation,
|
||||
type TurnCommandProfile,
|
||||
@@ -51,6 +52,7 @@ export interface TurnCommandFixtureRequest {
|
||||
year?: number;
|
||||
month?: number;
|
||||
hiddenSeed?: string;
|
||||
scenarioEffect?: string | null;
|
||||
staticEventHandlers?: Record<string, string[]>;
|
||||
};
|
||||
isolateWorld?: boolean;
|
||||
@@ -428,7 +430,13 @@ export const buildCoreTurnCommandWorldInput = (
|
||||
? { staticEventHandlers: request.setup.world.staticEventHandlers }
|
||||
: {}),
|
||||
},
|
||||
environment: { mapName: map.id, unitSet: unitSet.id },
|
||||
environment: {
|
||||
mapName: map.id,
|
||||
unitSet: unitSet.id,
|
||||
...(request.setup?.world?.scenarioEffect !== undefined
|
||||
? { scenarioEffect: normalizeScenarioEffect(request.setup.world.scenarioEffect) }
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
scenarioMeta: {
|
||||
title: '턴 명령 차등',
|
||||
|
||||
@@ -25,6 +25,20 @@ const withProjectedTraceMeta = (trace: CanonicalTurnCommandTrace): CanonicalTurn
|
||||
after: withProjectedGeneralMeta(trace.after),
|
||||
});
|
||||
|
||||
const referenceRunnerEnvironment = (workspaceRoot: string, stackDirectory: string): NodeJS.ProcessEnv => {
|
||||
const compareSourceRoot = process.env.REF_COMPARE_SOURCE_ROOT;
|
||||
return {
|
||||
...process.env,
|
||||
TURN_DIFFERENTIAL_STACK_DIR: stackDirectory,
|
||||
...(compareSourceRoot
|
||||
? {
|
||||
TURN_DIFFERENTIAL_APP_DIR: path.resolve(compareSourceRoot),
|
||||
TURN_DIFFERENTIAL_RUNTIME_DIR: path.join(workspaceRoot, 'ref/sam'),
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
};
|
||||
|
||||
export const findTurnDifferentialWorkspaceRoot = (start: string): string | null => {
|
||||
let current = path.resolve(start);
|
||||
while (true) {
|
||||
@@ -82,8 +96,7 @@ export const runReferenceTurnCommandTrace = (workspaceRoot: string, fixturePath:
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
env: {
|
||||
...process.env,
|
||||
TURN_DIFFERENTIAL_STACK_DIR: stackDirectory,
|
||||
...referenceRunnerEnvironment(workspaceRoot, stackDirectory),
|
||||
},
|
||||
});
|
||||
return withProjectedTraceMeta(JSON.parse(stdout) as CanonicalTurnCommandTrace);
|
||||
@@ -101,8 +114,7 @@ export const runReferenceTurnCommandTraceRequest = (
|
||||
encoding: 'utf8',
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
env: {
|
||||
...process.env,
|
||||
TURN_DIFFERENTIAL_STACK_DIR: stackDirectory,
|
||||
...referenceRunnerEnvironment(workspaceRoot, stackDirectory),
|
||||
},
|
||||
});
|
||||
return withProjectedTraceMeta(JSON.parse(stdout) as CanonicalTurnCommandTrace);
|
||||
|
||||
Reference in New Issue
Block a user