what is locked folk?

This commit is contained in:
Canis Artorus 2023-02-23 12:44:29 -07:00
parent 2ea53d2688
commit 1c3ec99c59
4 changed files with 29 additions and 38 deletions

View file

@ -125,8 +125,7 @@ window.Cultures = (function () {
}); });
if (cultures.length) { if (cultures.length) {
if (pack.religions?.length > 2) {
if (pack.religions?.length > 1) {
const religions = pack.religions; const religions = pack.religions;
const religMap = []; const religMap = [];
religions.forEach(r => religMap.push(r.type === "Folk" ? 0 : r.i)); // remove folk religions in general religions.forEach(r => religMap.push(r.type === "Folk" ? 0 : r.i)); // remove folk religions in general
@ -139,24 +138,11 @@ window.Cultures = (function () {
religions.forEach(r => { religions.forEach(r => {
if (r.i === 0) return; if (r.i === 0) return;
// queue for movement to newId, or removal // queue for movement to new id, or removal
if (religMap[r.i]) r.i = religMap[r.i]; if (religMap[r.i]) r.i = religMap[r.i];
else if (r.locked) { else {
// locked folk religion getting a new culture r.removed = true; // the folk religions that were left behind by unlocked cultures
if (religMap.find(r.i) > 0) { // something already there, shift away from conflict
const nextId = religMap.find(0);
if (nextId > 0) {
religMap[r.i] = nextId;
r.i = nextId;
}
else { // none available...
religMap[r.i] = religMap.length;
r.i = religMap.length;
religMap.push(r.i);
}
}
} }
else r.removed = true; // the unlocked folk religions that were left behind by unlocked cultures
// update origin heirarchy to the new ids // update origin heirarchy to the new ids
r.origins = r.origins.map(i => religMap[i]).filter(i => i); r.origins = r.origins.map(i => religMap[i]).filter(i => i);
@ -169,16 +155,14 @@ window.Cultures = (function () {
} else { } else {
if (c === def.length) return def; if (c === def.length) return def;
if (def.every(d => d.odd === 1)) return def.splice(0, c); if (def.every(d => d.odd === 1)) return def.splice(0, c);
if (pack.religions?.length > 2) {
pack.religions.forEach(r => {
if (r.type === "Folk" && !r.lock) r.removed = true;
});
}
} }
pack.religions?.forEach(r => { for (let culture, rnd, i = 0; cultures.length < c && def.length > 0;) {
if (r.type === "Folk" && !r.locked)
cells.religion = cells.religion.map(ri => ri === r.i ? 0 : ri);
});
let culture, rnd;
let i = 0;
do {
do { do {
rnd = rand(def.length - 1); rnd = rand(def.length - 1);
culture = def[rnd]; culture = def[rnd];
@ -186,7 +170,7 @@ window.Cultures = (function () {
} while (i < 200 && !P(culture.odd)); } while (i < 200 && !P(culture.odd));
cultures.push(culture); cultures.push(culture);
def.splice(rnd, 1); def.splice(rnd, 1);
} while (cultures.length < c && def.length > 0); }
return cultures; return cultures;
} }

View file

@ -234,16 +234,22 @@ function religionsEditorAddLines() {
${r.type === "Folk" ? ${r.type === "Folk" ?
`<span data-tip="Potential religion extent" class="hide" style="width: 5em"> `<span data-tip="Potential religion extent" class="hide" style="width: 5em">
culture culture
</span>` </span>
<span class="icon-resize-full placeholder hide"></span>
<input class="religionExpan placeholder hide" type="number" />
<span
data-tip="Lock religion, culture changes still take precence"
class="icon-lock${r.lock ? "" : "-open"} 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"> `<select data-tip="Potential religion extent" class="religionExtent hide" style="width: 5em">
${getExtentOptions(r.expansion)} ${getExtentOptions(r.expansion)}
</select>` </select>
} <span data-tip="Religion expansionism. Defines competitive size" class="icon-resize-full hide"></span>
<span data-tip="Religion expansionism. Defines competitive size" class="icon-resize-full ${r.type === "Folk" ? "placeholder " : ""}hide"></span>
<input <input
data-tip="Religion expansionism. Defines competitive size. Click to change, then click Recalculate to apply change" data-tip="Religion expansionism. Defines competitive size. Click to change, then click Recalculate to apply change"
class="religionExpan ${r.type === "Folk" ? "placeholder " : ""}hide" class="religionExpan hide"
type="number" type="number"
min="0" min="0"
max="99" max="99"
@ -251,10 +257,11 @@ function religionsEditorAddLines() {
value=${r.expansionism} value=${r.expansionism}
/> />
<span <span
data-tip="Lock religion, will regenerate the origin folk and organized religion if they are not also locked" 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 ${r.type === "Folk" ? "placeholder " : ""}hide"></span> <span data-tip="Remove religion" class="icon-trash-empty hide"></span>`
}
</div>`; </div>`;
} }
$body.innerHTML = lines; $body.innerHTML = lines;

View file

@ -813,7 +813,7 @@ window.Religions = (function () {
for (let i = cultures.length; i < religions.length; i++) { for (let i = cultures.length; i < religions.length; i++) {
const faith = religions.find(r => r.i === i); const faith = religions.find(r => r.i === i);
if (faith) { if (faith) {
if (faith.type === "Folk" && !faith.locked) if (faith.type === "Folk" && !faith.lock)
tReligions.push({...faith, removed: true}); tReligions.push({...faith, removed: true});
else tReligions.push(faith); else tReligions.push(faith);
} }

View file

@ -29,7 +29,7 @@ const version = "1.90.00"; // generator version, update each time
<ul> <ul>
<strong>Latest changes:</strong> <strong>Latest changes:</strong>
<li>Religions update by center and expansionism value</li> <li>Religions update by center and expansionism value</li>
<li>Adding a culture manually also adds a folk religion for it</li> <li>Adding, removing, and regenerating cultures also affect the linked folk religion</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>