X-Git-Url: https://git.auder.net/rpsls.js?a=blobdiff_plain;f=utils%2Falea.js;h=751d3474b42a5fd6bebaefddb0fbf49d8a719e98;hb=98d144512e5505f5ef8b702b139ca6ceff92c823;hp=aa3aa57cec2bce2fab1b910e845f9402b245c0b1;hpb=bc2bc396ec4df092f218b58a0fbf08ba7eb8ca6e;p=xogo.git 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) {