mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix: #1048
This commit is contained in:
parent
721cec4e58
commit
73b39d217d
5 changed files with 114 additions and 64 deletions
|
|
@ -624,28 +624,36 @@ function stateRemovePrompt(state) {
|
|||
});
|
||||
}
|
||||
|
||||
function stateRemove(state) {
|
||||
statesBody.select("#state" + state).remove();
|
||||
statesBody.select("#state-gap" + state).remove();
|
||||
statesHalo.select("#state-border" + state).remove();
|
||||
labels.select("#stateLabel" + state).remove();
|
||||
defs.select("#textPath_stateLabel" + state).remove();
|
||||
function stateRemove(stateId) {
|
||||
statesBody.select("#state" + stateId).remove();
|
||||
statesBody.select("#state-gap" + stateId).remove();
|
||||
statesHalo.select("#state-border" + stateId).remove();
|
||||
labels.select("#stateLabel" + stateId).remove();
|
||||
defs.select("#textPath_stateLabel" + stateId).remove();
|
||||
|
||||
unfog("focusState" + state);
|
||||
pack.burgs.forEach(b => {
|
||||
if (b.state === state) b.state = 0;
|
||||
unfog("focusState" + stateId);
|
||||
|
||||
pack.burgs.forEach(burg => {
|
||||
if (burg.state === stateId) {
|
||||
burg.state = 0;
|
||||
if (burg.capital) {
|
||||
burg.capital = 0;
|
||||
moveBurgToGroup(burg.i, "towns");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
pack.cells.state.forEach((s, i) => {
|
||||
if (s === state) pack.cells.state[i] = 0;
|
||||
if (s === stateId) pack.cells.state[i] = 0;
|
||||
});
|
||||
|
||||
// remove emblem
|
||||
const coaId = "stateCOA" + state;
|
||||
const coaId = "stateCOA" + stateId;
|
||||
byId(coaId).remove();
|
||||
emblems.select(`#stateEmblems > use[data-i='${state}']`).remove();
|
||||
emblems.select(`#stateEmblems > use[data-i='${stateId}']`).remove();
|
||||
|
||||
// remove provinces
|
||||
pack.states[state].provinces.forEach(p => {
|
||||
pack.states[stateId].provinces.forEach(p => {
|
||||
pack.provinces[p] = {i: p, removed: true};
|
||||
pack.cells.province.forEach((pr, i) => {
|
||||
if (pr === p) pack.cells.province[i] = 0;
|
||||
|
|
@ -660,19 +668,14 @@ function stateRemove(state) {
|
|||
});
|
||||
|
||||
// remove military
|
||||
pack.states[state].military.forEach(m => {
|
||||
const id = `regiment${state}-${m.i}`;
|
||||
pack.states[stateId].military.forEach(m => {
|
||||
const id = `regiment${stateId}-${m.i}`;
|
||||
const index = notes.findIndex(n => n.id === id);
|
||||
if (index != -1) notes.splice(index, 1);
|
||||
});
|
||||
armies.select("g#army" + state).remove();
|
||||
armies.select("g#army" + stateId).remove();
|
||||
|
||||
const capital = pack.states[state].capital;
|
||||
pack.burgs[capital].capital = 0;
|
||||
pack.burgs[capital].state = 0;
|
||||
moveBurgToGroup(capital, "towns");
|
||||
|
||||
pack.states[state] = {i: state, removed: true};
|
||||
pack.states[stateId] = {i: stateId, removed: true};
|
||||
|
||||
debug.selectAll(".highlight").remove();
|
||||
if (!layerIsOn("toggleStates")) toggleStates();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue