refactor: apply consistent formatting and minor import adjustments across test and tsconfig files.

This commit is contained in:
2026-01-07 18:05:22 +00:00
parent 542a65c2a9
commit f62bbb7927
12 changed files with 419 additions and 195 deletions
+139 -41
View File
@@ -1,4 +1,3 @@
import { describe, expect, it } from 'vitest';
import { MINIMAL_MAP } from '../fixtures/minimalMap.js';
import { InMemoryWorld, TestGameRunner } from '../testEnv.js';
@@ -11,32 +10,83 @@ describe('Domestic Affairs Scenario', () => {
it('should increase agriculture when executing "Farming" command', async () => {
// 1. Setup World
const mockNation: Nation = {
id: 1, name: 'Test Nation', color: '#FF0000', capitalCityId: 1, chiefGeneralId: 1,
gold: 10000, rice: 10000, power: 0, level: 5, typeCode: 'test', meta: {}
id: 1,
name: 'Test Nation',
color: '#FF0000',
capitalCityId: 1,
chiefGeneralId: 1,
gold: 10000,
rice: 10000,
power: 0,
level: 5,
typeCode: 'test',
meta: {},
};
const cityDef = MINIMAL_MAP.cities[0];
if (!cityDef) throw new Error('City definition missing');
const mockCity: City = {
id: 1, name: cityDef.name, nationId: 1, level: 1, state: 0,
population: 10000, populationMax: 10000, agriculture: 500, agricultureMax: 1000,
commerce: 500, commerceMax: 1000, security: 500, securityMax: 1000,
defence: 500, defenceMax: 1000, wall: 500, wallMax: 1000,
supplyState: 1, frontState: 0, meta: {}
id: 1,
name: cityDef.name,
nationId: 1,
level: 1,
state: 0,
population: 10000,
populationMax: 10000,
agriculture: 500,
agricultureMax: 1000,
commerce: 500,
commerceMax: 1000,
security: 500,
securityMax: 1000,
defence: 500,
defenceMax: 1000,
wall: 500,
wallMax: 1000,
supplyState: 1,
frontState: 0,
meta: {},
};
const mockGeneral: General = {
id: 1, name: 'Domestic Officer', nationId: 1, cityId: 1, troopId: 0, npcState: 0,
experience: 100, dedication: 100, officerLevel: 5, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0,
train: 100, atmos: 100, injury: 0, age: 30,
id: 1,
name: 'Domestic Officer',
nationId: 1,
cityId: 1,
troopId: 0,
npcState: 0,
experience: 100,
dedication: 100,
officerLevel: 5,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 100,
atmos: 100,
injury: 0,
age: 30,
stats: { leadership: 50, strength: 50, intelligence: 100 },
role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {}
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const snapshot: WorldSnapshot = {
scenarioConfig: { environment: { mapName: 'minimal_map', unitSet: 'default' }, options: {} } as any,
scenarioMeta: { title: 'Test', startYear: 200, life: 0, fiction: 0, history: [], ignoreDefaultEvents: false },
scenarioMeta: {
title: 'Test',
startYear: 200,
life: 0,
fiction: 0,
history: [],
ignoreDefaultEvents: false,
},
map: MINIMAL_MAP,
unitSet: { id: 'default', name: 'default' },
nations: [mockNation],
@@ -45,7 +95,7 @@ describe('Domestic Affairs Scenario', () => {
troops: [],
diplomacy: [],
events: [],
initialEvents: []
initialEvents: [],
};
const world = new InMemoryWorld(snapshot);
@@ -74,18 +124,20 @@ describe('Domestic Affairs Scenario', () => {
maxTechLevel: 10,
baseGold: 1000,
baseRice: 1000,
maxResourceActionAmount: 1000
maxResourceActionAmount: 1000,
};
const farmingDef = developAgricultureSpec.createDefinition(systemEnv);
// 3. Execute
await runner.runTurn([{
generalId: 1,
commandKey: 'che_농지개간',
resolver: farmingDef,
args: {}
}]);
await runner.runTurn([
{
generalId: 1,
commandKey: 'che_농지개간',
resolver: farmingDef,
args: {},
},
]);
// 4. Verify
const updatedCity = world.getCity(1)!;
@@ -96,23 +148,67 @@ describe('Domestic Affairs Scenario', () => {
it('should not increase agriculture when city is already maxed', async () => {
// Setup with max agriculture
const mockNation: Nation = {
id: 1, name: 'Test Nation', color: '#FF0000', capitalCityId: 1, chiefGeneralId: 1,
gold: 10000, rice: 10000, power: 0, level: 5, typeCode: 'test', meta: {}
id: 1,
name: 'Test Nation',
color: '#FF0000',
capitalCityId: 1,
chiefGeneralId: 1,
gold: 10000,
rice: 10000,
power: 0,
level: 5,
typeCode: 'test',
meta: {},
};
const mockCity: City = {
id: 1, name: 'City A', nationId: 1, level: 1, state: 0,
population: 10000, populationMax: 10000, agriculture: 1000, agricultureMax: 1000,
commerce: 500, commerceMax: 1000, security: 500, securityMax: 1000,
defence: 500, defenceMax: 1000, wall: 500, wallMax: 1000,
supplyState: 1, frontState: 0, meta: {}
id: 1,
name: 'City A',
nationId: 1,
level: 1,
state: 0,
population: 10000,
populationMax: 10000,
agriculture: 1000,
agricultureMax: 1000,
commerce: 500,
commerceMax: 1000,
security: 500,
securityMax: 1000,
defence: 500,
defenceMax: 1000,
wall: 500,
wallMax: 1000,
supplyState: 1,
frontState: 0,
meta: {},
};
const mockGeneral: General = {
id: 1, name: 'Domestic Officer', nationId: 1, cityId: 1, troopId: 0, npcState: 0,
experience: 100, dedication: 100, officerLevel: 5, gold: 1000, rice: 1000, crew: 0, crewTypeId: 0,
train: 100, atmos: 100, injury: 0, age: 30,
id: 1,
name: 'Domestic Officer',
nationId: 1,
cityId: 1,
troopId: 0,
npcState: 0,
experience: 100,
dedication: 100,
officerLevel: 5,
gold: 1000,
rice: 1000,
crew: 0,
crewTypeId: 0,
train: 100,
atmos: 100,
injury: 0,
age: 30,
stats: { leadership: 50, strength: 50, intelligence: 100 },
role: { personality: null, specialDomestic: null, specialWar: null, items: { horse: null, weapon: null, book: null, item: null } },
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} }, meta: {}
role: {
personality: null,
specialDomestic: null,
specialWar: null,
items: { horse: null, weapon: null, book: null, item: null },
},
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {},
};
const snapshot: WorldSnapshot = {
@@ -124,7 +220,7 @@ describe('Domestic Affairs Scenario', () => {
troops: [],
diplomacy: [],
events: [],
initialEvents: []
initialEvents: [],
};
const world = new InMemoryWorld(snapshot);
const runner = new TestGameRunner(world, 200, 1);
@@ -132,12 +228,14 @@ describe('Domestic Affairs Scenario', () => {
const systemEnv: TurnCommandEnv = { develCost: 50 } as any;
const farmingDef = developAgricultureSpec.createDefinition(systemEnv);
await runner.runTurn([{
generalId: 1,
commandKey: 'che_농지개간',
resolver: farmingDef,
args: {}
}]);
await runner.runTurn([
{
generalId: 1,
commandKey: 'che_농지개간',
resolver: farmingDef,
args: {},
},
]);
const updatedCity = world.getCity(1)!;
expect(updatedCity.agriculture).toBe(1000);