mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
resource units
This commit is contained in:
parent
a09a266d30
commit
34bf6ffd1e
4 changed files with 39 additions and 2 deletions
|
|
@ -535,7 +535,7 @@ window.FMG.data.resourceModels = {
|
||||||
Marine_and_rivers: 'shore(-1) && (type("ocean", "freshwater", "salt") || (river() && shore(1, 2)))',
|
Marine_and_rivers: 'shore(-1) && (type("ocean", "freshwater", "salt") || (river() && shore(1, 2)))',
|
||||||
Pastures_and_temperate_forest: '(biome(3, 4) && !elevation()) || (biome(6) && random(70)) || (biome(5) && nth(5))',
|
Pastures_and_temperate_forest: '(biome(3, 4) && !elevation()) || (biome(6) && random(70)) || (biome(5) && nth(5))',
|
||||||
Tropical_forests: 'biome(5, 7)',
|
Tropical_forests: 'biome(5, 7)',
|
||||||
Arid_land_and_salt_lakes: 'type("salt", "dry") || (biome(1, 2) && random(70)) || (biome(12) && nth(10))',
|
Arid_land_and_salt_lakes: 'shore(1) && type("salt", "dry") || (biome(1, 2) && random(70)) || (biome(12) && nth(10))',
|
||||||
Hot_desert: 'biome(1)',
|
Hot_desert: 'biome(1)',
|
||||||
Deserts: 'biome(1, 2)',
|
Deserts: 'biome(1, 2)',
|
||||||
Grassland_and_cold_desert: 'biome(3) || (biome(2) && nth(4))',
|
Grassland_and_cold_desert: 'biome(3) || (biome(2) && nth(4))',
|
||||||
|
|
|
||||||
1
main.js
1
main.js
|
|
@ -727,6 +727,7 @@ async function generate(options) {
|
||||||
BurgsAndStates.defineTaxes();
|
BurgsAndStates.defineTaxes();
|
||||||
|
|
||||||
Production.collectResources();
|
Production.collectResources();
|
||||||
|
Production.defineExport();
|
||||||
|
|
||||||
Trade.defineCenters();
|
Trade.defineCenters();
|
||||||
Trade.calculateDistances();
|
Trade.calculateDistances();
|
||||||
|
|
|
||||||
|
|
@ -110,5 +110,24 @@ window.Production = (function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {collectResources};
|
const defineExport = () => {
|
||||||
|
const {cells, burgs} = pack;
|
||||||
|
|
||||||
|
for (const burg of burgs) {
|
||||||
|
if (!burg.i || burg.removed) continue;
|
||||||
|
const {population, production: resourcePool} = burg;
|
||||||
|
const localUsage = Math.ceil(population);
|
||||||
|
|
||||||
|
const surplus = {};
|
||||||
|
for (const resourceId in resourcePool) {
|
||||||
|
const production = resourcePool[resourceId];
|
||||||
|
const extraProduction = production - localUsage;
|
||||||
|
if (extraProduction > 0) surplus[resourceId] = extraProduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
burg.export = surplus;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {collectResources, defineExport};
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,23 @@ function editBurg(id) {
|
||||||
return `${totalIncome}: ${exported.join('')}`;
|
return `${totalIncome}: ${exported.join('')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getProduction(resources) {
|
||||||
|
let html = '';
|
||||||
|
|
||||||
|
for (const resourceId in resources) {
|
||||||
|
const {name, unit, icon} = Resources.get(+resourceId);
|
||||||
|
const production = resources[resourceId];
|
||||||
|
const unitName = production > 1 ? unit + 's' : unit;
|
||||||
|
|
||||||
|
html += `<span data-tip="${name}: ${production} ${unitName}">
|
||||||
|
<svg class="resIcon"><use href="#${icon}"></svg>
|
||||||
|
<span style="margin: 0 0.2em 0 -0.2em">${production}</span>
|
||||||
|
</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
// [-1; 31] °C, source: https://en.wikipedia.org/wiki/List_of_cities_by_average_temperature
|
// [-1; 31] °C, source: https://en.wikipedia.org/wiki/List_of_cities_by_average_temperature
|
||||||
function getTemperatureLikeness(temperature) {
|
function getTemperatureLikeness(temperature) {
|
||||||
if (temperature < -15) return 'nowhere in the real-world';
|
if (temperature < -15) return 'nowhere in the real-world';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue