prepare from trade generation

This commit is contained in:
Azgaar 2021-08-08 14:39:43 +03:00
parent ec468914e4
commit 2312d99760
4 changed files with 385 additions and 120 deletions

View file

@ -1,8 +1,28 @@
'use strict';
window.Trade = (function () {
const defineTradeCenters = () => {
const defineCenters = () => {
const {cells} = pack;
};
return {defineTradeCenters};
const exportGoods = () => {
for (const burg of pack.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;
}
};
const importGoods = () => {};
return {defineCenters, exportGoods, importGoods};
})();