-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.js
39 lines (33 loc) · 849 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
class Player {
constructor() {
this.index = null;
this.distance = 0;
this.name = null;
this.score =0;
}
getCount() {
var playerCountRef = database.ref('playerCount');
playerCountRef.on("value", (data) => {
playerCount = data.val();
})
}
updateCount(count) {
database.ref('/').update({
playerCount: count
});
}
update() {
var playerIndex = "players/player" + this.index;
database.ref(playerIndex).set({
name: this.name,
distance: this.distance,
score:this.score
});
}
static getPlayerInfo() {
var playerInfoRef = database.ref('players');
playerInfoRef.on("value", (data) => {
allPlayers = data.val();
})
}
}