-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLobby.js
43 lines (36 loc) · 1000 Bytes
/
Lobby.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Lobby {
constructor(id, users, questions) {
this.id = id;
this.users = users;
this.questions = questions;
this.currentQuestion = 0;
setTimeout(() => {
//announce to users game is starting
this.startGame();
}, 30000)
}
addUser(user) {
this.users.push(user);
// send info to other users
}
removeUser(name) {
for (let i = 0 ; i < this.users.length; i++) {
if (this.users[i].getName() === name) {
this.users.splice(i, 1);
return;
}
}
// send info to other users
}
startGame() {
while (this.users.length !== 0 && this.currentQuestion < this.users.length) {
setInterval(() => {
nextQuestion();
this.currentQuestion++;
}, 30000)
}
this.endGame();
}
endGame() {
}
}