-
Notifications
You must be signed in to change notification settings - Fork 229
/
room.js
47 lines (41 loc) · 972 Bytes
/
room.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
44
45
46
47
function Room(name, id, owner) {
this.name = name;
this.id = id;
this.owner = owner;
this.people = [];
this.peopleLimit = 4;
this.status = "available";
this.private = false;
};
Room.prototype.addPerson = function(personID) {
if (this.status === "available") {
this.people.push(personID);
}
};
Room.prototype.removePerson = function(person) {
var personIndex = -1;
for(var i = 0; i < this.people.length; i++){
if(this.people[i].id === person.id){
personIndex = i;
break;
}
}
this.people.remove(personIndex);
};
Room.prototype.getPerson = function(personID) {
var person = null;
for(var i = 0; i < this.people.length; i++) {
if(this.people[i].id == personID) {
person = this.people[i];
break;
}
}
return person;
};
Room.prototype.isAvailable = function() {
return this.available === "available";
};
Room.prototype.isPrivate = function() {
return this.private;
};
module.exports = Room;