fix: clean up neighbors references on state removal

This commit is contained in:
Marc Emmanuel 2026-02-03 16:42:15 +01:00
parent 844fc15891
commit ed3cc83fed
3 changed files with 8 additions and 2 deletions

View file

@ -640,6 +640,12 @@ function stateRemove(stateId) {
});
armies.select("g#army" + stateId).remove();
// clean up neighbors references from other states
pack.states.forEach(state => {
if (!state.i || state.removed || !state.neighbors) return;
state.neighbors = state.neighbors.filter(n => n !== stateId);
});
pack.states[stateId] = {i: stateId, removed: true};
debug.selectAll(".highlight").remove();