-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hud.js
49 lines (43 loc) · 1.29 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
class Hud {
constructor() {
this.scoreboards = []
}
update() {
this.scoreboards.forEach(s => {
//update me!
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("LineUpChange", () => {
this.createElement()
container.appendChild(this.element)
})
}
}