This commit is contained in:
Canis Artorus 2023-03-01 22:29:09 -07:00
parent f018256f7a
commit 64764dcd78
3 changed files with 12 additions and 9 deletions

View file

@ -684,6 +684,7 @@ async function generate(options) {
const timeStart = performance.now(); const timeStart = performance.now();
const {seed: precreatedSeed, graph: precreatedGraph} = options || {}; const {seed: precreatedSeed, graph: precreatedGraph} = options || {};
pack = {};
invokeActiveZooming(); invokeActiveZooming();
setSeed(precreatedSeed); setSeed(precreatedSeed);
INFO && console.group("Generated Map " + seed); INFO && console.group("Generated Map " + seed);

View file

@ -118,21 +118,23 @@ window.Cultures = (function () {
function selectCultures(culturesNumber) { function selectCultures(culturesNumber) {
let def = getDefault(culturesNumber); let def = getDefault(culturesNumber);
if (culturesNumber === def.length) return def;
if (def.every(d => d.odd === 1)) return def.splice(0, culturesNumber);
const count = Math.min(culturesNumber, def.length);
const cultures = []; const cultures = [];
pack.cultures?.forEach(function (culture) { pack.cultures?.forEach(function (culture) {
if (culture.lock) cultures.push(culture); if (culture.lock) cultures.push(culture);
}); });
for (let culture, rnd, i = 0; cultures.length < count && i < 200; i++) { if (!cultures.length) {
if (culturesNumber === def.length) return def;
if (def.every(d => d.odd === 1)) return def.splice(0, culturesNumber);
}
for (let culture, rnd, i = 0; cultures.length < culturesNumber && def.length > 0;) {
do { do {
rnd = rand(def.length - 1); rnd = rand(def.length - 1);
culture = def[rnd]; culture = def[rnd];
} while (!P(culture.odd)); i++;
} while (i < 200 && !P(culture.odd));
cultures.push(culture); cultures.push(culture);
def.splice(rnd, 1); def.splice(rnd, 1);
} }

View file

@ -5,7 +5,7 @@ export function open() {
closeDialogs("#religionsEditor, .stable"); closeDialogs("#religionsEditor, .stable");
if (layerIsOn("toggleStates")) toggleStates(); if (layerIsOn("toggleStates")) toggleStates();
if (layerIsOn("toggleBiomes")) toggleBiomes(); if (layerIsOn("toggleBiomes")) toggleBiomes();
if (layerIsOn("toggleCultures")) toggleReligions(); if (layerIsOn("toggleCultures")) toggleCultures();
if (layerIsOn("toggleProvinces")) toggleProvinces(); if (layerIsOn("toggleProvinces")) toggleProvinces();
if (!layerIsOn("toggleReligions")) toggleReligions(); if (!layerIsOn("toggleReligions")) toggleReligions();
@ -213,7 +213,7 @@ function religionsEditorAddLines() {
<span data-tip="${populationTip}" class="icon-male hide"></span> <span data-tip="${populationTip}" class="icon-male hide"></span>
<div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div> <div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div>
<span <span
data-tip="Lock religion, will regenerate the origin folk and organized religion if they are not also locked" data-tip="Lock this religion"
class="icon-lock${r.lock ? "" : "-open"} hide" class="icon-lock${r.lock ? "" : "-open"} hide"
></span> ></span>
<span data-tip="Remove religion" class="icon-trash-empty hide"></span> <span data-tip="Remove religion" class="icon-trash-empty hide"></span>
@ -475,7 +475,7 @@ function drawReligionCenters() {
.attr("stroke", "#444444") .attr("stroke", "#444444")
.style("cursor", "move"); .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.removed);
religionCenters religionCenters
.selectAll("circle") .selectAll("circle")
.data(data) .data(data)