Fantasy-Map-Generator/modules/trade-generator.js
2021-08-08 14:39:43 +03:00

28 lines
725 B
JavaScript

'use strict';
window.Trade = (function () {
const defineCenters = () => {
const {cells} = pack;
};
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};
})();