-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
58 lines (51 loc) · 1.34 KB
/
test.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
function restart(engine) {
console.log("===========================");
console.log("==== Restarting engine ====");
console.log("===========================");
engine.initGame();
engine.start();
}
function executeCommands(commands, engine, processCommand) {
for (let index = 0; index < commands.length; index++) {
console.log("==== Step " + (index + 1) + "/" + commands.length + " ====");
const command = commands[index];
if (engine.game.endState) {
return;
}
if (processCommand) {
processCommand(command);
} else {
engine.processCommand(command);
}
}
}
function assertTrue(condition, message) {
if (!condition) {
error("ERROR: " + message);
return true;
}
return false;
}
function assertFalse(condition, message) {
if (condition) {
error(message);
return true;
}
return false;
}
function info(text) {
message(text, "info");
}
function error(text) {
message(text, "error");
}
function success(text) {
message(text, "success");
}
function message(text, cssClass) {
const messages = document.querySelector("#game-tests");
const message = document.createElement("div");
message.className = cssClass;
message.textContent = text;
messages.appendChild(message);
}