fix: match scenario 2601 monthly seed progression

This commit is contained in:
2026-08-03 18:56:23 +00:00
parent 2f17584075
commit 58b9a230a7
92 changed files with 3696 additions and 587 deletions
+94 -1
View File
@@ -181,8 +181,12 @@ describe('che_출병', () => {
const defenderNation = buildNation(2);
const attackerCity = buildCity(1, attackerNation.id);
const defenderCity = buildCity(2, defenderNation.id);
const neutralCity = buildCity(3, 0);
const attacker = buildGeneral(1, attackerNation.id, attackerCity.id);
const defender = buildGeneral(2, defenderNation.id, defenderCity.id);
defender.crew = 0;
defenderCity.defence = 0;
defenderCity.wall = 0;
const definition = new ActionDefinition();
const context: Omit<DispatchResolveContext, 'addLog'> = {
@@ -192,10 +196,23 @@ describe('che_출병', () => {
rng,
destCity: defenderCity,
destNation: defenderNation,
cities: [attackerCity, defenderCity],
cities: [attackerCity, defenderCity, neutralCity],
nations: [attackerNation, defenderNation],
generals: [attacker, defender],
unitSet,
map: {
id: 'test-map',
name: 'test-map',
cities: [
{ id: 1, name: 'City1', level: 2, region: 1, position: { x: 0, y: 0 }, connections: [2, 3], max: { population: 1, agriculture: 1, commerce: 1, security: 1, defence: 1, wall: 1 }, initial: { population: 1, agriculture: 1, commerce: 1, security: 1, defence: 1, wall: 1 } },
{ id: 2, name: 'City2', level: 2, region: 1, position: { x: 1, y: 0 }, connections: [1], max: { population: 1, agriculture: 1, commerce: 1, security: 1, defence: 1, wall: 1 }, initial: { population: 1, agriculture: 1, commerce: 1, security: 1, defence: 1, wall: 1 } },
{ id: 3, name: 'City3', level: 2, region: 1, position: { x: 0, y: 1 }, connections: [1], max: { population: 1, agriculture: 1, commerce: 1, security: 1, defence: 1, wall: 1 }, initial: { population: 1, agriculture: 1, commerce: 1, security: 1, defence: 1, wall: 1 } },
],
},
diplomacy: [
{ fromNationId: attackerNation.id, toNationId: defenderNation.id, state: 0, term: 0 },
{ fromNationId: defenderNation.id, toNationId: attackerNation.id, state: 0, term: 0 },
],
time: {
year: 200,
month: 1,
@@ -220,6 +237,9 @@ describe('che_출병', () => {
expect(resolution.logs.length).toBeGreaterThan(0);
expect(resolution.patches?.generals.some((patch) => patch.id === defender.id)).toBe(true);
expect(resolution.patches?.cities.some((patch) => patch.id === defenderCity.id)).toBe(true);
expect({ city: resolution.city, patches: resolution.patches?.cities }).toMatchObject({
city: { frontState: 2 },
});
expect(
resolution.effects.some(
(effect) =>
@@ -229,4 +249,77 @@ describe('che_출병', () => {
)
).toBe(true);
});
it('prefers an enemy on the shortest route layer before considering the next layer', () => {
const attackerNation = buildNation(1);
const attackerCity = buildCity(1, attackerNation.id);
const targetCity = buildCity(2, 0);
const alternateCity = buildCity(3, 0);
targetCity.defence = 0;
targetCity.wall = 0;
alternateCity.defence = 0;
alternateCity.wall = 0;
const attacker = buildGeneral(1, attackerNation.id, attackerCity.id);
const pickLastRng = {
...rng,
nextInt: (_minInclusive: number, maxExclusive: number) => maxExclusive - 1,
};
const definition = new ActionDefinition();
const mapCity = (id: number, connections: number[]) => ({
id,
name: `City${id}`,
level: 2,
region: 1,
position: { x: id, y: 0 },
connections,
max: {
population: 1,
agriculture: 1,
commerce: 1,
security: 1,
defence: 1,
wall: 1,
},
initial: {
population: 1,
agriculture: 1,
commerce: 1,
security: 1,
defence: 1,
wall: 1,
},
});
const context: Omit<DispatchResolveContext, 'addLog'> = {
general: attacker,
city: attackerCity,
nation: attackerNation,
rng: pickLastRng,
destCity: targetCity,
destNation: null,
cities: [attackerCity, targetCity, alternateCity],
nations: [attackerNation],
generals: [attacker],
unitSet,
map: {
id: 'triangle',
name: 'triangle',
cities: [mapCity(1, [2, 3]), mapCity(2, [1, 3]), mapCity(3, [1, 2])],
},
diplomacy: [],
time: { year: 200, month: 1, startYear: 180 },
seedBase: 'route-layer-seed',
warConfig,
aftermathConfig,
};
const resolution = resolveGeneralAction(
definition,
context,
{ now: new Date('2000-01-01T00:00:00Z'), schedule },
{ destCityId: targetCity.id }
);
expect(resolution.patches?.cities.some((patch) => patch.id === targetCity.id)).toBe(true);
expect(resolution.patches?.cities.some((patch) => patch.id === alternateCity.id)).toBe(false);
});
});