Supporters update

This commit is contained in:
Azgaar 2022-01-10 19:30:51 +03:00 committed by Peter
parent a51d2e6403
commit 7c09d7376e

View file

@ -1,4 +1,4 @@
'use strict'; "use strict";
window.Religions = (function () { window.Religions = (function () {
// name generation approach and relative chance to be selected // name generation approach and relative chance to be selected
@ -63,46 +63,19 @@ window.Religions = (function () {
"Ape", "Ape",
"Badger", "Badger",
"Basilisk", "Basilisk",
=======
"God",
"Goddess",
"Lord",
"Lady",
"Deity",
"Creator",
"Maker",
"Master",
"Mother",
"Numen",
"Overlord",
"Reaper"
"Ruler",
"Sister",
"Spirit",
"Virgin",
],
animal: [
"Antelope",
"Ape",
"Badger",
"Bear", "Bear",
"Beaver", "Beaver",
"Bison", "Bison",
"Boar", "Boar",
"Buffalo", "Buffalo",
<<<<<<< HEAD
"Camel", "Camel",
"Cat", "Cat",
"Centaur", "Centaur",
"Chimera", "Chimera",
=======
"Cat",
>>>>>>> c6917a14 (religion gen fix)
"Cobra", "Cobra",
"Crane", "Crane",
"Crocodile", "Crocodile",
"Crow", "Crow",
<<<<<<< HEAD
"Cyclope", "Cyclope",
"Deer", "Deer",
"Dog", "Dog",
@ -110,10 +83,6 @@ window.Religions = (function () {
"Eagle", "Eagle",
"Elk", "Elk",
"Falcon", "Falcon",
"Deer",
"Dog",
"Eagle",
"Elk",
"Fox", "Fox",
"Goat", "Goat",
"Goose", "Goose",
@ -140,7 +109,6 @@ window.Religions = (function () {
"Panther", "Panther",
"Pegasus", "Pegasus",
"Phoenix", "Phoenix",
"Panther",
"Rat", "Rat",
"Raven", "Raven",
"Rook", "Rook",
@ -150,9 +118,6 @@ window.Religions = (function () {
"Sheep", "Sheep",
"Snake", "Snake",
"Sphinx", "Sphinx",
"Shark",
"Sheep",
"Snake",
"Spider", "Spider",
"Swan", "Swan",
"Tiger", "Tiger",
@ -330,166 +295,12 @@ window.Religions = (function () {
"White", "White",
"Yellow" "Yellow"
] ]
=======
"Camel",
"Falcon",
"Hound",
"Ox",
"Serpent"
],
adjective: [
"Aggressive",
"Almighty",
"Ancient",
"Beautiful",
"Benevolent",
"Big",
"Blind",
"Blond",
"Bloody",
"Brave",
"Broken",
"Brutal",
"Burning",
"Calm",
"Cheerful",
"Crazy",
"Cruel",
"Dead",
"Deadly",
"Devastating",
"Distant",
"Disturbing",
"Divine",
"Dying",
"Eternal",
"Evil",
"Explicit",
"Fair",
"Far",
"Fat",
"Fatal",
"Favorable",
"Flying",
"Friendly",
"Frozen",
"Giant",
"Good",
"Grateful",
"Great",
"Happy",
"High",
"Holy",
"Honest",
"Huge",
"Hungry",
"Immutable",
"Infallible"
"Inherent",
"Last",
"Latter",
"Lost",
"Loud",
"Lucky",
"Mad",
"Magical",
"Main",
"Major",
"Marine",
"Naval",
"New",
"Old",
"Patient",
"Peaceful",
"Pregnant",
"Prime",
"Proud",
"Pure",
"Sacred",
"Sad",
"Scary",
"Secret",
"Selected",
"Severe",
"Silent",
"Sleeping",
"Slumbering",
"Strong",
"Sunny",
"Superior",
"Sustainable",
"Troubled",
"Unhappy",
"Unknown",
"Waking",
"Wild",
"Wise",
"Worried",
"Young",
],
genitive: [
"Cold",
"Day",
"Death",
"Doom",
"Fate",
"Fire",
"Fog",
"Frost",
"Gates",
"Heaven",
"Home",
"Ice",
"Justice",
"Life",
"Light",
"Lightning",
"Love",
"Nature",
"Night",
"Pain",
"Snow",
"Springs",
"Summer",
"Thunder",
"Time",
"Victory"
"War",
"Winter",
],
theGenitive: [
"Abyss",
"Blood",
"Dawn",
"Earth",
"East",
"Eclipse",
"Fall",
"Harvest",
"Moon",
"North",
"Peak",
"Rainbow",
"Sea",
"Sky",
"South",
"Stars",
"Storm",
"Sun",
"Tree",
"Underworld",
"West",
"Wild"
"Word",
"World",
],
color: ["Dark", "Light", "Bright", "Golden", "White", "Black", "Red", "Pink", "Purple", "Blue", "Green", "Yellow", "Amber", "Orange", "Brown", "Grey"]
}; };
const forms = { const forms = {
Folk: {Shamanism: 2, Animism: 2, 'Ancestor worship': 1, Polytheism: 2}, Folk: {Shamanism: 2, Animism: 2, "Ancestor worship": 1, Polytheism: 2},
Organized: {Polytheism: 5, Dualism: 1, Monotheism: 4, 'Non-theism': 1}, Organized: {Polytheism: 5, Dualism: 1, Monotheism: 4, "Non-theism": 1},
Cult: {Cult: 1, 'Dark Cult': 1}, Cult: {Cult: 1, "Dark Cult": 1},
Heresy: {Heresy: 1} Heresy: {Heresy: 1}
}; };
@ -507,12 +318,12 @@ window.Religions = (function () {
const types = { const types = {
Shamanism: {Beliefs: 3, Shamanism: 2, Spirits: 1}, Shamanism: {Beliefs: 3, Shamanism: 2, Spirits: 1},
Animism: {Spirits: 1, Beliefs: 1}, Animism: {Spirits: 1, Beliefs: 1},
'Ancestor worship': {Beliefs: 1, Forefathers: 2, Ancestors: 2}, "Ancestor worship": {Beliefs: 1, Forefathers: 2, Ancestors: 2},
Polytheism: {Deities: 3, Faith: 1, Gods: 1, Pantheon: 1}, Polytheism: {Deities: 3, Faith: 1, Gods: 1, Pantheon: 1},
Dualism: {Religion: 3, Faith: 1, Cult: 1}, Dualism: {Religion: 3, Faith: 1, Cult: 1},
Monotheism: {Religion: 1, Church: 1}, Monotheism: {Religion: 1, Church: 1},
'Non-theism': {Beliefs: 3, Spirits: 1}, "Non-theism": {Beliefs: 3, Spirits: 1},
Cult: {Cult: 4, Sect: 4, Arcanum: 1, Coterie: 1, Order: 1, Worship: 1}, Cult: {Cult: 4, Sect: 4, Arcanum: 1, Coterie: 1, Order: 1, Worship: 1},
"Dark Cult": {Cult: 2, Sect: 2, Blasphemy: 1, Circle: 1, Coven: 1, Idols: 1, Occultism: 1}, "Dark Cult": {Cult: 2, Sect: 2, Blasphemy: 1, Circle: 1, Coven: 1, Idols: 1, Occultism: 1},
@ -532,7 +343,7 @@ window.Religions = (function () {
}; };
const generate = function () { const generate = function () {
TIME && console.time('generateReligions'); TIME && console.time("generateReligions");
const cells = pack.cells, const cells = pack.cells,
states = pack.states, states = pack.states,
cultures = pack.cultures; cultures = pack.cultures;
@ -554,8 +365,8 @@ window.Religions = (function () {
} }
const form = rw(forms.Folk); const form = rw(forms.Folk);
const name = c.name + ' ' + rw(types[form]); const name = c.name + " " + rw(types[form]);
const deity = form === 'Animism' ? null : getDeityName(c.i); 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); // `url(#hatch${rand(8,13)})`;
religions.push({i: c.i, name, color, culture: c.i, type: "Folk", form, deity, center: c.center, origins: [0]}); religions.push({i: c.i, name, color, culture: c.i, type: "Folk", form, deity, center: c.center, origins: [0]});
}); });
@ -587,13 +398,13 @@ window.Religions = (function () {
const state = cells.state[center]; const state = cells.state[center];
const culture = cells.culture[center]; const culture = cells.culture[center];
const deity = form === 'Non-theism' ? null : getDeityName(culture); const deity = form === "Non-theism" ? null : getDeityName(culture);
let [name, expansion] = getReligionName(form, deity, center); let [name, expansion] = getReligionName(form, deity, center);
if (expansion === 'state' && !state) expansion = 'global'; if (expansion === "state" && !state) expansion = "global";
if (expansion === 'culture' && !culture) expansion = 'global'; if (expansion === "culture" && !culture) expansion = "global";
if (expansion === 'state' && Math.random() > 0.5) center = states[state].center; if (expansion === "state" && Math.random() > 0.5) center = states[state].center;
if (expansion === 'culture' && Math.random() > 0.5) center = cultures[culture].center; if (expansion === "culture" && Math.random() > 0.5) center = cultures[culture].center;
if (!cells.burg[center] && cells.c[center].some(c => cells.burg[c])) if (!cells.burg[center] && cells.c[center].some(c => cells.burg[c]))
center = cells.c[center].find(c => cells.burg[c]); center = cells.c[center].find(c => cells.burg[c]);
@ -666,8 +477,8 @@ window.Religions = (function () {
// generate heresies // generate heresies
religions religions
.filter((r) => r.type === 'Organized') .filter(r => r.type === "Organized")
.forEach((r) => { .forEach(r => {
if (r.expansionism < 3) return; if (r.expansionism < 3) return;
const count = gauss(0, 1, 0, 3); const count = gauss(0, 1, 0, 3);
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
@ -681,7 +492,7 @@ window.Religions = (function () {
if (religionsTree.find(x, y, spacing / 10) !== undefined) continue; // to close to other if (religionsTree.find(x, y, spacing / 10) !== undefined) continue; // to close to other
const culture = cells.culture[center]; const culture = cells.culture[center];
const name = getCultName('Heresy', center); const name = getCultName("Heresy", center);
const expansionism = gauss(1.2, 0.5, 0, 5); const expansionism = gauss(1.2, 0.5, 0, 5);
const color = getMixedColor(r.color, 0.4, 0.2); // "url(#hatch6)"; const color = getMixedColor(r.color, 0.4, 0.2); // "url(#hatch6)";
religions.push({ religions.push({
@ -695,11 +506,7 @@ window.Religions = (function () {
expansion: "global", expansion: "global",
expansionism, expansionism,
center, center,
<<<<<<< HEAD
origins: [r.i] origins: [r.i]
=======
origin: r.i
>>>>>>> c6917a14 (religion gen fix)
}); });
religionsTree.add([x, y]); religionsTree.add([x, y]);
} }
@ -708,7 +515,7 @@ window.Religions = (function () {
expandHeresies(); expandHeresies();
checkCenters(); checkCenters();
TIME && console.timeEnd('generateReligions'); TIME && console.timeEnd("generateReligions");
}; };
const add = function (center) { const add = function (center) {
@ -725,22 +532,19 @@ window.Religions = (function () {
type === "Heresy" ? religions[religionId].deity : form === "Non-theism" ? null : getDeityName(culture); type === "Heresy" ? religions[religionId].deity : form === "Non-theism" ? null : getDeityName(culture);
let name, expansion; let name, expansion;
if (type === 'Organized') [name, expansion] = getReligionName(form, deity, center); if (type === "Organized") [name, expansion] = getReligionName(form, deity, center);
else { else {
name = getCultName(form, center); name = getCultName(form, center);
expansion = 'global'; expansion = "global";
} }
const formName = type === "Heresy" ? religions[religionId].form : form; const formName = type === "Heresy" ? religions[religionId].form : form;
const code = abbreviate( const code = abbreviate(
name, name,
religions.map((r) => r.code) religions.map(r => r.code)
); );
<<<<<<< HEAD
const i = religions.length; const i = religions.length;
=======
>>>>>>> c6917a14 (religion gen fix)
religions.push({ religions.push({
i, i,
name, name,
@ -756,11 +560,7 @@ window.Religions = (function () {
area: 0, area: 0,
rural: 0, rural: 0,
urban: 0, urban: 0,
<<<<<<< HEAD
origins: [religionId], origins: [religionId],
=======
origin: r,
>>>>>>> c6917a14 (religion gen fix)
code code
}); });
cells.religion[center] = i; cells.religion[center] = i;
@ -774,8 +574,8 @@ window.Religions = (function () {
const cost = []; const cost = [];
religions religions
.filter((r) => r.type === 'Organized' || r.type === 'Cult') .filter(r => r.type === "Organized" || r.type === "Cult")
.forEach((r) => { .forEach(r => {
cells.religion[r.center] = r.i; cells.religion[r.center] = r.i;
queue.queue({e: r.center, p: 0, r: r.i, s: cells.state[r.center], c: r.culture}); queue.queue({e: r.center, p: 0, r: r.i, s: cells.state[r.center], c: r.culture});
cost[r.center] = 1; cost[r.center] = 1;
@ -794,12 +594,12 @@ window.Religions = (function () {
const expansion = religions[r].expansion; const expansion = religions[r].expansion;
cells.c[n].forEach(function (e) { cells.c[n].forEach(function (e) {
if (expansion === 'culture' && c !== cells.culture[e]) return; if (expansion === "culture" && c !== cells.culture[e]) return;
if (expansion === 'state' && s !== cells.state[e]) return; if (expansion === "state" && s !== cells.state[e]) return;
const cultureCost = c !== cells.culture[e] ? 10 : 0; const cultureCost = c !== cells.culture[e] ? 10 : 0;
const stateCost = s !== cells.state[e] ? 10 : 0; const stateCost = s !== cells.state[e] ? 10 : 0;
const biomeCost = biomesData.cost[cells.biome[e]]; const biomeCost = cells.road[e] ? 1 : biomesData.cost[cells.biome[e]];
const populationCost = Math.max(rn(popCost - cells.pop[e]), 0); const populationCost = Math.max(rn(popCost - cells.pop[e]), 0);
const heightCost = Math.max(cells.h[e], 20) - 20; const heightCost = Math.max(cells.h[e], 20) - 20;
const waterCost = cells.h[e] < 20 ? (cells.road[e] ? 50 : 1000) : 0; const waterCost = cells.h[e] < 20 ? (cells.road[e] ? 50 : 1000) : 0;
@ -825,8 +625,8 @@ window.Religions = (function () {
const cost = []; const cost = [];
religions religions
.filter((r) => r.type === 'Heresy') .filter(r => r.type === "Heresy")
.forEach((r) => { .forEach(r => {
const b = cells.religion[r.center]; // "base" religion id const b = cells.religion[r.center]; // "base" religion id
cells.religion[r.center] = r.i; // heresy id cells.religion[r.center] = r.i; // heresy id
queue.queue({e: r.center, p: 0, r: r.i, b}); queue.queue({e: r.center, p: 0, r: r.i, b});
@ -844,7 +644,7 @@ window.Religions = (function () {
cells.c[n].forEach(function (e) { cells.c[n].forEach(function (e) {
const religionCost = cells.religion[e] === b ? 0 : 2000; const religionCost = cells.religion[e] === b ? 0 : 2000;
const biomeCost = biomesData.cost[cells.biome[e]]; const biomeCost = cells.road[e] ? 0 : biomesData.cost[cells.biome[e]];
const heightCost = Math.max(cells.h[e], 20) - 20; const heightCost = Math.max(cells.h[e], 20) - 20;
const waterCost = cells.h[e] < 20 ? (cells.road[e] ? 50 : 1000) : 0; const waterCost = cells.h[e] < 20 ? (cells.road[e] ? 50 : 1000) : 0;
const totalCost = const totalCost =
@ -878,25 +678,25 @@ window.Religions = (function () {
} }
function updateCultures() { function updateCultures() {
TIME && console.time('updateCulturesForReligions'); TIME && console.time("updateCulturesForReligions");
pack.religions = pack.religions.map((religion, index) => { pack.religions = pack.religions.map((religion, index) => {
if (index === 0) { if (index === 0) {
return religion; return religion;
} }
return {...religion, culture: pack.cells.culture[religion.center]}; return {...religion, culture: pack.cells.culture[religion.center]};
}); });
TIME && console.timeEnd('updateCulturesForReligions'); TIME && console.timeEnd("updateCulturesForReligions");
} }
// get supreme deity name // get supreme deity name
const getDeityName = function (culture) { const getDeityName = function (culture) {
if (culture === undefined) { if (culture === undefined) {
ERROR && console.error('Please define a culture'); ERROR && console.error("Please define a culture");
return; return;
} }
const meaning = generateMeaning(); const meaning = generateMeaning();
const cultureName = Names.getCulture(culture, null, null, '', 0.8); const cultureName = Names.getCulture(culture, null, null, "", 0.8);
return cultureName + ', The ' + meaning; return cultureName + ", The " + meaning;
}; };
function generateMeaning() { function generateMeaning() {
@ -954,14 +754,14 @@ window.Religions = (function () {
return rw(types[form]); return rw(types[form]);
}; };
const random = function () { const random = function () {
return trimVowels(Names.getCulture(cells.culture[center], null, null, '', 0).split(/[ ,]+/)[0]); return trimVowels(Names.getCulture(cells.culture[center], null, null, "", 0).split(/[ ,]+/)[0]);
}; };
const burg = function () { const burg = function () {
return trimVowels(pack.burgs[cells.burg[center]].name.split(/[ ,]+/)[0]); return trimVowels(pack.burgs[cells.burg[center]].name.split(/[ ,]+/)[0]);
}; };
if (cells.burg[center]) return burg() + 'ian ' + type(); if (cells.burg[center]) return burg() + "ian " + type();
if (Math.random() > 0.5) return random() + 'ian ' + type(); if (Math.random() > 0.5) return random() + "ian " + type();
return type() + ' of the ' + generateMeaning(); return type() + " of the " + generateMeaning();
} }
return {generate, add, getDeityName, expandReligions, updateCultures}; return {generate, add, getDeityName, expandReligions, updateCultures};