fix: match random capital move semantics
This commit is contained in:
@@ -105,6 +105,7 @@ export type GeneralActionEffect<TriggerState extends GeneralTriggerState = Gener
|
||||
|
||||
export interface GeneralActionOutcome<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
|
||||
effects: GeneralActionEffect<TriggerState>[];
|
||||
completed?: boolean;
|
||||
alternative?: {
|
||||
commandKey: string;
|
||||
args: unknown;
|
||||
@@ -120,6 +121,7 @@ export interface GeneralActionResolution {
|
||||
general: General;
|
||||
city?: City;
|
||||
nation?: Nation | null;
|
||||
completed: boolean;
|
||||
nextTurnAt: Date;
|
||||
logs: LogEntryDraft[];
|
||||
effects: GeneralActionEffect[];
|
||||
@@ -381,6 +383,7 @@ export const resolveGeneralAction = <TriggerState extends GeneralTriggerState =
|
||||
const resolution: GeneralActionResolution = {
|
||||
general: nextWorld.general as General,
|
||||
nation: nextWorld.nation as Nation | null,
|
||||
completed: outcome?.completed !== false,
|
||||
nextTurnAt,
|
||||
logs,
|
||||
effects: pendingEffects,
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface RandomMoveCapitalResolveContext<
|
||||
> extends GeneralActionResolveContext<TriggerState> {
|
||||
neutralCandidateCities: City[];
|
||||
nationGenerals: General<TriggerState>[];
|
||||
oldCapitalCity?: City;
|
||||
}
|
||||
|
||||
const ACTION_NAME = '무작위 수도 이전';
|
||||
@@ -81,13 +82,14 @@ export class ActionDefinition<
|
||||
context: RandomMoveCapitalResolveContext<TriggerState>,
|
||||
_args: RandomMoveCapitalArgs
|
||||
): GeneralActionOutcome<TriggerState> {
|
||||
const { general, nation, neutralCandidateCities, nationGenerals, rng } = context;
|
||||
const { general, nation, neutralCandidateCities, nationGenerals, oldCapitalCity, rng } = context;
|
||||
if (!nation) {
|
||||
return { effects: [createLogEffect('국가 정보가 없습니다.', { scope: LogScope.GENERAL })] };
|
||||
}
|
||||
|
||||
if (neutralCandidateCities.length === 0) {
|
||||
return {
|
||||
completed: false,
|
||||
effects: [
|
||||
createLogEffect(`이동할 수 있는 도시가 없습니다.`, {
|
||||
scope: LogScope.GENERAL,
|
||||
@@ -124,6 +126,7 @@ export class ActionDefinition<
|
||||
createCityPatchEffect(
|
||||
{
|
||||
nationId: nation.id,
|
||||
conflict: {},
|
||||
},
|
||||
destCity.id
|
||||
),
|
||||
@@ -132,6 +135,11 @@ export class ActionDefinition<
|
||||
{
|
||||
nationId: 0,
|
||||
frontState: 0,
|
||||
conflict: {},
|
||||
meta: {
|
||||
...oldCapitalCity?.meta,
|
||||
officer_set: 0,
|
||||
},
|
||||
},
|
||||
oldCityId!
|
||||
),
|
||||
@@ -213,11 +221,13 @@ export const actionContextBuilder: ActionContextBuilder = (base, options) => {
|
||||
const allCities = worldRef.listCities();
|
||||
const neutralCandidateCities = allCities.filter((c) => c.nationId === 0 && c.level >= 5 && c.level <= 6);
|
||||
const nationGenerals = worldRef.listGenerals().filter((g) => g.nationId === base.general.nationId);
|
||||
const oldCapitalCity = base.nation?.capitalCityId ? worldRef.getCityById(base.nation.capitalCityId) : undefined;
|
||||
|
||||
return {
|
||||
...base,
|
||||
neutralCandidateCities,
|
||||
nationGenerals,
|
||||
...(oldCapitalCity ? { oldCapitalCity } : {}),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ export const beOpeningPart = (): Constraint => ({
|
||||
return { kind: 'deny', reason: '초반 제한 중에는 불가능합니다.' };
|
||||
}
|
||||
|
||||
if (relYear + 1 <= openingPartYear) {
|
||||
if (relYear + 1 < openingPartYear) {
|
||||
return allow();
|
||||
}
|
||||
|
||||
@@ -47,12 +47,7 @@ export const beOpeningPart = (): Constraint => ({
|
||||
},
|
||||
});
|
||||
|
||||
export const reqEnvValue = (
|
||||
key: string,
|
||||
comp: CompareOperator,
|
||||
reqVal: unknown,
|
||||
failMessage: string
|
||||
): Constraint => ({
|
||||
export const reqEnvValue = (key: string, comp: CompareOperator, reqVal: unknown, failMessage: string): Constraint => ({
|
||||
name: 'reqEnvValue',
|
||||
requires: () => [{ kind: 'env', key }],
|
||||
test: (_ctx, view) => {
|
||||
|
||||
Reference in New Issue
Block a user