fix the issue with province that cannot be reassigned

This commit is contained in:
Azgaar 2021-07-10 22:41:50 +03:00
parent 43ce0424a5
commit 0e9732e6ce

View file

@ -827,18 +827,15 @@ function editStates() {
} }
function adjustProvinces(affectedProvinces) { function adjustProvinces(affectedProvinces) {
const cells = pack.cells, const {cells, provinces, states} = pack;
provinces = pack.provinces,
states = pack.states;
const form = {Zone: 1, Area: 1, Territory: 2, Province: 1}; const form = {Zone: 1, Area: 1, Territory: 2, Province: 1};
affectedProvinces.forEach(p => { affectedProvinces.forEach(p => {
// do nothing if neutral lands are captured if (!p) return; // do nothing if neutral lands are captured
if (!p) return; const old = provinces[p].state;
// remove province from state provinces list // remove province from state provinces list
const old = provinces[p].state; if (states[old]?.provinces?.includes(p)) states[old].provinces.splice(states[old].provinces.indexOf(p), 1);
if (states[old].provinces.includes(p)) states[old].provinces.splice(states[old].provinces.indexOf(p), 1);
// find states owning at least 1 province cell // find states owning at least 1 province cell
const provCells = cells.i.filter(i => cells.province[i] === p); const provCells = cells.i.filter(i => cells.province[i] === p);