mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
refactor: routes continue
This commit is contained in:
parent
910e782f1f
commit
aff29d9d71
3 changed files with 15 additions and 11 deletions
|
|
@ -29,7 +29,7 @@ export function specifyBurgs(
|
|||
): TBurgs {
|
||||
TIME && console.time("specifyBurgs");
|
||||
|
||||
const burgs: IBurg[] = [...capitals, ...towns].map(burgData => {
|
||||
const burgs = [...capitals, ...towns].map(burgData => {
|
||||
const {cell, culture, capital} = burgData;
|
||||
const state = stateIds[cell];
|
||||
|
||||
|
|
@ -38,9 +38,10 @@ export function specifyBurgs(
|
|||
const [x, y] = defineLocation(cell, port);
|
||||
|
||||
const type = defineType(cell, port, population);
|
||||
const coa = defineEmblem(state, culture, port, capital, type, cultures, states);
|
||||
const coa: ICoa = defineEmblem(state, culture, port, capital, type, cultures, states);
|
||||
|
||||
return {...burgData, state, port, population, x, y, type, coa};
|
||||
const burg: IBurg = {...burgData, state, port, population, x, y, type, coa};
|
||||
return burg;
|
||||
});
|
||||
|
||||
TIME && console.timeEnd("specifyBurgs");
|
||||
|
|
|
|||
|
|
@ -19,18 +19,18 @@ const getRoads = function (burgs: TBurgs) {
|
|||
|
||||
if (capitals.length < 2) return []; // not enough capitals to build main roads
|
||||
|
||||
const paths = []; // array to store path segments
|
||||
const routes = []; // array to store path segments
|
||||
|
||||
for (const b of capitals) {
|
||||
const connect = capitals.filter(c => c.feature === b.feature && c !== b);
|
||||
for (const t of connect) {
|
||||
const [from, exit] = findLandPath(b.cell, t.cell, true);
|
||||
const segments = restorePath(b.cell, exit, "main", from);
|
||||
segments.forEach(s => paths.push(s));
|
||||
for (const {i, feature, cell: fromCell} of capitals) {
|
||||
const sameFeatureCapitals = capitals.filter(capital => i !== capital.i && feature === capital.feature);
|
||||
for (const {cell: toCell} of sameFeatureCapitals) {
|
||||
const [from, exit] = findLandPath(fromCell, toCell, true);
|
||||
const segments = restorePath(fromCell, exit, "main", from);
|
||||
segments.forEach(s => routes.push(s));
|
||||
}
|
||||
}
|
||||
|
||||
cells.i.forEach(i => (cells.s[i] += cells.road[i] / 2)); // add roads to suitability score
|
||||
TIME && console.timeEnd("generateMainRoads");
|
||||
return paths;
|
||||
return routes;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue