goods export system

This commit is contained in:
Azgaar 2021-08-08 20:47:00 +03:00 committed by Peter
parent 0c0944863c
commit 838ef27359
3 changed files with 23 additions and 9 deletions

View file

@ -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)))',

View file

@ -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");

View file

@ -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';