-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathstatus.js
66 lines (58 loc) · 2.21 KB
/
status.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
var status2 = {
getText : function(){
var statusLines = [];
var character = this.getLinesFromThingIndex(quest.getCharacterIndex());
if(quest.getCharacterIndex() + 1 < quest.things.length && quest.things[quest.getCharacterIndex() + 1].type != "none"){
statusLines.push(this.formatLines(character));
if(quest.things[quest.getCharacterIndex() + 1].type == "mob") // If it's a mob
statusLines.push(this.formatLines(["", "VERSUS", "", ""]));
if(quest.things[quest.getCharacterIndex() + 1].type == "ally") // If it's an ally
statusLines.push(this.formatLines(["", " WITH ", "", ""]));
statusLines.push(this.getLinesFromThingIndex(quest.getCharacterIndex() + 1));
}
else{
statusLines.push(character);
}
return this.formatStatusLines(statusLines);
},
formatLines : function(lines){
var max_len = 0;
for(var i = 0; i < lines.length; i++){
if(lines[i].length > max_len) max_len = lines[i].length;
}
for(var i = 0; i < lines.length; i++){
if(lines[i].length < max_len){
for(var j = lines[i].length; j < max_len; j++){
lines[i] += " ";
}
}
lines[i] += " | ";
}
return lines;
},
formatStatusLines : function(lines){
var text = "";
var stop = false;
var i = 0;
while(stop == false){
stop = true;
text += "\n";
for(var j = 0; j < lines.length; j++){
if(lines[j].length > i){
text += lines[j][i];
stop = false; // While we have something to add, we continue
}
}
i++;
}
return text;
},
getLinesFromThingIndex : function(i){
var lines = [];
lines.push(" " + quest.things[i].text);
lines.push("HP : " + quest.things[i].hp + "/" + quest.things[i].max_hp);
lines.push("Weapon : " + quest.things[i].weapon);
lines.push("\"" + quest.things[i].description + "\"");
return lines;
}
};