add: absorb uno-online as regular subdirectory
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.
This commit is contained in:
28
uno-online/users.js
Normal file
28
uno-online/users.js
Normal file
@@ -0,0 +1,28 @@
|
||||
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 }
|
||||
Reference in New Issue
Block a user