-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.js
50 lines (40 loc) · 853 Bytes
/
player.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
48
49
50
function Player(number) {
this.id = null;
this.number = number;
this.readyToStartGame = false;
}
Player.prototype.getID = function() {
return this.id;
};
Player.prototype.getNumber = function() {
return this.number;
};
Player.prototype.assignID = function(playerID) {
this.id = playerID;
this.readyToStartGame = true;
};
Player.prototype.isMe = function(playerID) {
if (this.id === playerID) {
return true;
} else {
return false;
}
};
Player.prototype.clear = function() {
this.id = null;
this.readyToStartGame = false;
};
Player.prototype.isInUse = function() {
if (this.id) {
return true;
} else {
return false;
}
};
Player.prototype.setReadyToStartGame = function(ready) {
this.readyToStartGame = ready;
};
Player.prototype.isReadyToStartGame = function() {
return this.readyToStartGame;
};
module.exports = Player;