mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
goods export system
This commit is contained in:
parent
0c0944863c
commit
838ef27359
3 changed files with 23 additions and 9 deletions
|
|
@ -528,8 +528,8 @@ window.FMG.data.resourceModels = {
|
|||
Any_forest: 'biome(5, 6, 7, 8, 9)',
|
||||
Temperate_and_boreal_forests: 'biome(6, 8, 9)',
|
||||
Hills: 'minHeight(40) || (minHeight(30) && nth(10))',
|
||||
Mountains: 'minHeight(60) || (minHeight(40) && nth(10))',
|
||||
Mountains_and_wetlands: 'minHeight(60) || (biome(12) && nth(8))',
|
||||
Mountains: 'minHeight(60) || (minHeight(20) && nth(10))',
|
||||
Mountains_and_wetlands: 'minHeight(60) || (biome(12) && nth(7)) || (minHeight(20) && nth(10))',
|
||||
Headwaters: 'river() && minHeight(40)',
|
||||
More_habitable: 'minHabitability(20) && habitability()',
|
||||
Marine_and_rivers: 'shore(-1) && (type("ocean", "freshwater", "salt") || (river() && shore(1, 2)))',
|
||||
|
|
|
|||
4
main.js
4
main.js
|
|
@ -1566,7 +1566,6 @@ function rankCells() {
|
|||
flMax = d3.max(cells.fl) + d3.max(cells.conf); // to normalize flux
|
||||
const areaMean = d3.mean(cells.area); // to adjust population by cell area
|
||||
const getResValue = (i) => (cells.resource[i] ? Resources.get(cells.resource[i])?.value : 0); // get bonus resource scope
|
||||
const resBonuses = [];
|
||||
const POP_BALANCER = 1.5; // to ballance population to desired number
|
||||
|
||||
for (const i of cells.i) {
|
||||
|
|
@ -1598,13 +1597,10 @@ function rankCells() {
|
|||
const cellRes = getResValue(i);
|
||||
const neibRes = d3.mean(cells.c[i].map((c) => getResValue(c)));
|
||||
const resBonus = (cellRes ? cellRes + 10 : 0) + neibRes;
|
||||
resBonuses.push(resBonus);
|
||||
|
||||
// cell rural population is suitability adjusted by cell area
|
||||
cells.pop[i] = s > 0 ? (s * POP_BALANCER * cells.area[i]) / areaMean : 0;
|
||||
cells.s[i] = s + resBonus;
|
||||
|
||||
// debug.append('text').attr('x', cells.p[i][0]).attr('y', cells.p[i][1]).text(cells.s[i]);
|
||||
}
|
||||
|
||||
TIME && console.timeEnd("rankCells");
|
||||
|
|
|
|||
|
|
@ -163,12 +163,12 @@ function editBurg(id) {
|
|||
return `${totalIncome}: ${exported.join('')}`;
|
||||
}
|
||||
|
||||
function getProduction(resources) {
|
||||
function getProduction(pool) {
|
||||
let html = '';
|
||||
|
||||
for (const resourceId in resources) {
|
||||
for (const resourceId in pool) {
|
||||
const {name, unit, icon} = Resources.get(+resourceId);
|
||||
const production = resources[resourceId];
|
||||
const production = pool[resourceId];
|
||||
const unitName = production > 1 ? unit + 's' : unit;
|
||||
|
||||
html += `<span data-tip="${name}: ${production} ${unitName}">
|
||||
|
|
@ -180,6 +180,24 @@ function editBurg(id) {
|
|||
return html;
|
||||
}
|
||||
|
||||
function getExport(dealsArray) {
|
||||
if (!dealsArray.length) return 'no';
|
||||
|
||||
const totalIncome = d3.sum(dealsArray.map((deal) => deal.burgIncome));
|
||||
const exported = dealsArray.map((deal) => {
|
||||
const {resourceId, quantity, burgIncome} = deal;
|
||||
const {name, unit, icon} = Resources.get(resourceId);
|
||||
const unitName = quantity > 1 ? unit + 's' : unit;
|
||||
|
||||
return `<span data-tip="${name}: ${quantity} ${unitName}. Income: ${burgIncome}">
|
||||
<svg class="resIcon"><use href="#${icon}"></svg>
|
||||
<span style="margin: 0 0.2em 0 -0.2em">${quantity}</span>
|
||||
</span>`;
|
||||
});
|
||||
|
||||
return `${totalIncome}: ${exported.join('')}`;
|
||||
}
|
||||
|
||||
// [-1; 31] °C, source: https://en.wikipedia.org/wiki/List_of_cities_by_average_temperature
|
||||
function getTemperatureLikeness(temperature) {
|
||||
if (temperature < -15) return 'nowhere in the real-world';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue