From 1c3ec99c598360334fd3e72c4d4421f6e3c23d44 Mon Sep 17 00:00:00 2001 From: Canis Artorus Date: Thu, 23 Feb 2023 12:44:29 -0700 Subject: [PATCH] what is locked folk? --- modules/cultures-generator.js | 40 +++++++-------------- modules/dynamic/editors/religions-editor.js | 23 +++++++----- modules/religions-generator.js | 2 +- versioning.js | 2 +- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/modules/cultures-generator.js b/modules/cultures-generator.js index 4e0b47ba..db8fb06a 100644 --- a/modules/cultures-generator.js +++ b/modules/cultures-generator.js @@ -125,8 +125,7 @@ window.Cultures = (function () { }); if (cultures.length) { - - if (pack.religions?.length > 1) { + if (pack.religions?.length > 2) { const religions = pack.religions; const religMap = []; 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 => { 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]; - else if (r.locked) { - // locked folk religion getting a new culture - 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 folk religions that were left behind by unlocked cultures } - else r.removed = true; // the unlocked folk religions that were left behind by unlocked cultures // update origin heirarchy to the new ids r.origins = r.origins.map(i => religMap[i]).filter(i => i); @@ -164,21 +150,19 @@ window.Cultures = (function () { for (const i of cells.i) { cells.religion[i] = religMap[cells.religion[i]]; - } + } } } else { if (c === def.length) return def; 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 => { - if (r.type === "Folk" && !r.locked) - cells.religion = cells.religion.map(ri => ri === r.i ? 0 : ri); - }); - - let culture, rnd; - let i = 0; - do { + for (let culture, rnd, i = 0; cultures.length < c && def.length > 0;) { do { rnd = rand(def.length - 1); culture = def[rnd]; @@ -186,7 +170,7 @@ window.Cultures = (function () { } while (i < 200 && !P(culture.odd)); cultures.push(culture); def.splice(rnd, 1); - } while (cultures.length < c && def.length > 0); + } return cultures; } diff --git a/modules/dynamic/editors/religions-editor.js b/modules/dynamic/editors/religions-editor.js index f4e8c086..fb7e1e07 100644 --- a/modules/dynamic/editors/religions-editor.js +++ b/modules/dynamic/editors/religions-editor.js @@ -234,16 +234,22 @@ function religionsEditorAddLines() { ${r.type === "Folk" ? ` culture - ` + + + + + ` : `` - } - + + - + ` + } `; } $body.innerHTML = lines; diff --git a/modules/religions-generator.js b/modules/religions-generator.js index 14a98ec5..44426f59 100644 --- a/modules/religions-generator.js +++ b/modules/religions-generator.js @@ -813,7 +813,7 @@ window.Religions = (function () { for (let i = cultures.length; i < religions.length; i++) { const faith = religions.find(r => r.i === i); if (faith) { - if (faith.type === "Folk" && !faith.locked) + if (faith.type === "Folk" && !faith.lock) tReligions.push({...faith, removed: true}); else tReligions.push(faith); } diff --git a/versioning.js b/versioning.js index 18173fac..b140206a 100644 --- a/versioning.js +++ b/versioning.js @@ -29,7 +29,7 @@ const version = "1.90.00"; // generator version, update each time