This commit is contained in:
2026-01-11 10:05:42 +00:00
parent dc0b9271fb
commit 373ddd863d
8 changed files with 774 additions and 226 deletions
@@ -101,7 +101,6 @@ function createViewState(world: InMemoryWorld, year: number = 200, env: TurnComm
}
describe('che_NPC능동', () => {
it('should allow NPC to teleport with "순간이동"', async () => {
const bootstrapResult = buildScenarioBootstrap({
scenario: MOCK_SCENARIO_BASE,
@@ -125,7 +124,12 @@ describe('che_NPC능동', () => {
experience: 0,
dedication: 0,
officerLevel: 0,
role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
@@ -144,9 +148,11 @@ describe('che_NPC능동', () => {
{
generalId: general.id,
commandKey: 'che_NPC능동',
resolver: (await import('../../../src/actions/turn/general/che_NPC능동.js')).commandSpec.createDefinition({} as any),
resolver: (
await import('../../../src/actions/turn/general/che_NPC능동.js')
).commandSpec.createDefinition({} as any),
args: { optionText: '순간이동', destCityId },
}
},
]);
const updated = world.getGeneral(general.id);
@@ -173,7 +179,12 @@ describe('che_NPC능동', () => {
experience: 0,
dedication: 0,
officerLevel: 0,
role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
@@ -188,7 +199,9 @@ describe('che_NPC능동', () => {
};
world.snapshot.generals.push(general);
const def = (await import('../../../src/actions/turn/general/che_NPC능동.js')).commandSpec.createDefinition({} as any);
const def = (await import('../../../src/actions/turn/general/che_NPC능동.js')).commandSpec.createDefinition(
{} as any
);
const args = { optionText: '순간이동', destCityId };
const ctx = createConstraintContext(general, 200, args);
@@ -35,11 +35,56 @@ const LINEAR_MAP: MapDefinition = {
id: 'linear_map',
name: 'Linear Map',
cities: [
{ id: 101, name: 'City1', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [102], max: {} as any, initial: {} as any },
{ id: 102, name: 'City2', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [101, 103], max: {} as any, initial: {} as any },
{ id: 103, name: 'City3', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [102, 104], max: {} as any, initial: {} as any },
{ id: 104, name: 'City4', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [103, 105], max: {} as any, initial: {} as any },
{ id: 105, name: 'City5', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [104], max: {} as any, initial: {} as any },
{
id: 101,
name: 'City1',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [102],
max: {} as any,
initial: {} as any,
},
{
id: 102,
name: 'City2',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [101, 103],
max: {} as any,
initial: {} as any,
},
{
id: 103,
name: 'City3',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [102, 104],
max: {} as any,
initial: {} as any,
},
{
id: 104,
name: 'City4',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [103, 105],
max: {} as any,
initial: {} as any,
},
{
id: 105,
name: 'City5',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [104],
max: {} as any,
initial: {} as any,
},
],
defaults: { trust: 50, trade: 100, supplyState: 1, frontState: 0 },
};
@@ -140,7 +185,12 @@ describe('che_강행', () => {
experience: 1000,
dedication: 0,
officerLevel: 1,
role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
@@ -154,18 +204,29 @@ describe('che_강행', () => {
meta: {},
};
const nation: Nation = {
id: 1, name: 'MyNation', color: '#000', capitalCityId: 101, chiefGeneralId: 1,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 1,
name: 'MyNation',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(general);
world.snapshot.nations.push(nation);
// Move 101 -> 104 (dist 3) OK
const definition = (await import('../../../src/actions/turn/general/che_강행.js')).commandSpec.createDefinition({
scenarioConfig: { const: { develCost: 10 } } as any,
worldRef: { listGenerals: () => world.getAllGenerals() } as any, // Mock world ref context
map: LINEAR_MAP
} as any);
const definition = (await import('../../../src/actions/turn/general/che_강행.js')).commandSpec.createDefinition(
{
scenarioConfig: { const: { develCost: 10 } } as any,
worldRef: { listGenerals: () => world.getAllGenerals() } as any, // Mock world ref context
map: LINEAR_MAP,
} as any
);
await runner.runTurn([
{
@@ -175,9 +236,9 @@ describe('che_강행', () => {
args: { destCityId: 104 },
context: {
map: LINEAR_MAP,
startDevelCost: 10
}
}
startDevelCost: 10,
},
},
]);
const updated = world.getGeneral(general.id);
@@ -206,7 +267,12 @@ describe('che_강행', () => {
experience: 1000,
dedication: 0,
officerLevel: 1,
role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
@@ -220,18 +286,29 @@ describe('che_강행', () => {
meta: {},
};
const nation: Nation = {
id: 1, name: 'MyNation', color: '#000', capitalCityId: 101, chiefGeneralId: 1,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 1,
name: 'MyNation',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(general);
world.snapshot.nations.push(nation);
// Move 101 -> 105 (dist 4) Fail
const definition = (await import('../../../src/actions/turn/general/che_강행.js')).commandSpec.createDefinition({
scenarioConfig: { const: { develCost: 10 } } as any,
worldRef: { listGenerals: () => world.getAllGenerals() } as any,
map: LINEAR_MAP
} as any);
const definition = (await import('../../../src/actions/turn/general/che_강행.js')).commandSpec.createDefinition(
{
scenarioConfig: { const: { develCost: 10 } } as any,
worldRef: { listGenerals: () => world.getAllGenerals() } as any,
map: LINEAR_MAP,
} as any
);
// Manual constraint check
const args = { destCityId: 105 };
@@ -258,35 +335,88 @@ describe('che_강행', () => {
const runner = new TestGameRunner(world, 200, 1);
const leader: General = {
id: 1, name: 'Leader', nationId: 1, cityId: 101, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 12, role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 50, atmos: 50, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 1,
name: 'Leader',
nationId: 1,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 12,
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 50,
atmos: 50,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const sub: General = {
id: 2, name: 'Sub', nationId: 1, cityId: 101, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 1, role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 50, atmos: 50, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 2,
name: 'Sub',
nationId: 1,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 1,
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 50,
atmos: 50,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const nation: Nation = {
id: 1, name: 'RoamingNation', color: '#000', capitalCityId: 101, chiefGeneralId: 1,
gold: 0, rice: 0, power: 0,
id: 1,
name: 'RoamingNation',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 0, // Roaming
typeCode: 'che_def', meta: {},
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(leader);
world.snapshot.generals.push(sub);
world.snapshot.nations.push(nation);
const definition = (await import('../../../src/actions/turn/general/che_강행.js')).commandSpec.createDefinition({
scenarioConfig: { const: { develCost: 10 } } as any,
worldRef: { listGenerals: () => world.getAllGenerals() } as any, // Must return valid list
map: LINEAR_MAP
} as any);
const definition = (await import('../../../src/actions/turn/general/che_강행.js')).commandSpec.createDefinition(
{
scenarioConfig: { const: { develCost: 10 } } as any,
worldRef: { listGenerals: () => world.getAllGenerals() } as any, // Must return valid list
map: LINEAR_MAP,
} as any
);
await runner.runTurn([
{
@@ -297,9 +427,9 @@ describe('che_강행', () => {
context: {
map: LINEAR_MAP,
startDevelCost: 10,
moveGenerals: world.getAllGenerals()
}
}
moveGenerals: world.getAllGenerals(),
},
},
]);
const updatedLeader = world.getGeneral(leader.id);
@@ -35,9 +35,36 @@ const LINEAR_MAP: MapDefinition = {
id: 'linear_map',
name: 'Linear Map',
cities: [
{ id: 101, name: 'CapitalCity', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [102], max: {} as any, initial: {} as any },
{ id: 102, name: 'OtherCity', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [101, 103], max: {} as any, initial: {} as any },
{ id: 103, name: 'OfficerCity', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [102], max: {} as any, initial: {} as any },
{
id: 101,
name: 'CapitalCity',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [102],
max: {} as any,
initial: {} as any,
},
{
id: 102,
name: 'OtherCity',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [101, 103],
max: {} as any,
initial: {} as any,
},
{
id: 103,
name: 'OfficerCity',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [102],
max: {} as any,
initial: {} as any,
},
],
defaults: { trust: 50, trade: 100, supplyState: 1, frontState: 0 },
};
@@ -78,7 +105,7 @@ function createConstraintContext(actor: General, year: number = 200, args: any =
world: { currentYear: year },
openingPartYear: systemEnv.openingPartYear,
map: LINEAR_MAP,
cities: LINEAR_MAP.cities
cities: LINEAR_MAP.cities,
},
mode: 'full',
};
@@ -119,7 +146,6 @@ function createViewState(world: InMemoryWorld, year: number = 200, env: TurnComm
}
describe('che_귀환', () => {
it('should return to capital if normal officer', async () => {
const bootstrapResult = buildScenarioBootstrap({
scenario: MOCK_SCENARIO_BASE,
@@ -129,14 +155,45 @@ describe('che_귀환', () => {
const runner = new TestGameRunner(world, 200, 1);
const general: General = {
id: 1, name: 'NormalOfficer', nationId: 1, cityId: 102, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 1, role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 1,
name: 'NormalOfficer',
nationId: 1,
cityId: 102,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 1,
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const nation: Nation = {
id: 1, name: 'MyNation', color: '#000', capitalCityId: 101, chiefGeneralId: 1,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 1,
name: 'MyNation',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(general);
world.snapshot.nations.push(nation);
@@ -145,9 +202,11 @@ describe('che_귀환', () => {
{
generalId: general.id,
commandKey: 'che_귀환',
resolver: (await import('../../../src/actions/turn/general/che_귀환.js')).commandSpec.createDefinition({} as any),
resolver: (await import('../../../src/actions/turn/general/che_귀환.js')).commandSpec.createDefinition(
{} as any
),
args: {},
}
},
]);
const updated = world.getGeneral(general.id);
@@ -168,15 +227,45 @@ describe('che_귀환', () => {
const runner = new TestGameRunner(world, 200, 1);
const general: General = {
id: 1, name: 'Governor', nationId: 1, cityId: 102, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 4, role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
id: 1,
name: 'Governor',
nationId: 1,
cityId: 102,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 4,
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: { officer_city: 103 },
};
const nation: Nation = {
id: 1, name: 'MyNation', color: '#000', capitalCityId: 101, chiefGeneralId: 1,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 1,
name: 'MyNation',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(general);
world.snapshot.nations.push(nation);
@@ -185,9 +274,11 @@ describe('che_귀환', () => {
{
generalId: general.id,
commandKey: 'che_귀환',
resolver: (await import('../../../src/actions/turn/general/che_귀환.js')).commandSpec.createDefinition({} as any),
resolver: (await import('../../../src/actions/turn/general/che_귀환.js')).commandSpec.createDefinition(
{} as any
),
args: {},
}
},
]);
const updated = world.getGeneral(general.id);
@@ -202,19 +293,52 @@ describe('che_귀환', () => {
const world = new InMemoryWorld(bootstrapResult.snapshot);
const general: General = {
id: 1, name: 'AlreadyHome', nationId: 1, cityId: 101, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 1, role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 1,
name: 'AlreadyHome',
nationId: 1,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 1,
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const nation: Nation = {
id: 1, name: 'MyNation', color: '#000', capitalCityId: 101, chiefGeneralId: 1,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 1,
name: 'MyNation',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(general);
world.snapshot.nations.push(nation);
const def = (await import('../../../src/actions/turn/general/che_귀환.js')).commandSpec.createDefinition({} as any);
const def = (await import('../../../src/actions/turn/general/che_귀환.js')).commandSpec.createDefinition(
{} as any
);
const args = {};
const ctx = createConstraintContext(general, 200, args);
@@ -251,15 +375,45 @@ describe('che_귀환', () => {
const runner = new TestGameRunner(world, 200, 1);
const general: General = {
id: 1, name: 'GovernorAtHome', nationId: 1, cityId: 103, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 4, role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
id: 1,
name: 'GovernorAtHome',
nationId: 1,
cityId: 103,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 4,
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: { officer_city: 103 },
};
const nation: Nation = {
id: 1, name: 'MyNation', color: '#000', capitalCityId: 101, chiefGeneralId: 1,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 1,
name: 'MyNation',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(general);
world.snapshot.nations.push(nation);
@@ -271,9 +425,11 @@ describe('che_귀환', () => {
{
generalId: general.id,
commandKey: 'che_귀환',
resolver: (await import('../../../src/actions/turn/general/che_귀환.js')).commandSpec.createDefinition({} as any),
resolver: (await import('../../../src/actions/turn/general/che_귀환.js')).commandSpec.createDefinition(
{} as any
),
args: {},
}
},
]);
const updated = world.getGeneral(general.id);
@@ -1,4 +1,3 @@
import { describe, expect, it } from 'vitest';
import type { General, Nation } from '../../../src/domain/entities.js';
import { buildScenarioBootstrap } from '../../../src/world/bootstrap.js';
@@ -36,8 +35,26 @@ const MINIMAL_MAP = {
id: 'minimal_map',
name: 'Minimal Map',
cities: [
{ id: 101, name: 'Capital1', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [], max: {} as any, initial: {} as any },
{ id: 102, name: 'Capital2', level: 1, region: 1, position: { x: 0, y: 0 }, connections: [], max: {} as any, initial: {} as any },
{
id: 101,
name: 'Capital1',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [],
max: {} as any,
initial: {} as any,
},
{
id: 102,
name: 'Capital2',
level: 1,
region: 1,
position: { x: 0, y: 0 },
connections: [],
max: {} as any,
initial: {} as any,
},
],
defaults: { trust: 50, trade: 100, supplyState: 1, frontState: 0 },
};
@@ -78,7 +95,7 @@ function createConstraintContext(actor: General, year: number = 200, args: any =
world: { currentYear: year },
openingPartYear: systemEnv.openingPartYear,
map: MINIMAL_MAP,
cities: MINIMAL_MAP.cities
cities: MINIMAL_MAP.cities,
},
mode: 'full',
};
@@ -131,21 +148,70 @@ describe('che_등용수락', () => {
const runner = new TestGameRunner(world, 200, 1);
const neutralGen: General = {
id: 1, name: 'Neutral', nationId: 0, cityId: 101, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 0, role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 1,
name: 'Neutral',
nationId: 0,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 0,
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const recruiterGen: General = {
id: 2, name: 'Recruiter', nationId: 2, cityId: 102, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 1, role: null as any, injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 2,
name: 'Recruiter',
nationId: 2,
cityId: 102,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 1,
role: null as any,
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const nation2: Nation = {
id: 2, name: 'Nation2', color: '#000', capitalCityId: 102, chiefGeneralId: 2,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 2,
name: 'Nation2',
color: '#000',
capitalCityId: 102,
chiefGeneralId: 2,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(neutralGen);
@@ -156,14 +222,16 @@ describe('che_등용수락', () => {
{
generalId: neutralGen.id,
commandKey: 'che_등용수락',
resolver: (await import('../../../src/actions/turn/general/che_등용수락.js')).commandSpec.createDefinition({} as any),
resolver: (
await import('../../../src/actions/turn/general/che_등용수락.js')
).commandSpec.createDefinition({} as any),
args: { destNationId: 2, destGeneralId: 2 },
context: {
destNation: nation2,
destGeneral: recruiterGen,
env: systemEnv
}
}
env: systemEnv,
},
},
]);
const updatedSelf = world.getGeneral(neutralGen.id);
@@ -188,24 +256,77 @@ describe('che_등용수락', () => {
const runner = new TestGameRunner(world, 200, 1);
const betrayer: General = {
id: 1, name: 'Betrayer', nationId: 1, cityId: 101, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 1000, dedication: 1000,
officerLevel: 1, role: null as any, injury: 0, gold: 2000, rice: 2000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
id: 1,
name: 'Betrayer',
nationId: 1,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 1000,
dedication: 1000,
officerLevel: 1,
role: null as any,
injury: 0,
gold: 2000,
rice: 2000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: { betray: 1 },
};
const nation1: Nation = {
id: 1, name: 'Nation1', color: '#000', capitalCityId: 101, chiefGeneralId: 0,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 1,
name: 'Nation1',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 0,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
const recruiterGen: General = {
id: 2, name: 'Recruiter', nationId: 2, cityId: 102, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 1, role: null as any, injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 2,
name: 'Recruiter',
nationId: 2,
cityId: 102,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 1,
role: null as any,
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const nation2: Nation = {
id: 2, name: 'Nation2', color: '#000', capitalCityId: 102, chiefGeneralId: 2,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 2,
name: 'Nation2',
color: '#000',
capitalCityId: 102,
chiefGeneralId: 2,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(betrayer);
@@ -217,14 +338,16 @@ describe('che_등용수락', () => {
{
generalId: betrayer.id,
commandKey: 'che_등용수락',
resolver: (await import('../../../src/actions/turn/general/che_등용수락.js')).commandSpec.createDefinition({} as any),
resolver: (
await import('../../../src/actions/turn/general/che_등용수락.js')
).commandSpec.createDefinition({} as any),
args: { destNationId: 2, destGeneralId: 2 },
context: {
destNation: nation2,
destGeneral: recruiterGen,
env: systemEnv
}
}
env: systemEnv,
},
},
]);
const updatedSelf = world.getGeneral(betrayer.id);
@@ -248,23 +371,81 @@ describe('che_등용수락', () => {
const world = new InMemoryWorld(bootstrapResult.snapshot);
const monarch: General = {
id: 1, name: 'Monarch', nationId: 1, cityId: 101, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 12, role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 1,
name: 'Monarch',
nationId: 1,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 12,
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
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: {},
id: 1,
name: 'Nation1',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
const recruiterGen: General = {
id: 2, name: 'Recruiter', nationId: 2, cityId: 102, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 1, role: null as any, injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 2,
name: 'Recruiter',
nationId: 2,
cityId: 102,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 1,
role: null as any,
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const nation2: Nation = {
id: 2, name: 'Nation2', color: '#000', capitalCityId: 102, chiefGeneralId: 2,
gold: 0, rice: 0, power: 0, level: 1, typeCode: 'che_def', meta: {},
id: 2,
name: 'Nation2',
color: '#000',
capitalCityId: 102,
chiefGeneralId: 2,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
world.snapshot.generals.push(monarch);
@@ -273,7 +454,9 @@ describe('che_등용수락', () => {
world.snapshot.nations.push(nation2);
// Manually check constraints for denial
const def = (await import('../../../src/actions/turn/general/che_등용수락.js')).commandSpec.createDefinition({} as any);
const def = (await import('../../../src/actions/turn/general/che_등용수락.js')).commandSpec.createDefinition(
{} as any
);
const args = { destNationId: 2, destGeneralId: 2 };
const ctx = createConstraintContext(monarch, 200, args);
@@ -283,7 +466,7 @@ describe('che_등용수락', () => {
expect(result.kind).toBe('deny');
if (result.kind === 'deny') {
const reason = result.constraintName || result.reason;
// notLord constraint failure.
// notLord constraint failure.
// In TS presets, notLord(monarch) returns deny.
// ConstraintName should be 'notLord' or 'NotLord'.
expect(result.constraintName).toMatch(/NotLord/i);
@@ -298,27 +481,74 @@ describe('che_등용수락', () => {
const world = new InMemoryWorld(bootstrapResult.snapshot);
const general: General = {
id: 1, name: 'Gen1', nationId: 1, cityId: 101, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 1, role: null as any, injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 1,
name: 'Gen1',
nationId: 1,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 1,
role: null as any,
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
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: {},
id: 1,
name: 'Nation1',
color: '#000',
capitalCityId: 101,
chiefGeneralId: 1,
gold: 0,
rice: 0,
power: 0,
level: 1,
typeCode: 'che_def',
meta: {},
};
// Recruiter also in same nation? Or different?
// Arg destNationId is key.
const recruiterGen: General = {
id: 2, name: 'Recruiter', nationId: 1, cityId: 101, troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 }, experience: 0, dedication: 0,
officerLevel: 1, role: null as any, injury: 0, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0, train: 0, atmos: 0, age: 20, npcState: 0, triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {},
id: 2,
name: 'Recruiter',
nationId: 1,
cityId: 101,
troopId: 0,
stats: { leadership: 50, strength: 50, intelligence: 50 },
experience: 0,
dedication: 0,
officerLevel: 1,
role: null as any,
injury: 0,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 0,
atmos: 0,
age: 20,
npcState: 0,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
world.snapshot.generals.push(general);
world.snapshot.generals.push(recruiterGen);
world.snapshot.nations.push(nation1);
const def = (await import('../../../src/actions/turn/general/che_등용수락.js')).commandSpec.createDefinition({} as any);
const def = (await import('../../../src/actions/turn/general/che_등용수락.js')).commandSpec.createDefinition(
{} as any
);
const args = { destNationId: 1, destGeneralId: 2 }; // Target same nation 1
const ctx = createConstraintContext(general, 200, args);