fix: preserve nation and recruit AI boundaries
This commit is contained in:
@@ -25,6 +25,7 @@ import type { NationTurnCommandSpec } from './index.js';
|
||||
import type { MapDefinition } from '@sammo-ts/logic/world/types.js';
|
||||
import { z } from 'zod';
|
||||
import { normalizeLegacyIntegerArg, parseArgsWithSchema } from '../parseArgs.js';
|
||||
import { GeneralActionPipeline } from '@sammo-ts/logic/actionModules/general.js';
|
||||
|
||||
const ARGS_SCHEMA = z.object({
|
||||
destCityID: z.preprocess(normalizeLegacyIntegerArg, z.number()),
|
||||
@@ -109,8 +110,11 @@ export class ActionDefinition<
|
||||
public readonly key = 'che_천도';
|
||||
public readonly name = ACTION_NAME;
|
||||
public readonly countsAsInheritanceActiveAction = true;
|
||||
private readonly pipeline: GeneralActionPipeline<TriggerState>;
|
||||
|
||||
constructor(private readonly env: TurnCommandEnv) {}
|
||||
constructor(private readonly env: TurnCommandEnv) {
|
||||
this.pipeline = new GeneralActionPipeline(env.generalActionModules ?? []);
|
||||
}
|
||||
|
||||
parseArgs(raw: unknown): MoveCapitalArgs | null {
|
||||
return parseArgsWithSchema(ARGS_SCHEMA, raw);
|
||||
@@ -256,8 +260,9 @@ export class ActionDefinition<
|
||||
}),
|
||||
];
|
||||
|
||||
general.experience += 5 * (dist * 2 + 1);
|
||||
general.dedication += 5 * (dist * 2 + 1);
|
||||
const reward = 5 * (dist * 2 + 1);
|
||||
general.experience += this.pipeline.onCalcStat(context, 'experience', reward);
|
||||
general.dedication += this.pipeline.onCalcStat(context, 'dedication', reward);
|
||||
|
||||
return { effects };
|
||||
}
|
||||
|
||||
@@ -343,12 +343,22 @@ describe('Nation Actions', () => {
|
||||
});
|
||||
|
||||
describe('che_천도 (Move Capital)', () => {
|
||||
it('changes nation capital city', () => {
|
||||
it('changes nation capital city and applies general reward modules', () => {
|
||||
const nation = buildNation(1);
|
||||
const city1 = buildCity(1, 1);
|
||||
const city2 = buildCity(2, 1);
|
||||
const general = buildGeneral(1, 1, 1);
|
||||
const env = { develCost: 100, baseGold: 100, baseRice: 100 };
|
||||
const env = {
|
||||
develCost: 100,
|
||||
baseGold: 100,
|
||||
baseRice: 100,
|
||||
generalActionModules: [
|
||||
{
|
||||
onCalcStat: (_context: unknown, statName: string, value: number) =>
|
||||
statName === 'experience' ? value * 0.9 : value,
|
||||
},
|
||||
],
|
||||
};
|
||||
const definition = new MoveCapitalAction(env as any);
|
||||
|
||||
const context = {
|
||||
@@ -374,6 +384,8 @@ describe('Nation Actions', () => {
|
||||
patch: expect.objectContaining({ capitalCityId: 2 }),
|
||||
})
|
||||
);
|
||||
expect(general.experience).toBe(113.5);
|
||||
expect(general.dedication).toBe(115);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user