From 904951d6c05b833a540bbc8dba236341be80d7f5 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 23 Dec 2019 21:28:40 +0300 Subject: [PATCH] 1.22.32 --- modules/cultures-generator.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/cultures-generator.js b/modules/cultures-generator.js index c46bf78a..34209404 100644 --- a/modules/cultures-generator.js +++ b/modules/cultures-generator.js @@ -58,9 +58,9 @@ // the first culture with id 0 is for wildlands cultures.unshift({name:"Wildlands", i:0, base:1, origin:null}); - // check whether all bases are valid. If not, load default namesbase - const invalidBase = cultures.some(c => !nameBases[c.base]); - if (invalidBase) nameBases = Names.getNameBases(); + // make sure all bases exist in nameBases + if (!nameBases.length) {console.error("Name base is empty, default nameBases will be applied"); nameBases = Names.getNameBases();} + cultures.forEach(c => c.base = c.base % nameBases.length); function getRandomCultures(c) { const d = getDefault(c), n = d.length-1; @@ -70,7 +70,7 @@ let culture = d[rand(n)]; do { culture = d[rand(n)]; - } while (Math.random() > culture.odd || cultures.find(c => c.name === culture.name)) + } while (!P(culture.odd) || cultures.find(c => c.name === culture.name)) cultures.push(culture); } return cultures; @@ -306,7 +306,7 @@ if (culturesSet.value === "random") { return d3.range(count).map(i => { - const rnd = rand(41); + const rnd = rand(nameBases.length-1); return {name:Names.getBaseShort(rnd), base:rnd, odd: 1} }); }