From 9f32bb258c04fa48d1973dc141d651778ef51058 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 7 Jun 2022 11:04:01 +0300 Subject: [PATCH] fix: cults origins if max is 0 --- index.html | 2 +- modules/religions-generator.js | 23 ++++++++++++++--------- versioning.js | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index fd665d47..ee426085 100644 --- a/index.html +++ b/index.html @@ -7801,7 +7801,7 @@ - + diff --git a/modules/religions-generator.js b/modules/religions-generator.js index bc820384..a213f728 100644 --- a/modules/religions-generator.js +++ b/modules/religions-generator.js @@ -385,6 +385,7 @@ window.Religions = (function () { const count = +religionsInput.value - cultsCount + religions.length; function getReligionsInRadius({x, y, r, max}) { + if (max === 0) return [0]; const cellsInRadius = findAll(x, y, r); const religions = unique(cellsInRadius.map(i => cells.religion[i]).filter(r => r)); return religions.length ? religions.slice(0, max) : [0]; @@ -421,6 +422,7 @@ window.Religions = (function () { const expansionism = rand(3, 8); const baseColor = religions[culture]?.color || states[state]?.color || getRandomColor(); const color = getMixedColor(baseColor, 0.3, 0); + religions.push({ i: religions.length, name, @@ -517,17 +519,17 @@ window.Religions = (function () { }; const add = function (center) { - const cells = pack.cells, - religions = pack.religions; - const r = cells.religion[center]; - const i = religions.length; + const {cells, religions} = pack; + const religionId = cells.religion[center]; + const culture = cells.culture[center]; - const color = getMixedColor(religions[r].color, 0.3, 0); + const color = getMixedColor(religions[religionId].color, 0.3, 0); const type = - religions[r].type === "Organized" ? rw({Organized: 4, Cult: 1, Heresy: 2}) : rw({Organized: 5, Cult: 2}); + religions[religionId].type === "Organized" ? rw({Organized: 4, Cult: 1, Heresy: 2}) : rw({Organized: 5, Cult: 2}); const form = rw(forms[type]); - const deity = type === "Heresy" ? religions[r].deity : form === "Non-theism" ? null : getDeityName(culture); + const deity = + type === "Heresy" ? religions[religionId].deity : form === "Non-theism" ? null : getDeityName(culture); let name, expansion; if (type === "Organized") [name, expansion] = getReligionName(form, deity, center); @@ -535,11 +537,14 @@ window.Religions = (function () { name = getCultName(form, center); expansion = "global"; } - const formName = type === "Heresy" ? religions[r].form : form; + + const formName = type === "Heresy" ? religions[religionId].form : form; const code = abbreviate( name, religions.map(r => r.code) ); + + const i = religions.length; religions.push({ i, name, @@ -555,7 +560,7 @@ window.Religions = (function () { area: 0, rural: 0, urban: 0, - origins: [r], + origins: [religionId], code }); cells.religion[center] = i; diff --git a/versioning.js b/versioning.js index a811c90f..728515af 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.86.01"; // generator version, update each time +const version = "1.86.02"; // generator version, update each time { document.title += " v" + version;