X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=utils%2Falea.js;h=751d3474b42a5fd6bebaefddb0fbf49d8a719e98;hp=aa3aa57cec2bce2fab1b910e845f9402b245c0b1;hb=3b641716d7e86d9f1b39d1e046ce197e6b5a8075;hpb=24872b22ca84fc01cc1d47247580e4e8280fff1e diff --git a/utils/alea.js b/utils/alea.js index aa3aa57..751d347 100644 --- a/utils/alea.js +++ b/utils/alea.js @@ -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) {