feat: 여러 제약 조건 개선 및 테스트 케이스 수정

This commit is contained in:
2026-02-07 05:14:33 +00:00
parent 13d22ece4a
commit d888140cf3
4 changed files with 20 additions and 24 deletions
@@ -4,6 +4,7 @@ import {
beLord,
wanderingNation,
reqNationValue,
reqNationGeneralCount,
checkNationNameDuplicate,
beOpeningPart,
constructableCity,
@@ -89,7 +90,7 @@ export class ActionDefinition<
beOpeningPart(),
beLord(),
wanderingNation(),
reqNationValue('gennum', '수하 장수', '>=', 2),
reqNationGeneralCount(2),
checkNationNameDuplicate(args.nationName),
allowJoinAction(),
constructableCity(),
@@ -314,7 +314,7 @@ describe('Blank Start Scenario', () => {
const resLevel = evaluateActionConstraints(foundNationDef, ctx, view, FOUNDING_ARGS);
expect(resLevel.kind).toBe('deny');
if (resLevel.kind === 'deny') {
expect(resLevel.constraintName).toBe('reqCityLevel');
expect(resLevel.constraintName).toBe('constructableCity');
}
});
@@ -159,7 +159,7 @@ describe('che_NPC능동', () => {
expect(updated?.cityId).toBe(destCityId);
});
it('should deny non-NPC general', async () => {
it('should reject non-NPC general at resolve stage', async () => {
const bootstrapResult = buildScenarioBootstrap({
scenario: MOCK_SCENARIO_BASE,
map: MINIMAL_MAP,
@@ -209,10 +209,19 @@ describe('che_NPC능동', () => {
const result = evaluateActionConstraints(def, ctx, view, args);
expect(result.kind).toBe('deny');
if (result.kind === 'deny') {
expect(result.constraintName).toBe('mustBeNPC');
}
expect(result.kind).toBe('allow');
const runner = new TestGameRunner(world, 200, 1);
await expect(
runner.runTurn([
{
generalId: general.id,
commandKey: 'che_NPC능동',
resolver: def,
args,
},
])
).rejects.toThrow('NPC가 아닙니다.');
});
it('should fail if args are invalid', async () => {
@@ -385,7 +385,7 @@ describe('che_등용수락', () => {
const monarch: General = {
id: 1,
name: 'Monarch',
nationId: 1,
nationId: 0,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
@@ -410,19 +410,6 @@ describe('che_등용수락', () => {
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: { killturn: 24 },
};
const nation1: Nation = {
id: 1,
name: 'Nation1',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: { killturn: 24 },
};
const recruiterGen: General = {
id: 2,
name: 'Recruiter',
@@ -462,7 +449,6 @@ describe('che_등용수락', () => {
world.snapshot.generals.push(monarch);
world.snapshot.generals.push(recruiterGen);
world.snapshot.nations.push(nation1);
world.snapshot.nations.push(nation2);
const { commandSpec } = await import('../../../src/actions/turn/general/che_등용수락.js');
@@ -475,7 +461,7 @@ describe('che_등용수락', () => {
const result = evaluateActionConstraints(def, ctx, view, args);
expect(result.kind).toBe('deny');
if (result.kind === 'deny') {
expect(result.constraintName).toMatch(/NotLord/i);
expect(result.constraintName).toBe('reqGeneralValue');
}
});
@@ -565,7 +551,7 @@ describe('che_등용수락', () => {
const result = evaluateActionConstraints(def, ctx, view, args);
expect(result.kind).toBe('deny');
if (result.kind === 'deny') {
expect(result.constraintName).toMatch(/notSameDestNation/i);
expect(result.constraintName).toBe('beNeutral');
}
});
});