This commit is contained in:
Azgaar 2020-04-08 23:35:32 +03:00
parent 6d0e106f1f
commit 5e9bd86069
2 changed files with 6 additions and 2 deletions

View file

@ -916,7 +916,9 @@
states.forEach(s => {
s.provinces = [];
if (!s.i || s.removed) return;
const stateBurgs = burgs.filter(b => b.state === s.i && !b.removed).sort((a, b) => b.population * gauss(1, .2, .5, 1.5, 3) - a.population);
const stateBurgs = burgs.filter(b => b.state === s.i && !b.removed)
.sort((a, b) => b.population * gauss(1, .2, .5, 1.5, 3) - a.population)
.sort((a, b) => b.capital - a.capital);
if (stateBurgs.length < 2) return; // at least 2 provinces are required
const provincesNumber = Math.max(Math.ceil(stateBurgs.length * percentage / 100), 2);
const form = Object.assign({}, forms[s.form]);

View file

@ -125,7 +125,7 @@ function editProvinces() {
<div data-tip="Province area" class="biomeArea hide">${si(area) + unit}</div>
<span data-tip="${populationTip}" class="icon-male hide"></span>
<div data-tip="${populationTip}" class="culturePopulation hide">${si(population)}</div>
<span data-tip="Declare province independence (turn province into a new state)" class="icon-flag-empty ${separable ? '' : 'placeholder'} hide"></span>
<span data-tip="Declare province independence (turn non-capital province with burgs into a new state)" class="icon-flag-empty ${separable ? '' : 'placeholder'} hide"></span>
<span data-tip="Toggle province focus" class="icon-pin ${focused?'':' inactive'} hide"></span>
<span data-tip="Remove the province" class="icon-trash-empty hide"></span>
</div>`;
@ -226,6 +226,8 @@ function editProvinces() {
function declareProvinceIndependence(p) {
const states = pack.states, provinces = pack.provinces, cells = pack.cells;
if (provinces[p].burgs.some(b => pack.burgs[b].capital)) {tip("Cannot declare independence of a province having capital burg. Please change capital first", false, "error"); return;}
const oldState = pack.provinces[p].state;
const newState = pack.states.length;