-
Notifications
You must be signed in to change notification settings - Fork 9
/
player.js
63 lines (47 loc) · 1.07 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
function Player() {
this.players = [];
this.playersId = [];
this.new = function (player)
{
let id = this.count();
player["id"] = id;
this.playersId.push(id);
this.players.push(player);
return player;
}
this.count = function ()
{
return this.players.length;
}
this.get = function (id)
{
return this.players[id];
}
this.all = function ()
{
return this.players;
}
this.update = function (id, player)
{
this.players[id] = player;
}
this.exist = function (id)
{
return this.playersId.indexOf(id) > -1;
}
this.is_lock = function (id)
{
let player = this.get(id);
return player.lock >0;
}
this.opposition = function (id)
{
let player = this.get(id);
return this.get(player.opposition);
}
this.delete = function (id) {
this.players.splice(id, 1);
this.playersId.splice(id, 1);
}
}
module.exports = Player;