typescript on both client and server with communication via socket.io

This commit is contained in:
Gavin McDonald
2025-04-09 11:28:35 -04:00
parent 9f2773f45d
commit 3c4b8cf56e
73 changed files with 1233 additions and 41 deletions

12
tools/getRandomItems.js Normal file
View File

@@ -0,0 +1,12 @@
export default function getRandomItems(items, count) {
const shuffled = [...items];
// Fisher-Yates shuffle
for (let i = shuffled.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
}
return count > shuffled.length ? shuffled : shuffled.slice(0, count);
}