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