UNO card game web app (Node.js/React) with Miku bot integration. Previously an independent git repo (fork of mizanxali/uno-online). Removed .git/ and absorbed into main repo for unified tracking. Includes bot integration code: botActionExecutor, cardParser, gameStateBuilder, and server-side bot action support. 37 files, node_modules excluded via local .gitignore.
28 lines
691 B
JavaScript
28 lines
691 B
JavaScript
const users = []
|
|
|
|
const addUser = ({id, name, room}) => {
|
|
const numberOfUsersInRoom = users.filter(user => user.room === room).length
|
|
if(numberOfUsersInRoom === 2)
|
|
return { error: 'Room full' }
|
|
|
|
const newUser = { id, name, room }
|
|
users.push(newUser)
|
|
return { newUser }
|
|
}
|
|
|
|
const removeUser = id => {
|
|
const removeIndex = users.findIndex(user => user.id === id)
|
|
|
|
if(removeIndex!==-1)
|
|
return users.splice(removeIndex, 1)[0]
|
|
}
|
|
|
|
const getUser = id => {
|
|
return users.find(user => user.id === id)
|
|
}
|
|
|
|
const getUsersInRoom = room => {
|
|
return users.filter(user => user.room === room)
|
|
}
|
|
|
|
module.exports = { addUser, removeUser, getUser, getUsersInRoom } |