fix: clean cultures on regeneration, v1.89.07

This commit is contained in:
Azgaar 2023-02-19 18:11:07 +04:00
parent acbe839ee7
commit d40cab2e28
7 changed files with 41 additions and 35 deletions

View file

@ -350,9 +350,8 @@ window.Religions = (function () {
const religions = [];
// add folk religions
pack.cultures.forEach(c => {
const newId = c.i;
if (!newId) return religions.push({i: 0, name: "No religion"});
cultures.forEach(c => {
if (!c.i) return religions.push({i: 0, name: "No religion"});
if (c.removed) {
religions.push({
@ -364,6 +363,8 @@ window.Religions = (function () {
return;
}
const newId = c.i;
if (pack.religions) {
const lockedFolkReligion = pack.religions.find(
r => r.culture === c.i && !r.removed && r.lock && r.type === "Folk"
@ -383,7 +384,7 @@ window.Religions = (function () {
const form = rw(forms.Folk);
const name = c.name + " " + rw(types[form]);
const deity = form === "Animism" ? null : getDeityName(c.i);
const color = getMixedColor(c.color, 0.1, 0); // `url(#hatch${rand(8,13)})`;
const color = getMixedColor(c.color, 0.1, 0);
religions.push({
i: newId,
name,
@ -713,14 +714,10 @@ window.Religions = (function () {
};
function updateCultures() {
TIME && console.time("updateCulturesForReligions");
pack.religions = pack.religions.map((religion, index) => {
if (index === 0) {
return religion;
}
if (index === 0) return religion;
return {...religion, culture: pack.cells.culture[religion.center]};
});
TIME && console.timeEnd("updateCulturesForReligions");
}
// get supreme deity name