mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
burgAssign code by deuzeksmckinna
Starting point for moving burgs to a 'burg group' in bulk when burgs meet certain specific criteria. Ideal version will have several filters as written on: Discord/fmg-suggestions/Mass Burg assignation/
This commit is contained in:
parent
845dc893d2
commit
4e729c123b
2 changed files with 28 additions and 0 deletions
|
|
@ -5337,6 +5337,7 @@
|
||||||
class="icon-download"
|
class="icon-download"
|
||||||
></button>
|
></button>
|
||||||
<button id="burgNamesImport" data-tip="Rename burgs in bulk" class="icon-upload"></button>
|
<button id="burgNamesImport" data-tip="Rename burgs in bulk" class="icon-upload"></button>
|
||||||
|
<button id="burgGroupAssign" data-tip="Reassign burgs to a group in bulk" class=" icon-layer-group"></button>
|
||||||
<button id="burgsLockAll" data-tip="Lock or unlock all burgs" class="icon-lock"></button>
|
<button id="burgsLockAll" data-tip="Lock or unlock all burgs" class="icon-lock"></button>
|
||||||
<button
|
<button
|
||||||
id="burgsRemoveAll"
|
id="burgsRemoveAll"
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ function overviewBurgs(options = {stateId: null, cultureId: null}) {
|
||||||
byId("burgsListToLoad").addEventListener("change", function () {
|
byId("burgsListToLoad").addEventListener("change", function () {
|
||||||
uploadFile(this, importBurgNames);
|
uploadFile(this, importBurgNames);
|
||||||
});
|
});
|
||||||
|
byId("burgGroupAssign").addEventListener("click", burgGroupAssignInBulk);
|
||||||
byId("burgsLockAll").addEventListener("click", toggleLockAll);
|
byId("burgsLockAll").addEventListener("click", toggleLockAll);
|
||||||
byId("burgsRemoveAll").addEventListener("click", triggerAllBurgsRemove);
|
byId("burgsRemoveAll").addEventListener("click", triggerAllBurgsRemove);
|
||||||
byId("burgsInvertLock").addEventListener("click", invertLock);
|
byId("burgsInvertLock").addEventListener("click", invertLock);
|
||||||
|
|
@ -584,6 +585,32 @@ function overviewBurgs(options = {stateId: null, cultureId: null}) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function burgGroupAssignInBulk() {
|
||||||
|
// Define the constants separately
|
||||||
|
let minpop = 1000 / populationRate;
|
||||||
|
let maxpop = null / populationRate;
|
||||||
|
|
||||||
|
// Define the function to filter and move burgs
|
||||||
|
const filterAndMoveBurgs = (burgs) => {
|
||||||
|
// Filter the burgs based on certain conditions using the previously defined constants
|
||||||
|
const filteredBurgs = burgs.filter(b =>
|
||||||
|
b.cell &&
|
||||||
|
b.port &&
|
||||||
|
!b.citadel &&
|
||||||
|
b.walls &&
|
||||||
|
b.plaza &&
|
||||||
|
b.temple &&
|
||||||
|
b.shanty &&
|
||||||
|
b.population >= minpop &&
|
||||||
|
b.population <= maxpop &&
|
||||||
|
!b.capital
|
||||||
|
);
|
||||||
|
|
||||||
|
// Move the filtered burgs to the 'towns' group
|
||||||
|
filteredBurgs.forEach(b => moveBurgToGroup(b.i, 'towns'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function triggerAllBurgsRemove() {
|
function triggerAllBurgsRemove() {
|
||||||
const number = pack.burgs.filter(b => b.i && !b.removed && !b.capital && !b.lock).length;
|
const number = pack.burgs.filter(b => b.i && !b.removed && !b.capital && !b.lock).length;
|
||||||
confirmationDialog({
|
confirmationDialog({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue