show production in burgs editor

This commit is contained in:
Azgaar 2021-08-07 16:01:40 +03:00
parent 5d5d5d225b
commit 5b8c5a7a78
4 changed files with 89 additions and 37 deletions

View file

@ -1,42 +1,42 @@
'use strict';
window.Production = (function () {
const BONUS_PRODUCTION = 5;
const BONUS_PRODUCTION = 4;
const BIOME_PRODUCTION = [
[{resource: 11, production: 1}], // marine: fish 1
[{resource: 2, production: 0.5}], // hot desert: stone 0.5
[{resource: 2, production: 0.5}], // cold desert: stone 0.5
[{resource: 11, production: 0.75}], // marine: fish
[{resource: 2, production: 0.5}], // hot desert: stone
[{resource: 2, production: 0.5}], // cold desert: stone
[
{resource: 12, production: 0.75},
{resource: 10, production: 0.75}
{resource: 12, production: 0.4},
{resource: 10, production: 0.4}
], // savanna: game 0.75, cattle 0.75
[{resource: 10, production: 1}], // grassland: cattle 1
[{resource: 9, production: 1}], // tropical seasonal forest: grain 1
[{resource: 10, production: 0.5}], // grassland: cattle
[{resource: 9, production: 0.5}], // tropical seasonal forest: grain
[
{resource: 9, production: 1},
{resource: 1, production: 1}
], // temperate deciduous forest: grain 1, wood 1
{resource: 9, production: 0.5},
{resource: 1, production: 0.5}
], // temperate deciduous forest: grain, wood
[
{resource: 9, production: 1},
{resource: 1, production: 1}
], // tropical rainforest: grain 1, wood 1
{resource: 9, production: 0.5},
{resource: 1, production: 0.5}
], // tropical rainforest: grain, wood
[
{resource: 9, production: 1},
{resource: 1, production: 1}
], // temperate rainforest: grain 1, wood 1
{resource: 9, production: 0.5},
{resource: 1, production: 0.5}
], // temperate rainforest: grain, wood
[
{resource: 1, production: 1},
{resource: 12, production: 0.75}
], // taiga: wood 1, game 0.75
[{resource: 29, production: 0.5}], // tundra: furs 0.5
{resource: 1, production: 0.5},
{resource: 12, production: 0.4}
], // taiga: wood, game
[{resource: 29, production: 0.5}], // tundra: furs
[], // glacier: nothing
[
{resource: 4, production: 0.5},
{resource: 12, production: 0.75}
] // wetland: iron .5, game .75
{resource: 4, production: 0.4},
{resource: 12, production: 0.4}
] // wetland: iron, game
];
const RIVER_PRODUCTION = [{resource: 11, production: 1.5}]; // fish 1.5
const HILLS_PRODUCTION = [{resource: 34, production: 1}]; // coal 1
const RIVER_PRODUCTION = [{resource: 11, production: 0.5}]; // fish
const HILLS_PRODUCTION = [{resource: 34, production: 0.5}]; // coal
const FOOD_MULTIPLIER = 3;
const collectResources = () => {

View file

@ -10,7 +10,7 @@ function editBurg(id) {
burgLabels.selectAll('text').call(d3.drag().on('start', dragBurgLabel)).classed('draggable', true);
updateBurgValues();
const my = id || d3.event.target.tagName === 'text' ? 'center bottom-20' : 'center top+20';
const my = id || d3.event.target.tagName === 'text' ? 'center bottom-40' : 'center top+40';
const at = id ? 'center' : d3.event.target.tagName === 'text' ? 'top' : 'bottom';
const of = id ? 'svg' : d3.event.target;
@ -57,14 +57,17 @@ function editBurg(id) {
function updateBurgValues() {
const id = +elSelected.attr('data-id');
const b = pack.burgs[id];
const province = pack.cells.province[b.cell];
const provinceName = province ? pack.provinces[province].fullName + ', ' : '';
const stateName = pack.states[b.state].fullName || pack.states[b.state].name;
document.getElementById('burgProvinceAndState').innerHTML = provinceName + stateName;
document.getElementById('burgName').value = b.name;
document.getElementById('burgType').value = b.type || 'Generic';
document.getElementById('burgPopulation').value = rn(b.population * populationRate * urbanization);
const stateName = pack.states[b.state].fullName || pack.states[b.state].name;
const province = pack.cells.province[b.cell];
const provinceName = province ? pack.provinces[province].fullName : '';
document.getElementById('burgState').innerHTML = stateName;
document.getElementById('burgProvince').innerHTML = provinceName;
document.getElementById('burgEditAnchorStyle').style.display = +b.port ? 'inline-block' : 'none';
// update list and select culture
@ -94,6 +97,18 @@ function editBurg(id) {
if (b.shanty) document.getElementById('burgShanty').classList.remove('inactive');
else document.getElementById('burgShanty').classList.add('inactive');
// economics block
let productionHTML = '';
for (const resourceId in b.production) {
const {name, icon} = Resources.get(+resourceId);
const production = b.production[resourceId];
productionHTML += `<span data-tip="${name}: ${production}">
<svg class="resIcon"><use href="#${icon}"></svg>
<span style="margin: 0 0.2em 0 -0.2em">${production}</span>
</span>`;
}
document.getElementById('burgProduction').innerHTML = productionHTML;
//toggle lock
updateBurgLockIcon();