feat: 여러 제약 조건 개선 및 테스트 케이스 수정
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
beLord,
|
beLord,
|
||||||
wanderingNation,
|
wanderingNation,
|
||||||
reqNationValue,
|
reqNationValue,
|
||||||
|
reqNationGeneralCount,
|
||||||
checkNationNameDuplicate,
|
checkNationNameDuplicate,
|
||||||
beOpeningPart,
|
beOpeningPart,
|
||||||
constructableCity,
|
constructableCity,
|
||||||
@@ -89,7 +90,7 @@ export class ActionDefinition<
|
|||||||
beOpeningPart(),
|
beOpeningPart(),
|
||||||
beLord(),
|
beLord(),
|
||||||
wanderingNation(),
|
wanderingNation(),
|
||||||
reqNationValue('gennum', '수하 장수', '>=', 2),
|
reqNationGeneralCount(2),
|
||||||
checkNationNameDuplicate(args.nationName),
|
checkNationNameDuplicate(args.nationName),
|
||||||
allowJoinAction(),
|
allowJoinAction(),
|
||||||
constructableCity(),
|
constructableCity(),
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ describe('Blank Start Scenario', () => {
|
|||||||
const resLevel = evaluateActionConstraints(foundNationDef, ctx, view, FOUNDING_ARGS);
|
const resLevel = evaluateActionConstraints(foundNationDef, ctx, view, FOUNDING_ARGS);
|
||||||
expect(resLevel.kind).toBe('deny');
|
expect(resLevel.kind).toBe('deny');
|
||||||
if (resLevel.kind === '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);
|
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({
|
const bootstrapResult = buildScenarioBootstrap({
|
||||||
scenario: MOCK_SCENARIO_BASE,
|
scenario: MOCK_SCENARIO_BASE,
|
||||||
map: MINIMAL_MAP,
|
map: MINIMAL_MAP,
|
||||||
@@ -209,10 +209,19 @@ describe('che_NPC능동', () => {
|
|||||||
|
|
||||||
const result = evaluateActionConstraints(def, ctx, view, args);
|
const result = evaluateActionConstraints(def, ctx, view, args);
|
||||||
|
|
||||||
expect(result.kind).toBe('deny');
|
expect(result.kind).toBe('allow');
|
||||||
if (result.kind === 'deny') {
|
|
||||||
expect(result.constraintName).toBe('mustBeNPC');
|
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 () => {
|
it('should fail if args are invalid', async () => {
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ describe('che_등용수락', () => {
|
|||||||
const monarch: General = {
|
const monarch: General = {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Monarch',
|
name: 'Monarch',
|
||||||
nationId: 1,
|
nationId: 0,
|
||||||
cityId: 101,
|
cityId: 101,
|
||||||
troopId: 0,
|
troopId: 0,
|
||||||
stats: { leadership: 50, strength: 50, intelligence: 50 },
|
stats: { leadership: 50, strength: 50, intelligence: 50 },
|
||||||
@@ -410,19 +410,6 @@ describe('che_등용수락', () => {
|
|||||||
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
|
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
|
||||||
meta: { killturn: 24 },
|
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 = {
|
const recruiterGen: General = {
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'Recruiter',
|
name: 'Recruiter',
|
||||||
@@ -462,7 +449,6 @@ describe('che_등용수락', () => {
|
|||||||
|
|
||||||
world.snapshot.generals.push(monarch);
|
world.snapshot.generals.push(monarch);
|
||||||
world.snapshot.generals.push(recruiterGen);
|
world.snapshot.generals.push(recruiterGen);
|
||||||
world.snapshot.nations.push(nation1);
|
|
||||||
world.snapshot.nations.push(nation2);
|
world.snapshot.nations.push(nation2);
|
||||||
|
|
||||||
const { commandSpec } = await import('../../../src/actions/turn/general/che_등용수락.js');
|
const { commandSpec } = await import('../../../src/actions/turn/general/che_등용수락.js');
|
||||||
@@ -475,7 +461,7 @@ describe('che_등용수락', () => {
|
|||||||
const result = evaluateActionConstraints(def, ctx, view, args);
|
const result = evaluateActionConstraints(def, ctx, view, args);
|
||||||
expect(result.kind).toBe('deny');
|
expect(result.kind).toBe('deny');
|
||||||
if (result.kind === '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);
|
const result = evaluateActionConstraints(def, ctx, view, args);
|
||||||
expect(result.kind).toBe('deny');
|
expect(result.kind).toBe('deny');
|
||||||
if (result.kind === 'deny') {
|
if (result.kind === 'deny') {
|
||||||
expect(result.constraintName).toMatch(/notSameDestNation/i);
|
expect(result.constraintName).toBe('beNeutral');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user