mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
24 lines
605 B
JavaScript
24 lines
605 B
JavaScript
export const utility =
|
|
{
|
|
generateID() {
|
|
let code = "";
|
|
let charPool = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
for (let i = 0; i < 10; i++) {
|
|
code += charPool[this.getRandomInt(61)]
|
|
}
|
|
return code;
|
|
},
|
|
|
|
getRandomInt(max) {
|
|
return Math.floor(Math.random() * Math.floor(max));
|
|
},
|
|
|
|
shuffle(array) {
|
|
for (let i = array.length - 1; i > 0; i--) {
|
|
const j = Math.floor(Math.random() * (i + 1));
|
|
[array[i], array[j]] = [array[j], array[i]];
|
|
}
|
|
return array;
|
|
}
|
|
};
|