X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=utils%2Falea.js;h=077970df5df333a432e65ae189cf18b423d729e4;hb=f3824309fa7dffd121ebb859088362997cabe9c3;hp=aa3aa57cec2bce2fab1b910e845f9402b245c0b1;hpb=bc2bc396ec4df092f218b58a0fbf08ba7eb8ca6e;p=xogo.git diff --git a/utils/alea.js b/utils/alea.js index aa3aa57..077970d 100644 --- a/utils/alea.js +++ b/utils/alea.js @@ -22,7 +22,7 @@ export const Random = { min = 0; } if (!Random.rand) - Random.setSeed(Math.floor(Math.random() * 1984)); + Random.setSeed(Math.floor(Math.random() * 19840)); return Math.floor(Random.rand() * (max - min)) + min; }, @@ -34,7 +34,8 @@ export const Random = { const rand = Random.randInt(index, arr.length); [ cpArr[index], cpArr[rand] ] = [ cpArr[rand], cpArr[index] ]; } - return cpArr.slice(0, n); + const res = cpArr.slice(0, n); + return (n >= 2 ? res : res[0]); }, shuffle: function(arr) {