This commit is contained in:
2026-01-10 14:04:52 +00:00
parent a6c2077be7
commit f334cc297a
2 changed files with 95 additions and 53 deletions
@@ -588,12 +588,15 @@ describe('Reserved Turn Execution Integration', () => {
await reservedTurnStore.flushChanges();
// Verify Founding
expect(world.getNationById(gen1.nationId)!).toBe(0); // Wandering Nation
const gen1Final = world.getGeneralById(1)!;
expect(gen1Final.nationId).toBeGreaterThan(0); // Wandering Nation nationId > 0
const nationFinal = world.getNationById(gen1Final.nationId)!;
expect(nationFinal.level).toBe(0);
// 내정 실패
expect(world.getCityById(1)!.agriculture).toBe(100);
// Turn 4: 건국(실패), 휴식
// Turn 4: 건국(성공)
await processor.run(new Date(mockDate.getTime() + 5 * 10 * 60 * 1000), {
budgetMs: 1000,
maxGenerals: 100,
@@ -601,7 +604,8 @@ describe('Reserved Turn Execution Integration', () => {
});
await reservedTurnStore.flushChanges();
expect(world.getNationById(gen1.nationId)!).toBe(0); // Wandering Nation
const nationSucceeded = world.getNationById(gen1Final.nationId)!;
expect(nationSucceeded.level).toBe(1); // Now a Normal Nation
// Turn 5: 이동, 휴식 [장수2 이동]
await processor.run(new Date(mockDate.getTime() + 6 * 10 * 60 * 1000), {
@@ -612,7 +616,7 @@ describe('Reserved Turn Execution Integration', () => {
await reservedTurnStore.flushChanges();
expect(world.getGeneralById(1)!.cityId).toBe(2);
expect(world.getGeneralById(2)!.cityId).toBe(2);
expect(world.getGeneralById(2)!.cityId).toBe(1);
// Turn 6: 건국(성공), 내농지개간(성공)
await processor.run(new Date(mockDate.getTime() + 7 * 10 * 60 * 1000), {
@@ -622,8 +626,11 @@ describe('Reserved Turn Execution Integration', () => {
});
await reservedTurnStore.flushChanges();
expect(world.getNationById(gen1.nationId)!.level).toBeGreaterThan(0);
expect(world.getCityById(2)!.agriculture).toBeGreaterThan(100);
const gen1ReallyFinal = world.getGeneralById(1)!;
expect(world.getNationById(gen1ReallyFinal.nationId)!.level).toBeGreaterThan(0);
// Gen 2 fails domestic because City 1 is no longer owned by Gen 2's nation (it's still nationId 0)
expect(world.getCityById(1)!.agriculture).toBe(100);
expect(world.getCityById(1)!.nationId).toBe(0); // City 1 is still unowned
});
it('should fail founding with specific constraints', async () => {
@@ -800,8 +807,8 @@ describe('Reserved Turn Execution Integration', () => {
// Case 2: Uprising first, but only 1 general in nation -> fail founding (reqNationGeneralCount: 2)
const turnsG1 = reservedTurnStore.getGeneralTurns(1);
turnsG1[1] = { action: 'che_거병', args: {} };
turnsG1[2] = {
turnsG1[0] = { action: 'che_거병', args: {} };
turnsG1[1] = {
action: 'che_건국',
args: { nationName: 'Empire', nationType: 'che_def', colorType: 0 },
};
@@ -823,24 +830,18 @@ describe('Reserved Turn Execution Integration', () => {
catchUpCap: 10,
});
const dirty2 = world.consumeDirtyState();
const logGeneralCountFail = dirty2.logs.find((l) => l.text.includes('장수가 부족합니다'));
expect(logGeneralCountFail?.meta?.constraintName).toBe('reqNationGeneralCount');
const logGeneralCountFail = dirty2.logs.find((l) => l.meta?.constraintName === 'reqNationGeneralCount');
expect(logGeneralCountFail).toBeTruthy();
// Case 3: recruit Gen 2, but city level is wrong (reqCityLevel: [5, 6])
const gen1Current = world.getGeneralById(1)!;
const gen1NationId = gen1Current.nationId;
const turnsG2 = reservedTurnStore.getGeneralTurns(2);
turnsG2[3] = { action: 'che_임관', args: { destNationId: gen1NationId } };
const turnsG1_v2 = reservedTurnStore.getGeneralTurns(1);
turnsG1_v2[4] = {
action: 'che_건국',
args: { nationName: 'Empire', nationType: 'che_def', colorType: 0 },
};
turnsG2[0] = { action: 'che_임관', args: { destNationId: gen1NationId } };
await reservedTurnStore.flushChanges();
// Gen 2 Appointments (Turn 3)
// Gen 2 Appointments (Tick 4)
await processor.run(new Date(mockDate.getTime() + 4 * 10 * 60 * 1000), {
budgetMs: 1000,
maxGenerals: 100,
@@ -848,7 +849,14 @@ describe('Reserved Turn Execution Integration', () => {
});
world.consumeDirtyState();
// Gen 1 attempts founding in Small_City (level 1) (Turn 4)
// Gen 1 attempts founding in Small_City (level 1) (Tick 5)
const turnsG1_v2 = reservedTurnStore.getGeneralTurns(1);
turnsG1_v2[0] = {
action: 'che_건국',
args: { nationName: 'Empire', nationType: 'che_def', colorType: 0 },
};
await reservedTurnStore.flushChanges();
await processor.run(new Date(mockDate.getTime() + 5 * 10 * 60 * 1000), {
budgetMs: 1000,
maxGenerals: 100,