-
Notifications
You must be signed in to change notification settings - Fork 0
/
turnmenu.js
126 lines (112 loc) · 2.31 KB
/
turnmenu.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
function TurnMenu(){
if(!window.TurnMenuObject){
window.TurnMenuObject={
options:[
/**
* TO THE CURIOUS:
* The cooldown value here does not actually do anything other than display next to the menu option!
* This was one of the very absolute last things added to the code to help users understand why the item is disabled after use
*/
{
title:'Jump',
points:1,
cooldown:0,
enabled:true
},
{
title:'Hit',
points:1.5,
cooldown:1,
enabled:true
},
{
title:'Psychic',
points:0,
cooldown:0,
enabled:true
}
],
optionID:0,
update:function(){
if(F()){
this.options[2].enabled=!F().psychic;
}
if(I().pressed('ArrowDown')){
this.optionID++;
So().txt.play();
}
if(I().pressed('ArrowUp')){
this.optionID--;
So().txt.play();
}
if(this.optionID < 0){
this.optionID=this.options.length-1;
}
if(this.optionID >= this.options.length){
this.optionID=0;
}
if(I().pressed(' ') && this.options[this.optionID].enabled){
if(this.optionID == 1){
this.options[this.optionID].enabled=false;
}else{
this.options[1].enabled=true;
}
F().playerMove=this.optionID;
this.optionID=0;
So().txt.play();
}
},
draw:function(){
D().fillText(
"Choose Your Move:",
32 * S().zoom,
8 * S().zoom
);
for(let i in this.options){
let option=this.options[i];
let drawColor='#FFF';
if(i == this.optionID){
if(option.enabled){
drawColor='#F00';
}else{
drawColor='#900';
}
}else{
if(!option.enabled){
drawColor='#999';
}
}
D().fillStyle=drawColor;
D().fillText(
(
option.title
+
' ('
+
(
TurnMenu().options[i].points
+
Math.round(
TurnMenu().options[i].points
*
(P().level / 4)
)
)
+
' AP'
+
(option.cooldown ? '; ' + option.cooldown + ' cooldown' : '')
+
')'
+
(!option.enabled ? ' [can\'t]' : '')
),
32 * S().zoom,
(16 + (8 * i)) * S().zoom
);
}
}
};
}
return window.TurnMenuObject;
}