-
Notifications
You must be signed in to change notification settings - Fork 0
/
CraftingMenu.js
47 lines (42 loc) · 1.25 KB
/
CraftingMenu.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
class CraftingMenu {
constructor({pizzas, onComplete}) {
this.pizzas = pizzas
this.onComplete = onComplete
}
getOptions() {
return this.pizzas.map(id => {
const base = Pizzas[id]
return {
label: base.name,
description: base.description,
handler: () => {
//Create a way to add a pizza to PlayerState
playerState.addPizza(id)
this.close()
}
}
})
}
createElement() {
this.element = document.createElement("div")
this.element.classList.add("CraftingMenu")
this.element.classList.add("overlayMenu")
this.element.innerHTML = (`
<h2>Create Pizza</h2>
`)
}
close() {
this.keyboardMenu.end()
this.element.remove()
this.onComplete()
}
init(container) {
this.createElement()
this.keyboardMenu = new KeyboardMenu({
descriptionContainer: container
})
this.keyboardMenu.init(this.element)
this.keyboardMenu.setOptions(this.getOptions())
container.appendChild(this.element)
}
}