mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
Folk religions follow cultures through regeneration; extinct religion centers draw, folk centers are immutable and do not
This commit is contained in:
parent
de3ed0d705
commit
81a19337a9
4 changed files with 48 additions and 23 deletions
|
|
@ -7845,7 +7845,7 @@
|
|||
<script src="modules/river-generator.js"></script>
|
||||
<script src="modules/lakes.js"></script>
|
||||
<script src="modules/names-generator.js?v=1.87.14"></script>
|
||||
<script src="modules/cultures-generator.js?v=1.89.00"></script>
|
||||
<script src="modules/cultures-generator.js?v=1.90.00"></script>
|
||||
<script src="modules/burgs-and-states.js?v=1.89.00"></script>
|
||||
<script src="modules/routes-generator.js"></script>
|
||||
<script src="modules/religions-generator.js?v=1.90.00"></script>
|
||||
|
|
|
|||
|
|
@ -127,6 +127,27 @@ window.Cultures = (function () {
|
|||
pack.cultures?.forEach(function (culture) {
|
||||
if (culture.lock) cultures.push(culture);
|
||||
});
|
||||
if(pack.religions?.length){
|
||||
const religMap=[];
|
||||
pack.religions.forEach(r => religMap.push(r.type === "Folk" ? 0 : r.i)); // remove folk religions in general
|
||||
for(const j = 0; j < cultures.length; j++) { // locked cultures save their folk religions, at the new id
|
||||
const k = j+1;
|
||||
religMap[cultures[j].i] = k;
|
||||
});
|
||||
for(const i of cells.i){
|
||||
cells.religion[i] = religMap[cells.religion[i]];
|
||||
}
|
||||
for(const i = 0; i < religMap.length; i++){
|
||||
// update origin heirarchy to the new ids
|
||||
pack.religions[i].origins = pack.religions[i].origins.map(i => religMap[i]).filter(i => i);
|
||||
if(religMap[i] !== i){
|
||||
if(religMap[i] !== 0)
|
||||
pack.religions[religMap[i]] = pack.religions[i];
|
||||
// folk religions for unlocked cultures are removed pending regeneration
|
||||
pack.religions[i].removed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let culture, rnd, i = 0; cultures.length < count && i < 200; i++) {
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -536,7 +536,7 @@ function drawReligionCenters() {
|
|||
.attr("stroke", "#444444")
|
||||
.style("cursor", "move");
|
||||
|
||||
const data = pack.religions.filter(r => r.i && r.center && r.cells && !r.removed);
|
||||
const data = pack.religions.filter(r => r.i && r.center && !r.type==="Folk" && !r.removed);
|
||||
religionCenters
|
||||
.selectAll("circle")
|
||||
.data(data)
|
||||
|
|
|
|||
|
|
@ -758,25 +758,26 @@ window.Religions = (function () {
|
|||
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;
|
||||
if(c.i < religions.length){
|
||||
const rCargo = religions[c.i];
|
||||
if(!rCargo.removed) {
|
||||
const newId = religions.length;
|
||||
rCargo.i = newId;
|
||||
for(const i of cells.i) {
|
||||
if(cells.religion[i] = c.i) {
|
||||
cells.religion[i] = newId;
|
||||
}
|
||||
}
|
||||
});
|
||||
religions.push(rCargo);
|
||||
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);
|
||||
|
|
@ -785,11 +786,14 @@ window.Religions = (function () {
|
|||
|
||||
function updateCultures() {
|
||||
TIME && console.time("updateCulturesForReligions");
|
||||
pack.religions = pack.religions.map((religion, index) => {
|
||||
if (index === 0) {
|
||||
return religion;
|
||||
pack.religions.forEach(r => {
|
||||
if(r.i === 0) return;
|
||||
if(!r.origins.length) r.origins = [0];
|
||||
if(r.type === "Folk"){
|
||||
if(r.removed) addFolk(pack.cultures[r.i].center); // regnerate folk religions for the regenerated cultures
|
||||
else r.center = pack.cultures[r.i].center;
|
||||
}
|
||||
return {...religion, culture: pack.cells.culture[religion.center]};
|
||||
else r.culture = pack.cells.culture[r.center];
|
||||
});
|
||||
TIME && console.timeEnd("updateCulturesForReligions");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue