refactor: Update test object modifications to use immutable patterns and extend command context with map, unitSet, and cities.
This commit is contained in:
@@ -162,16 +162,15 @@ describe('Blank Start Scenario', () => {
|
|||||||
if (city) {
|
if (city) {
|
||||||
// Manually update nationId in city
|
// Manually update nationId in city
|
||||||
const cityIdx = world.snapshot.cities.findIndex(c => c.id === city.id);
|
const cityIdx = world.snapshot.cities.findIndex(c => c.id === city.id);
|
||||||
const cityToUpdate = world.snapshot.cities[cityIdx];
|
world.snapshot.cities[cityIdx] = { ...world.snapshot.cities[cityIdx], nationId: newNationId };
|
||||||
if (cityToUpdate) cityToUpdate.nationId = newNationId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const genIdx = world.snapshot.generals.findIndex(g => g.id === generalAfter.id);
|
const genIdx = world.snapshot.generals.findIndex(g => g.id === generalAfter.id);
|
||||||
const genToUpdate = world.snapshot.generals[genIdx];
|
world.snapshot.generals[genIdx] = {
|
||||||
if (genToUpdate) {
|
...world.snapshot.generals[genIdx],
|
||||||
genToUpdate.nationId = newNationId;
|
nationId: newNationId,
|
||||||
genToUpdate.meta = { ...generalAfter.meta, founding: false };
|
meta: { ...generalAfter.meta, founding: false }
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Verify
|
// 5. Verify
|
||||||
|
|||||||
@@ -200,6 +200,9 @@ export class TestGameRunner {
|
|||||||
year: this.currentDate.getFullYear(),
|
year: this.currentDate.getFullYear(),
|
||||||
month: this.currentDate.getMonth() + 1,
|
month: this.currentDate.getMonth() + 1,
|
||||||
season: Math.floor(this.currentDate.getMonth() / 3),
|
season: Math.floor(this.currentDate.getMonth() / 3),
|
||||||
|
map: this.world.snapshot.map,
|
||||||
|
unitSet: this.world.snapshot.unitSet,
|
||||||
|
cities: this.world.snapshot.cities,
|
||||||
...cmd.context
|
...cmd.context
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user