mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
add / remove Culture creates / removes Folk religion
This commit is contained in:
parent
05a45fca86
commit
6d9c8df651
3 changed files with 71 additions and 15 deletions
|
|
@ -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? <br>This action cannot be reverted",
|
||||
message: "Are you sure you want to remove the culture? <br>The linked folk religion will also be removed. <br>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();
|
||||
|
|
|
|||
|
|
@ -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<pack.religions.length){
|
||||
if(pack.religions[j].type != "Folk"){
|
||||
knownFolk = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const {religion, culture} = pack.cells;
|
||||
|
||||
for(const i of pack.cells.i){
|
||||
if( culture[i] && (culture[i] < +knownFolk) && !pack.religions[religion[i]]?.lock ){
|
||||
if( !pack.religions[religion[i]]?.lock ){
|
||||
religion[i] = culture[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {generate, expandReligions, expandHeresies, checkReligionCenters, add, getDeityName, updateCultures, resetUnlockedReligions};
|
||||
return {generate, expandReligions, expandHeresies, checkReligionCenters, add, addFolk, getDeityName, updateCultures, resetUnlockedReligions};
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ const version = "1.90.00"; // generator version, update each time
|
|||
|
||||
<ul>
|
||||
<strong>Latest changes:</strong>
|
||||
<li>Religions update by center drag expansionism value</li>
|
||||
<li>Religions update by center and expansionism value</li>
|
||||
<li>Adding a culture manually also adds a folk religion for it</li>
|
||||
<li>Lock states, provinces, cultures, and religions from regeneration</li>
|
||||
<li>Heightmap brushes: linear edit option</li>
|
||||
<li>Data Charts screen</li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue