mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
Merge branch 'faith-update' into new-faith+update
This commit is contained in:
commit
2c7624cdb8
8 changed files with 254 additions and 21 deletions
|
|
@ -7864,10 +7864,10 @@
|
||||||
<script src="modules/river-generator.js"></script>
|
<script src="modules/river-generator.js"></script>
|
||||||
<script src="modules/lakes.js"></script>
|
<script src="modules/lakes.js"></script>
|
||||||
<script src="modules/names-generator.js?v=1.87.14"></script>
|
<script src="modules/names-generator.js?v=1.87.14"></script>
|
||||||
<script src="modules/cultures-generator.js?v=1.89.07"></script>
|
<script src="modules/cultures-generator.js?v=1.90.00"></script>
|
||||||
<script src="modules/burgs-and-states.js?v=1.89.07"></script>
|
<script src="modules/burgs-and-states.js?v=1.89.07"></script>
|
||||||
<script src="modules/routes-generator.js"></script>
|
<script src="modules/routes-generator.js"></script>
|
||||||
<script src="modules/religions-generator.js?v=1.89.07"></script>
|
<script src="modules/religions-generator.js?v=1.90.00"></script>
|
||||||
<script src="modules/military-generator.js"></script>
|
<script src="modules/military-generator.js"></script>
|
||||||
<script src="modules/markers-generator.js?v=1.87.13"></script>
|
<script src="modules/markers-generator.js?v=1.87.13"></script>
|
||||||
<script src="modules/coa-generator.js"></script>
|
<script src="modules/coa-generator.js"></script>
|
||||||
|
|
@ -7886,7 +7886,7 @@
|
||||||
|
|
||||||
<script defer src="modules/relief-icons.js"></script>
|
<script defer src="modules/relief-icons.js"></script>
|
||||||
<script defer src="modules/ui/style.js"></script>
|
<script defer src="modules/ui/style.js"></script>
|
||||||
<script defer src="modules/ui/editors.js?v=1.89.07"></script>
|
<script defer src="modules/ui/editors.js?v=1.90.00"></script>
|
||||||
<script defer src="modules/ui/tools.js?v=1.89.00"></script>
|
<script defer src="modules/ui/tools.js?v=1.89.00"></script>
|
||||||
<script defer src="modules/ui/world-configurator.js"></script>
|
<script defer src="modules/ui/world-configurator.js"></script>
|
||||||
<script defer src="modules/ui/heightmap-editor.js?v=1.89.06"></script>
|
<script defer src="modules/ui/heightmap-editor.js?v=1.89.06"></script>
|
||||||
|
|
|
||||||
2
main.js
2
main.js
|
|
@ -2038,6 +2038,8 @@ const regenerateMap = debounce(async function (options) {
|
||||||
customization = 0;
|
customization = 0;
|
||||||
resetZoom(1000);
|
resetZoom(1000);
|
||||||
undraw();
|
undraw();
|
||||||
|
pack.religions = [];
|
||||||
|
pack.cultures = [];
|
||||||
await generate(options);
|
await generate(options);
|
||||||
restoreLayers();
|
restoreLayers();
|
||||||
if (ThreeD.options.isOn) ThreeD.redraw();
|
if (ThreeD.options.isOn) ThreeD.redraw();
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,8 @@ window.Cultures = (function () {
|
||||||
|
|
||||||
function selectCultures(culturesNumber) {
|
function selectCultures(culturesNumber) {
|
||||||
let def = getDefault(culturesNumber);
|
let def = getDefault(culturesNumber);
|
||||||
|
|
||||||
const cultures = [];
|
const cultures = [];
|
||||||
|
|
||||||
pack.cultures?.forEach(function (culture) {
|
pack.cultures?.forEach(function (culture) {
|
||||||
if (culture.lock) cultures.push(culture);
|
if (culture.lock) cultures.push(culture);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -519,10 +519,11 @@ function cultureRegenerateBurgs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeCulture(cultureId) {
|
function removeCulture(cultureId) {
|
||||||
|
// and the Folk religion
|
||||||
cults.select("#culture" + cultureId).remove();
|
cults.select("#culture" + cultureId).remove();
|
||||||
debug.select("#cultureCenter" + cultureId).remove();
|
debug.select("#cultureCenter" + cultureId).remove();
|
||||||
|
|
||||||
const {burgs, states, cells, cultures} = pack;
|
const {burgs, states, cells, cultures, religions} = pack;
|
||||||
|
|
||||||
burgs.filter(b => b.culture == cultureId).forEach(b => (b.culture = 0));
|
burgs.filter(b => b.culture == cultureId).forEach(b => (b.culture = 0));
|
||||||
states.forEach(s => {
|
states.forEach(s => {
|
||||||
|
|
@ -531,7 +532,11 @@ function removeCulture(cultureId) {
|
||||||
cells.culture.forEach((c, i) => {
|
cells.culture.forEach((c, i) => {
|
||||||
if (c === cultureId) cells.culture[i] = 0;
|
if (c === cultureId) cells.culture[i] = 0;
|
||||||
});
|
});
|
||||||
|
cells.religion.forEach((r, i) => {
|
||||||
|
if (r === cultureId) cells.religion[i] = 0;
|
||||||
|
})
|
||||||
cultures[cultureId].removed = true;
|
cultures[cultureId].removed = true;
|
||||||
|
religions[cultureId].removed = true;
|
||||||
|
|
||||||
cultures
|
cultures
|
||||||
.filter(c => c.i && !c.removed)
|
.filter(c => c.i && !c.removed)
|
||||||
|
|
@ -539,6 +544,12 @@ function removeCulture(cultureId) {
|
||||||
c.origins = c.origins.filter(origin => origin !== cultureId);
|
c.origins = c.origins.filter(origin => origin !== cultureId);
|
||||||
if (!c.origins.length) c.origins = [0];
|
if (!c.origins.length) c.origins = [0];
|
||||||
});
|
});
|
||||||
|
religions
|
||||||
|
.filter(r => r.i && !r.removed)
|
||||||
|
.forEach(r => {
|
||||||
|
r.origins = r.origins.filter(origin => origin !== cultureId);
|
||||||
|
if (!r.origins.length) r.origins = [0];
|
||||||
|
});
|
||||||
refreshCulturesEditor();
|
refreshCulturesEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -548,7 +559,7 @@ function cultureRemovePrompt() {
|
||||||
const cultureId = +this.parentNode.dataset.id;
|
const cultureId = +this.parentNode.dataset.id;
|
||||||
confirmationDialog({
|
confirmationDialog({
|
||||||
title: "Remove culture",
|
title: "Remove culture",
|
||||||
message: "Are you sure you want to remove the culture? <br>This action cannot be reverted",
|
message: "Are you sure you want to remove the culture? <br>The linked folk religion will also be removed. <br>This action cannot be reverted",
|
||||||
confirm: "Remove",
|
confirm: "Remove",
|
||||||
onConfirm: () => removeCulture(cultureId)
|
onConfirm: () => removeCulture(cultureId)
|
||||||
});
|
});
|
||||||
|
|
@ -823,6 +834,7 @@ function addCulture() {
|
||||||
|
|
||||||
if (d3.event.shiftKey === false) exitAddCultureMode();
|
if (d3.event.shiftKey === false) exitAddCultureMode();
|
||||||
Cultures.add(center);
|
Cultures.add(center);
|
||||||
|
Religions.addFolk(center);
|
||||||
|
|
||||||
drawCultureCenters();
|
drawCultureCenters();
|
||||||
culturesEditorAddLines();
|
culturesEditorAddLines();
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ addListeners();
|
||||||
|
|
||||||
export function open() {
|
export function open() {
|
||||||
closeDialogs("#religionsEditor, .stable");
|
closeDialogs("#religionsEditor, .stable");
|
||||||
|
if (!layerIsOn("toggleReligions")) toggleReligions();
|
||||||
if (layerIsOn("toggleStates")) toggleStates();
|
if (layerIsOn("toggleStates")) toggleStates();
|
||||||
if (layerIsOn("toggleBiomes")) toggleBiomes();
|
if (layerIsOn("toggleBiomes")) toggleBiomes();
|
||||||
if (layerIsOn("toggleCultures")) toggleCultures();
|
if (layerIsOn("toggleCultures")) toggleCultures();
|
||||||
if (layerIsOn("toggleProvinces")) toggleProvinces();
|
if (layerIsOn("toggleProvinces")) toggleProvinces();
|
||||||
if (!layerIsOn("toggleReligions")) toggleReligions();
|
|
||||||
|
|
||||||
refreshReligionsEditor();
|
refreshReligionsEditor();
|
||||||
drawReligionCenters();
|
drawReligionCenters();
|
||||||
|
|
@ -23,13 +23,15 @@ export function open() {
|
||||||
|
|
||||||
function insertEditorHtml() {
|
function insertEditorHtml() {
|
||||||
const editorHtml = /* html */ `<div id="religionsEditor" class="dialog stable">
|
const editorHtml = /* html */ `<div id="religionsEditor" class="dialog stable">
|
||||||
<div id="religionsHeader" class="header" style="grid-template-columns: 13em 6em 7em 18em 5em 6em">
|
<div id="religionsHeader" class="header" style="grid-template-columns: 13em 6em 7em 18em 5em 6em 6em 8em">
|
||||||
<div data-tip="Click to sort by religion name" class="sortable alphabetically" data-sortby="name">Religion </div>
|
<div data-tip="Click to sort by religion name" class="sortable alphabetically" data-sortby="name">Religion </div>
|
||||||
<div data-tip="Click to sort by religion type" class="sortable alphabetically icon-sort-name-down" data-sortby="type">Type </div>
|
<div data-tip="Click to sort by religion type" class="sortable alphabetically icon-sort-name-down" data-sortby="type">Type </div>
|
||||||
<div data-tip="Click to sort by religion form" class="sortable alphabetically hide" data-sortby="form">Form </div>
|
<div data-tip="Click to sort by religion form" class="sortable alphabetically hide" data-sortby="form">Form </div>
|
||||||
<div data-tip="Click to sort by supreme deity" class="sortable alphabetically hide" data-sortby="deity">Supreme Deity </div>
|
<div data-tip="Click to sort by supreme deity" class="sortable alphabetically hide" data-sortby="deity">Supreme Deity </div>
|
||||||
<div data-tip="Click to sort by religion area" class="sortable hide" data-sortby="area">Area </div>
|
<div data-tip="Click to sort by religion area" class="sortable hide" data-sortby="area">Area </div>
|
||||||
<div data-tip="Click to sort by number of believers (religion area population)" class="sortable hide" data-sortby="population">Believers </div>
|
<div data-tip="Click to sort by number of believers (religion area population)" class="sortable hide" data-sortby="population">Believers </div>
|
||||||
|
<div data-tip="Click to sort by potential extent type" class="sortable hide" data-sortby="expansion">Potential </div>
|
||||||
|
<div data-tip="Click to sort by expansionism" class="sortable hide" data-sortby="expansionism">Expansion </div>
|
||||||
</div>
|
</div>
|
||||||
<div id="religionsBody" class="table" data-type="absolute"></div>
|
<div id="religionsBody" class="table" data-type="absolute"></div>
|
||||||
|
|
||||||
|
|
@ -88,6 +90,11 @@ function insertEditorHtml() {
|
||||||
</div>
|
</div>
|
||||||
<button id="religionsAdd" data-tip="Add a new religion. Hold Shift to add multiple" class="icon-plus"></button>
|
<button id="religionsAdd" data-tip="Add a new religion. Hold Shift to add multiple" class="icon-plus"></button>
|
||||||
<button id="religionsExport" data-tip="Download religions-related data" class="icon-download"></button>
|
<button id="religionsExport" data-tip="Download religions-related data" class="icon-download"></button>
|
||||||
|
<button id="religionsRecalculate" data-tip="Recalculate religions based on current values of growth-related attributes" class="icon-retweet"></button>
|
||||||
|
<span data-tip="Allow religion center, extent, and expansionism changes to take an immediate effect">
|
||||||
|
<input id="religionsAutoChange" class="checkbox" type="checkbox" />
|
||||||
|
<label for="religionsAutoChange" class="checkbox-label"><i>auto-apply changes</i></label>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
|
@ -109,6 +116,7 @@ function addListeners() {
|
||||||
byId("religionsManuallyCancel").on("click", () => exitReligionsManualAssignment());
|
byId("religionsManuallyCancel").on("click", () => exitReligionsManualAssignment());
|
||||||
byId("religionsAdd").on("click", enterAddReligionMode);
|
byId("religionsAdd").on("click", enterAddReligionMode);
|
||||||
byId("religionsExport").on("click", downloadReligionsCsv);
|
byId("religionsExport").on("click", downloadReligionsCsv);
|
||||||
|
byId("religionsRecalculate").on("click", () => recalculateReligions(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshReligionsEditor() {
|
function refreshReligionsEditor() {
|
||||||
|
|
@ -166,6 +174,7 @@ function religionsEditorAddLines() {
|
||||||
data-type=""
|
data-type=""
|
||||||
data-form=""
|
data-form=""
|
||||||
data-deity=""
|
data-deity=""
|
||||||
|
data-expansion=""
|
||||||
data-expansionism=""
|
data-expansionism=""
|
||||||
>
|
>
|
||||||
<svg width="11" height="11" class="placeholder"></svg>
|
<svg width="11" height="11" class="placeholder"></svg>
|
||||||
|
|
@ -181,6 +190,9 @@ function religionsEditorAddLines() {
|
||||||
<div data-tip="Religion area" class="religionArea hide" style="width: 5em">${si(area) + unit}</div>
|
<div data-tip="Religion area" class="religionArea hide" style="width: 5em">${si(area) + unit}</div>
|
||||||
<span data-tip="${populationTip}" class="icon-male hide"></span>
|
<span data-tip="${populationTip}" class="icon-male hide"></span>
|
||||||
<div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div>
|
<div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div>
|
||||||
|
<select data-tip="Potential religion extent" class="religionExtent placeholder hide" style="width: 5em"></select>
|
||||||
|
<span class="icon-resize-full placeholder hide"></span>
|
||||||
|
<input class="religionExpan placeholder hide" type="number" />
|
||||||
</div>`;
|
</div>`;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -195,14 +207,21 @@ function religionsEditorAddLines() {
|
||||||
data-type="${r.type}"
|
data-type="${r.type}"
|
||||||
data-form="${r.form}"
|
data-form="${r.form}"
|
||||||
data-deity="${r.deity || ""}"
|
data-deity="${r.deity || ""}"
|
||||||
|
data-expansion="${r.expansion}"
|
||||||
data-expansionism="${r.expansionism}"
|
data-expansionism="${r.expansionism}"
|
||||||
>
|
>
|
||||||
<fill-box fill="${r.color}"></fill-box>
|
<fill-box fill="${r.color}"></fill-box>
|
||||||
<input data-tip="Religion name. Click and type to change" class="religionName" style="width: 11em"
|
<input data-tip="Religion name. Click and type to change" class="religionName" style="width: 11em"
|
||||||
value="${r.name}" autocorrect="off" spellcheck="false" />
|
value="${r.name}" autocorrect="off" spellcheck="false" />
|
||||||
<select data-tip="Religion type" class="religionType" style="width: 5em">
|
${r.type === "Folk" ?
|
||||||
|
`<span data-tip="Religion type" class="religionType" style="width: 5em">
|
||||||
|
Folk
|
||||||
|
</span>`
|
||||||
|
:
|
||||||
|
`<select data-tip="Religion type" class="religionType" style="width: 5em">
|
||||||
${getTypeOptions(r.type)}
|
${getTypeOptions(r.type)}
|
||||||
</select>
|
</select>`
|
||||||
|
}
|
||||||
<input data-tip="Religion form" class="religionForm hide" style="width: 6em"
|
<input data-tip="Religion form" class="religionForm hide" style="width: 6em"
|
||||||
value="${r.form}" autocorrect="off" spellcheck="false" />
|
value="${r.form}" autocorrect="off" spellcheck="false" />
|
||||||
<span data-tip="Click to re-generate supreme deity" class="icon-arrows-cw hide"></span>
|
<span data-tip="Click to re-generate supreme deity" class="icon-arrows-cw hide"></span>
|
||||||
|
|
@ -212,11 +231,37 @@ function religionsEditorAddLines() {
|
||||||
<div data-tip="Religion area" class="religionArea hide" style="width: 5em">${si(area) + unit}</div>
|
<div data-tip="Religion area" class="religionArea hide" style="width: 5em">${si(area) + unit}</div>
|
||||||
<span data-tip="${populationTip}" class="icon-male hide"></span>
|
<span data-tip="${populationTip}" class="icon-male hide"></span>
|
||||||
<div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div>
|
<div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div>
|
||||||
|
${r.type === "Folk" ?
|
||||||
|
`<span data-tip="Potential religion extent" class="hide" style="width: 5em">
|
||||||
|
culture
|
||||||
|
</span>
|
||||||
|
<span class="icon-resize-full placeholder hide"></span>
|
||||||
|
<input class="religionExpan placeholder hide" type="number" />
|
||||||
<span
|
<span
|
||||||
data-tip="Lock this religion"
|
data-tip="Lock this religion"
|
||||||
class="icon-lock${r.lock ? "" : "-open"} hide"
|
class="icon-lock${r.lock ? "" : "-open"} hide"
|
||||||
></span>
|
></span>
|
||||||
<span data-tip="Remove religion" class="icon-trash-empty hide"></span>
|
<span data-tip="Remove religion" class="icon-trash-empty placeholder hide"></span>`
|
||||||
|
:
|
||||||
|
`<select data-tip="Potential religion extent" class="religionExtent hide" style="width: 5em">
|
||||||
|
${getExtentOptions(r.expansion)}
|
||||||
|
</select>
|
||||||
|
<span data-tip="Religion expansionism. Defines competitive size" class="icon-resize-full hide"></span>
|
||||||
|
<input
|
||||||
|
data-tip="Religion expansionism. Defines competitive size. Click to change, then click Recalculate to apply change"
|
||||||
|
class="religionExpan hide"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
max="99"
|
||||||
|
step=".1"
|
||||||
|
value=${r.expansionism}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
data-tip="Lock this religion"
|
||||||
|
class="icon-lock${r.lock ? "" : "-open"} hide"
|
||||||
|
></span>
|
||||||
|
<span data-tip="Remove religion" class="icon-trash-empty hide"></span>`
|
||||||
|
}
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
$body.innerHTML = lines;
|
$body.innerHTML = lines;
|
||||||
|
|
@ -245,6 +290,8 @@ function religionsEditorAddLines() {
|
||||||
$body.querySelectorAll("div > input.religionDeity").forEach(el => el.on("input", religionChangeDeity));
|
$body.querySelectorAll("div > input.religionDeity").forEach(el => el.on("input", religionChangeDeity));
|
||||||
$body.querySelectorAll("div > span.icon-arrows-cw").forEach(el => el.on("click", regenerateDeity));
|
$body.querySelectorAll("div > span.icon-arrows-cw").forEach(el => el.on("click", regenerateDeity));
|
||||||
$body.querySelectorAll("div > div.religionPopulation").forEach(el => el.on("click", changePopulation));
|
$body.querySelectorAll("div > div.religionPopulation").forEach(el => el.on("click", changePopulation));
|
||||||
|
$body.querySelectorAll("div > select.religionExtent").forEach(el => el.on("change", religionChangeExtent));
|
||||||
|
$body.querySelectorAll("div > input.religionExpan").forEach(el => el.on("change", religionChangeExpansionism));
|
||||||
$body.querySelectorAll("div > span.icon-trash-empty").forEach(el => el.on("click", religionRemovePrompt));
|
$body.querySelectorAll("div > span.icon-trash-empty").forEach(el => el.on("click", religionRemovePrompt));
|
||||||
$body.querySelectorAll("div > span.icon-lock").forEach($el => $el.on("click", updateLockStatus));
|
$body.querySelectorAll("div > span.icon-lock").forEach($el => $el.on("click", updateLockStatus));
|
||||||
$body.querySelectorAll("div > span.icon-lock-open").forEach($el => $el.on("click", updateLockStatus));
|
$body.querySelectorAll("div > span.icon-lock-open").forEach($el => $el.on("click", updateLockStatus));
|
||||||
|
|
@ -259,7 +306,14 @@ function religionsEditorAddLines() {
|
||||||
|
|
||||||
function getTypeOptions(type) {
|
function getTypeOptions(type) {
|
||||||
let options = "";
|
let options = "";
|
||||||
const types = ["Folk", "Organized", "Cult", "Heresy"];
|
const types = ["Organized", "Cult", "Heresy"];
|
||||||
|
types.forEach(t => (options += `<option ${type === t ? "selected" : ""} value="${t}">${t}</option>`));
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getExtentOptions(type) {
|
||||||
|
let options = "";
|
||||||
|
const types = ["global", "state", "culture"];
|
||||||
types.forEach(t => (options += `<option ${type === t ? "selected" : ""} value="${t}">${t}</option>`));
|
types.forEach(t => (options += `<option ${type === t ? "selected" : ""} value="${t}">${t}</option>`));
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
@ -434,6 +488,20 @@ function changePopulation() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function religionChangeExtent() {
|
||||||
|
const religion = +this.parentNode.dataset.id;
|
||||||
|
this.parentNode.dataset.expansion = this.value;
|
||||||
|
pack.religions[religion].expansion = this.value;
|
||||||
|
recalculateReligions();
|
||||||
|
}
|
||||||
|
|
||||||
|
function religionChangeExpansionism() {
|
||||||
|
const religion = +this.parentNode.dataset.id;
|
||||||
|
this.parentNode.dataset.expansionism = this.value;
|
||||||
|
pack.religions[religion].expansionism = +this.value;
|
||||||
|
recalculateReligions();
|
||||||
|
}
|
||||||
|
|
||||||
function religionRemovePrompt() {
|
function religionRemovePrompt() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
|
|
||||||
|
|
@ -507,6 +575,7 @@ function religionCenterDrag() {
|
||||||
const cell = findCell(x, y);
|
const cell = findCell(x, y);
|
||||||
if (pack.cells.h[cell] < 20) return; // ignore dragging on water
|
if (pack.cells.h[cell] < 20) return; // ignore dragging on water
|
||||||
pack.religions[religionId].center = cell;
|
pack.religions[religionId].center = cell;
|
||||||
|
recalculateReligions();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -584,7 +653,7 @@ function enterReligionsManualAssignent() {
|
||||||
if (!layerIsOn("toggleReligions")) toggleReligions();
|
if (!layerIsOn("toggleReligions")) toggleReligions();
|
||||||
customization = 7;
|
customization = 7;
|
||||||
relig.append("g").attr("id", "temp");
|
relig.append("g").attr("id", "temp");
|
||||||
document.querySelectorAll("#religionsBottom > button").forEach(el => (el.style.display = "none"));
|
document.querySelectorAll("#religionsBottom > *").forEach(el => (el.style.display = "none"));
|
||||||
byId("religionsManuallyButtons").style.display = "inline-block";
|
byId("religionsManuallyButtons").style.display = "inline-block";
|
||||||
debug.select("#religionCenters").style("display", "none");
|
debug.select("#religionCenters").style("display", "none");
|
||||||
|
|
||||||
|
|
@ -686,7 +755,7 @@ function exitReligionsManualAssignment(close) {
|
||||||
customization = 0;
|
customization = 0;
|
||||||
relig.select("#temp").remove();
|
relig.select("#temp").remove();
|
||||||
removeCircle();
|
removeCircle();
|
||||||
document.querySelectorAll("#religionsBottom > button").forEach(el => (el.style.display = "inline-block"));
|
document.querySelectorAll("#religionsBottom > *").forEach(el => (el.style.display = "inline-block"));
|
||||||
byId("religionsManuallyButtons").style.display = "none";
|
byId("religionsManuallyButtons").style.display = "none";
|
||||||
|
|
||||||
byId("religionsEditor")
|
byId("religionsEditor")
|
||||||
|
|
@ -740,15 +809,15 @@ function addReligion() {
|
||||||
|
|
||||||
function downloadReligionsCsv() {
|
function downloadReligionsCsv() {
|
||||||
const unit = getAreaUnit("2");
|
const unit = getAreaUnit("2");
|
||||||
const headers = `Id,Name,Color,Type,Form,Supreme Deity,Area ${unit},Believers,Origins`;
|
const headers = `Id,Name,Color,Type,Form,Supreme Deity,Area ${unit},Believers,Origins,Potential,Expansionism`;
|
||||||
const lines = Array.from($body.querySelectorAll(":scope > div"));
|
const lines = Array.from($body.querySelectorAll(":scope > div"));
|
||||||
const data = lines.map($line => {
|
const data = lines.map($line => {
|
||||||
const {id, name, color, type, form, deity, area, population} = $line.dataset;
|
const {id, name, color, type, form, deity, area, population, expansion, expansionism} = $line.dataset;
|
||||||
const deityText = '"' + deity + '"';
|
const deityText = '"' + deity + '"';
|
||||||
const {origins} = pack.religions[+id];
|
const {origins} = pack.religions[+id];
|
||||||
const originList = (origins || []).filter(origin => origin).map(origin => pack.religions[origin].name);
|
const originList = (origins || []).filter(origin => origin).map(origin => pack.religions[origin].name);
|
||||||
const originText = '"' + originList.join(", ") + '"';
|
const originText = '"' + originList.join(", ") + '"';
|
||||||
return [id, name, color, type, form, deityText, area, population, originText].join(",");
|
return [id, name, color, type, form, deityText, area, population, originText, expansion, expansionism].join(",");
|
||||||
});
|
});
|
||||||
const csvData = [headers].concat(data).join("\n");
|
const csvData = [headers].concat(data).join("\n");
|
||||||
|
|
||||||
|
|
@ -773,3 +842,13 @@ function updateLockStatus() {
|
||||||
classList.toggle("icon-lock-open");
|
classList.toggle("icon-lock-open");
|
||||||
classList.toggle("icon-lock");
|
classList.toggle("icon-lock");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function recalculateReligions(must) {
|
||||||
|
if (!must && !religionsAutoChange.checked) return;
|
||||||
|
|
||||||
|
Religions.recalculate();
|
||||||
|
|
||||||
|
drawReligions();
|
||||||
|
refreshReligionsEditor();
|
||||||
|
drawReligionCenters();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -678,6 +678,7 @@ window.Religions = (function () {
|
||||||
const cultureId = cells.culture[cellId];
|
const cultureId = cells.culture[cellId];
|
||||||
religionIds[cellId] = cultureToReligionMap.get(cultureId) || 0;
|
religionIds[cellId] = cultureToReligionMap.get(cultureId) || 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return religionIds;
|
return religionIds;
|
||||||
}
|
}
|
||||||
|
|
@ -699,6 +700,32 @@ window.Religions = (function () {
|
||||||
pack.cells.religion = newReligionIds;
|
pack.cells.religion = newReligionIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkCenters() {
|
||||||
|
const cells = pack.cells;
|
||||||
|
pack.religions.forEach(r => {
|
||||||
|
if (!r.i) return;
|
||||||
|
// move religion center if it's not within religion area after expansion
|
||||||
|
if (r.type==="Folk" || cells.religion[r.center] === r.i) return; // in area, or non-expanding
|
||||||
|
const firstCell = cells.i.find(i => cells.religion[i] === r.i);
|
||||||
|
if (firstCell) r.center = firstCell; // move center, othervise it's an extinct religion
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function recalculate() {
|
||||||
|
const {religion, culture} = pack.cells;
|
||||||
|
// start with the culutres map, but also keep locked religions
|
||||||
|
for(const i of pack.cells.i){
|
||||||
|
if( !pack.religions[religion[i]]?.lock ){
|
||||||
|
religion[i] = culture[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expandReligions();
|
||||||
|
expandHeresies();
|
||||||
|
|
||||||
|
checkCenters();
|
||||||
|
}
|
||||||
|
|
||||||
const add = function (center) {
|
const add = function (center) {
|
||||||
const {cells, religions} = pack;
|
const {cells, religions} = pack;
|
||||||
const religionId = cells.religion[center];
|
const religionId = cells.religion[center];
|
||||||
|
|
@ -749,10 +776,122 @@ window.Religions = (function () {
|
||||||
cells.religion[center] = i;
|
cells.religion[center] = i;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addFolk = function (center) {
|
||||||
|
const {cultures, religions, cells} = pack;
|
||||||
|
|
||||||
|
const c = cultures.find(c => !c.removed && c.center === center);
|
||||||
|
const codes = religions.map(r => r.code);
|
||||||
|
const newFolk = createFolk(c, codes);
|
||||||
|
|
||||||
|
if(c.i < religions.length){
|
||||||
|
// move an existing organized religion to the end of the array
|
||||||
|
const rCargo = religions[c.i];
|
||||||
|
if(!rCargo.removed && rCargo.type != "Folk") {
|
||||||
|
const newId = religions.length;
|
||||||
|
rCargo.i = newId;
|
||||||
|
|
||||||
|
for(const i of cells.i) {
|
||||||
|
if(cells.religion[i] = c.i) {
|
||||||
|
cells.religion[i] = newId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
religions.forEach(r => {
|
||||||
|
if (r.i === 0) return;
|
||||||
|
for(let j = 0; j < r.origins.length; j++) {
|
||||||
|
if(r.origins[j] === c.i) {
|
||||||
|
r.origins[j] === newId;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
religions.push(rCargo);
|
||||||
|
}
|
||||||
|
|
||||||
|
religions[c.i] = newFolk;
|
||||||
|
}
|
||||||
|
else religions.push(newFolk);
|
||||||
|
};
|
||||||
|
|
||||||
function updateCultures() {
|
function updateCultures() {
|
||||||
pack.religions = pack.religions.map((religion, index) => {
|
TIME && console.time("updateCulturesForReligions");
|
||||||
if (index === 0) return religion;
|
const {religions, cultures, cells} = pack;
|
||||||
return {...religion, culture: pack.cells.culture[religion.center]};
|
|
||||||
|
const tReligions = [];
|
||||||
|
const spareCovenants = [];
|
||||||
|
const codes = religions.filter(r => !r.removed).map(r => r.code);
|
||||||
|
|
||||||
|
tReligions.push(religions[0]);
|
||||||
|
for (let i = 1; i < cultures.length; i++) {
|
||||||
|
const faith = religions.find(r => r.i === i);
|
||||||
|
if (faith && !faith.removed) {
|
||||||
|
if (faith.type === "Folk") {
|
||||||
|
tReligions.push(faith);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else spareCovenants.push(faith);
|
||||||
|
}
|
||||||
|
const newFolk = createFolk(cultures[i], codes);
|
||||||
|
tReligions.push(newFolk);
|
||||||
|
codes.push(newFolk.code);
|
||||||
|
}
|
||||||
|
for (let i = cultures.length; i < religions.length; i++) {
|
||||||
|
const faith = religions.find(r => r.i === i);
|
||||||
|
if (faith) {
|
||||||
|
if (faith.type === "Folk" && !faith.lock)
|
||||||
|
tReligions.push({...faith, removed: true});
|
||||||
|
else tReligions.push(faith);
|
||||||
|
}
|
||||||
|
else tReligions.push({
|
||||||
|
i,
|
||||||
|
name: "filler index",
|
||||||
|
origins: [null],
|
||||||
|
removed: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateMap = [];
|
||||||
|
for (let k = 0; k < spareCovenants.length; k++) {
|
||||||
|
const sc = spareCovenants[k];
|
||||||
|
const newId = tReligions.length;
|
||||||
|
|
||||||
|
for (const i of cells.i) {
|
||||||
|
if (cells.religion[i] = sc.i) {
|
||||||
|
cells.religion[i] = newId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMap.push({oldId: sc.i, newId});
|
||||||
|
tReligions.forEach(r => {
|
||||||
|
if (r.i === 0) return;
|
||||||
|
for (let i = 0; i < r.origins.length; i++) {
|
||||||
|
if (r.origins[i] === sc.i) {
|
||||||
|
r.origins[i] === newId;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// update origins from other spareCovenants
|
||||||
|
for (let i = 0; i < sc.origins.length; i++) {
|
||||||
|
const changeRule = updateMap.find(u => u.oldId === sc.origins[i])
|
||||||
|
if (changeRule) sc.origins[i] = changeRule.newId;
|
||||||
|
}
|
||||||
|
tReligions.push({...sc, i: newId});
|
||||||
|
}
|
||||||
|
|
||||||
|
pack.religions = tReligions;
|
||||||
|
|
||||||
|
pack.religions.forEach(r => {
|
||||||
|
if (r.i === 0) return;
|
||||||
|
|
||||||
|
if (r.origins?.length < 1) r.origins = [0];
|
||||||
|
|
||||||
|
if (r.type === "Folk" && cultures[r.i]) {
|
||||||
|
r.center = cultures[r.i].center;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
r.culture = cells.culture[r.center];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1188,6 +1188,6 @@ async function editCultures() {
|
||||||
|
|
||||||
async function editReligions() {
|
async function editReligions() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
const Editor = await import("../dynamic/editors/religions-editor.js?v=1.88.07");
|
const Editor = await import("../dynamic/editors/religions-editor.js?v=1.90.00");
|
||||||
Editor.open();
|
Editor.open();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ const version = "1.89.08"; // generator version, update each time
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<strong>Latest changes:</strong>
|
<strong>Latest changes:</strong>
|
||||||
|
<li>Religions can be edited and redrawn like cultures</li>
|
||||||
<li>Lock states, provinces, cultures, and religions from regeneration</li>
|
<li>Lock states, provinces, cultures, and religions from regeneration</li>
|
||||||
<li>Heightmap brushes: linear edit option</li>
|
<li>Heightmap brushes: linear edit option</li>
|
||||||
<li>Data Charts screen</li>
|
<li>Data Charts screen</li>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue