forked from michaljaz/webmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInventoryBar.js
More file actions
58 lines (53 loc) · 1.55 KB
/
InventoryBar.js
File metadata and controls
58 lines (53 loc) · 1.55 KB
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
// Generated by CoffeeScript 2.5.1
var InventoryBar;
InventoryBar = class InventoryBar {
setHp(points) {
var i, j, k, l, lista, ref;
lista = {};
for (i = j = 1; j <= 10; i = ++j) {
lista[i - 1] = "empty";
$(".hp").eq(i - 1).removeClass("empty");
$(".hp").eq(i - 1).removeClass("full");
$(".hp").eq(i - 1).removeClass("half");
}
if (points !== 0) {
for (i = k = 1, ref = (points + points % 2) / 2; (1 <= ref ? k <= ref : k >= ref); i = 1 <= ref ? ++k : --k) {
lista[i - 1] = "full";
}
if (points % 2 === 1) {
lista[(points + points % 2) / 2 - 1] = "half";
}
}
for (i = l = 1; l <= 10; i = ++l) {
$(".hp").eq(i - 1).addClass(lista[i - 1]);
}
}
setFood(points) {
var i, j, k, l, lista, ref;
lista = {};
for (i = j = 1; j <= 10; i = ++j) {
lista[10 - i] = "empty";
$(".food").eq(10 - i).removeClass("empty");
$(".food").eq(10 - i).removeClass("full");
$(".food").eq(10 - i).removeClass("half");
}
if (points !== 0) {
for (i = k = 1, ref = (points + points % 2) / 2; (1 <= ref ? k <= ref : k >= ref); i = 1 <= ref ? ++k : --k) {
lista[10 - i] = "full";
}
if (points % 2 === 1) {
lista[10 - (points + points % 2) / 2] = "half";
}
}
for (i = l = 1; l <= 10; i = ++l) {
$(".food").eq(10 - i).addClass(lista[10 - i]);
}
}
setXp(level, progress) {
$(".player_xp").text(level);
return $(".xp_bar").css("width", `${500 * progress}px`);
}
};
export {
InventoryBar
};