mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
resource units
This commit is contained in:
parent
16c316a74f
commit
a3043f932f
5 changed files with 51 additions and 13 deletions
|
|
@ -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};
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue