mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
prepare from trade generation
This commit is contained in:
parent
ec468914e4
commit
2312d99760
4 changed files with 385 additions and 120 deletions
|
|
@ -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};
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue