-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.js
40 lines (37 loc) · 991 Bytes
/
log.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
/*
* The message log displays battle messages and the like.
*/
var Log = {
display_height:10, // How many messages to show in the log at once.
messages:[],
mostrecentlogs:[]
}
Log.draw = function() {
var str = "<div class=\"log\">"
for (var i = Log.messages.length - (Log.display_height + 1); i < Log.messages.length; i++) {
var last = i === Log.messages.length - 1;
if (last) {
str += "<span class=\"mostrecentlog\">";
this.mostrecentlogs[i] = true;
} else if (this.mostrecentlogs[i] === true) {
str += "<span class=\"exmostrecentlog\">";
} else {
str += "<span class=\"regularlog\">";
}
if (i < 0) {
str += "<br>";
} else {
if (typeof Log.messages[i] === "function") {
str += Log.messages[i]() + "<br>";
} else {
str += MessageStrings.get(Log.messages[i]) + "<br>";
}
}
str += "</span>";
}
document.getElementById("log").innerHTML = str;
}
Log.add = function(msg) {
Log.messages.push(msg);
Log.mostrecentlogs.push(false);
}