-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHud.js
54 lines (42 loc) · 1.07 KB
/
Hud.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
class Hud {
constructor() {
this.scoreboards = [];
}
update() {
this.scoreboards.forEach(s => {
s.update(window.playerState.pizzas[s.id])
})
}
createElement() {
if (this.element) {
this.element.remove();
this.scoreboards = [];
}
this.element = document.createElement("div");
this.element.classList.add("Hud");
const {playerState} = window;
playerState.lineup.forEach(key => {
const pizza = playerState.pizzas[key];
const scoreboard = new Combatant({
id: key,
...Pizzas[pizza.pizzaId],
...pizza,
}, null)
scoreboard.createElement();
this.scoreboards.push(scoreboard);
this.element.appendChild(scoreboard.hudElement);
})
this.update();
}
init(container) {
this.createElement();
container.appendChild(this.element);
document.addEventListener("PlayerStateUpdated", () => {
this.update();
})
document.addEventListener("LineupChanged", () => {
this.createElement();
container.appendChild(this.element);
})
}
}