mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
feat: routes - change data format
This commit is contained in:
parent
597f6ddd75
commit
b47fa6b92d
14 changed files with 155 additions and 139 deletions
|
|
@ -692,7 +692,7 @@ window.Religions = (function () {
|
|||
|
||||
// growth algorithm to assign cells to religions
|
||||
function expandReligions(religions) {
|
||||
const cells = pack.cells;
|
||||
const {cells, routes} = pack;
|
||||
const religionIds = spreadFolkReligions(religions);
|
||||
|
||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||
|
|
@ -700,8 +700,6 @@ window.Religions = (function () {
|
|||
|
||||
const maxExpansionCost = (cells.i.length / 20) * neutralInput.value; // limit cost for organized religions growth
|
||||
|
||||
const biomePassageCost = cellId => biomesData.cost[cells.biome[cellId]];
|
||||
|
||||
religions
|
||||
.filter(r => r.i && !r.lock && r.type !== "Folk" && !r.removed)
|
||||
.forEach(r => {
|
||||
|
|
@ -712,11 +710,6 @@ window.Religions = (function () {
|
|||
|
||||
const religionsMap = new Map(religions.map(r => [r.i, r]));
|
||||
|
||||
const isMainRoad = cellId => cells.route[cellId] === 1;
|
||||
const isTrail = cellId => cells.route[cellId] === 2;
|
||||
const isSeaRoute = cellId => cells.route[cellId] === 3;
|
||||
const isWater = cellId => cells.h[cellId] < 20;
|
||||
|
||||
while (queue.length) {
|
||||
const {e: cellId, p, r, s: state} = queue.dequeue();
|
||||
const {culture, expansion, expansionism} = religionsMap.get(r);
|
||||
|
|
@ -728,7 +721,7 @@ window.Religions = (function () {
|
|||
|
||||
const cultureCost = culture !== cells.culture[nextCell] ? 10 : 0;
|
||||
const stateCost = state !== cells.state[nextCell] ? 10 : 0;
|
||||
const passageCost = getPassageCost(nextCell);
|
||||
const passageCost = getPassageCost(cellId, nextCell);
|
||||
|
||||
const cellCost = cultureCost + stateCost + passageCost;
|
||||
const totalCost = p + 10 + cellCost / expansionism;
|
||||
|
|
@ -745,11 +738,18 @@ window.Religions = (function () {
|
|||
|
||||
return religionIds;
|
||||
|
||||
function getPassageCost(cellId) {
|
||||
if (isWater(cellId)) return isSeaRoute ? 50 : 500;
|
||||
if (isMainRoad(cellId)) return 1;
|
||||
const biomeCost = biomePassageCost(cellId);
|
||||
return isTrail(cellId) ? biomeCost / 1.5 : biomeCost;
|
||||
function getPassageCost(cellId, nextCellId) {
|
||||
const route = Routes.getRoute(cellId, nextCellId);
|
||||
if (isWater(cellId)) return route ? 50 : 500;
|
||||
|
||||
const biomePassageCost = biomesData.cost[cells.biome[nextCellId]];
|
||||
|
||||
if (route) {
|
||||
if (route.group === "roads") return 1;
|
||||
return biomePassageCost / 3; // trails and other routes
|
||||
}
|
||||
|
||||
return biomePassageCost;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue