diff --git a/modules/dynamic/editors/cultures-editor.js b/modules/dynamic/editors/cultures-editor.js
index 3f8018d6..ac323573 100644
--- a/modules/dynamic/editors/cultures-editor.js
+++ b/modules/dynamic/editors/cultures-editor.js
@@ -519,10 +519,11 @@ function cultureRegenerateBurgs() {
}
function removeCulture(cultureId) {
+ // and the Folk religion
cults.select("#culture" + 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));
states.forEach(s => {
@@ -531,7 +532,11 @@ function removeCulture(cultureId) {
cells.culture.forEach((c, i) => {
if (c === cultureId) cells.culture[i] = 0;
});
+ cells.religion.forEach((r, i) => {
+ if (r === cultureId) cells.religion[i] = 0;
+ })
cultures[cultureId].removed = true;
+ religions[cultureId].removed = true;
cultures
.filter(c => c.i && !c.removed)
@@ -539,6 +544,12 @@ function removeCulture(cultureId) {
c.origins = c.origins.filter(origin => origin !== cultureId);
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();
}
@@ -548,7 +559,7 @@ function cultureRemovePrompt() {
const cultureId = +this.parentNode.dataset.id;
confirmationDialog({
title: "Remove culture",
- message: "Are you sure you want to remove the culture?
This action cannot be reverted",
+ message: "Are you sure you want to remove the culture?
The linked folk religion will also be removed.
This action cannot be reverted",
confirm: "Remove",
onConfirm: () => removeCulture(cultureId)
});
@@ -823,6 +834,7 @@ function addCulture() {
if (d3.event.shiftKey === false) exitAddCultureMode();
Cultures.add(center);
+ Religions.addFolk(center);
drawCultureCenters();
culturesEditorAddLines();
diff --git a/modules/religions-generator.js b/modules/religions-generator.js
index 6d73c34c..fa36d8a6 100644
--- a/modules/religions-generator.js
+++ b/modules/religions-generator.js
@@ -717,6 +717,57 @@ window.Religions = (function () {
cells.religion[center] = i;
};
+ const addFolk = function (center) {
+ const {cultures, religions, cells} = pack;
+
+ const c = cultures.find(c => !c.removed && c.center === center);
+ const color = getMixedColor(c.color, 0.1, 0);
+ const form = rw(forms.Folk);
+ const deity = form === "Animism" ? null : getDeityName(c.i);
+ const name = c.name + " " + rw(types[form]);
+ const code = abbreviate(name);
+ const newFolk = {
+ i: c.i,
+ name,
+ color,
+ culture: c.i,
+ type: "Folk",
+ form,
+ deity,
+ center: center,
+ cells: 0,
+ area: 0,
+ rural: 0,
+ urban: 0,
+ origins: [0],
+ code
+ };
+
+ if(religions[c.i]){
+ let rCargo = religions[c.i];
+ if(rCargo.type === "Folk") return;
+ 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 => {
+ 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() {
TIME && console.time("updateCulturesForReligions");
pack.religions = pack.religions.map((religion, index) => {
@@ -805,22 +856,14 @@ window.Religions = (function () {
}
const resetUnlockedReligions = function() {
- const religion = pack.cells.religion;
- const culture = pack.cells.culture;
- // ignore cultures added since last folk generation. Known Issue
- let knownFolk = 1;
- for(let j = 1; j++; j
Latest changes:
- Religions update by center drag expansionism value
+ Religions update by center and expansionism value
+ Adding a culture manually also adds a folk religion for it
Lock states, provinces, cultures, and religions from regeneration
Heightmap brushes: linear edit option
Data Charts screen