feat: enhance action context with diplomacy and map handling, add constraints for crew and route validation
This commit is contained in:
@@ -403,6 +403,7 @@ const ACTION_CONTEXT_BUILDERS: Record<string, ActionContextBuilder> = {
|
||||
destCity.nationId > 0
|
||||
? options.worldRef.getNationById(destCity.nationId)
|
||||
: null;
|
||||
const diplomacy = options.worldRef.listDiplomacy();
|
||||
const warConfig = buildWarConfig(options.scenarioConfig, options.unitSet);
|
||||
const aftermathConfig = buildWarAftermathConfig(
|
||||
options.scenarioConfig,
|
||||
@@ -416,6 +417,8 @@ const ACTION_CONTEXT_BUILDERS: Record<string, ActionContextBuilder> = {
|
||||
nations: options.worldRef.listNations(),
|
||||
generals: options.worldRef.listGenerals(),
|
||||
unitSet: options.unitSet,
|
||||
map: options.map,
|
||||
diplomacy,
|
||||
time: buildWarTime(options.world, options.scenarioMeta),
|
||||
seedBase: options.seedBase,
|
||||
warConfig,
|
||||
|
||||
@@ -42,7 +42,8 @@ const asRecord = (value: unknown): Record<string, unknown> =>
|
||||
|
||||
const resolveConstraintEnv = (
|
||||
world: TurnWorldState,
|
||||
scenarioMeta?: ScenarioMeta
|
||||
scenarioMeta: ScenarioMeta | undefined,
|
||||
openingPartYear: number
|
||||
): Record<string, unknown> => {
|
||||
const startYear =
|
||||
typeof scenarioMeta?.startYear === 'number'
|
||||
@@ -60,6 +61,7 @@ const resolveConstraintEnv = (
|
||||
month: world.currentMonth,
|
||||
startYear,
|
||||
relYear,
|
||||
openingPartYear,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -233,10 +235,15 @@ export const createReservedTurnHandler = async (options: {
|
||||
execute(context): GeneralTurnResult {
|
||||
const worldRef = options.getWorld();
|
||||
const constraintEnv = {
|
||||
...resolveConstraintEnv(context.world, options.scenarioMeta),
|
||||
...resolveConstraintEnv(
|
||||
context.world,
|
||||
options.scenarioMeta,
|
||||
env.openingPartYear
|
||||
),
|
||||
...(options.map ? { map: options.map } : {}),
|
||||
...(options.unitSet ? { unitSet: options.unitSet } : {}),
|
||||
cities: worldRef?.listCities() ?? [],
|
||||
nations: worldRef?.listNations() ?? [],
|
||||
};
|
||||
const logs: LogEntryDraft[] = [];
|
||||
const patches = {
|
||||
|
||||
Reference in New Issue
Block a user