diff --git a/src/js/generateMarketSlave.js b/src/js/generateMarketSlave.js index a311d8a78f0b227a5b7c57c35ee3a3c71d3af84a..80c810fa5db973d028161b8285442fd5183e892a 100644 --- a/src/js/generateMarketSlave.js +++ b/src/js/generateMarketSlave.js @@ -73,8 +73,7 @@ window.generateMarketSlave = function(market = "kidnappers", numArcology = 1) { if (V.corpSpecRaces.length === 12) { r += `There is no racial element to trainee selection. `; } else if (V.corpSpecRaces.length === 1) { - const corpSpecRace = jsEither(V.corpSpecRaces); - r += `The corporation specializes in ${corpSpecRace} slaves. `; + r += `The corporation specializes in ${V.corpSpecRaces[0]} slaves. `; } else { r += `The corporation selects slaves based on race. `/*getting into the specifics of which races exactly is a hellhole I'd rather not jump into*/ ; } diff --git a/src/js/utilJS.js b/src/js/utilJS.js index 69e26e93bdc1f36a5b6c7cafeef927bfb5a0f116..5968ba64cc1187d9a81e759d26d7e941fff06750 100644 --- a/src/js/utilJS.js +++ b/src/js/utilJS.js @@ -1148,10 +1148,14 @@ window.jsRandomMany = function(arr, count) { return result; }; -// This function wants an array - which explains why it works like array.random(). Give it one or you'll face a NaN -window.jsEither = function(choices) { - let index = Math.floor(Math.random() * choices.length); - return choices[index]; +// accepts both an array and a list, returns undefined if nothing is passed. +window.jsEither = function(choices, ...otherChoices) { + if (otherChoices.length === 0 && Array.isArray(choices)) { + return choices[Math.floor(Math.random() * choices.length)]; + } + const allChoices = otherChoices; + allChoices.push(choices); + return allChoices[Math.floor(Math.random() * allChoices.length)]; }; /*