-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
48 lines (45 loc) · 1.8 KB
/
index.html
File metadata and controls
48 lines (45 loc) · 1.8 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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>TEST</title>
<script src="CodeBattleJsLibrary.js"></script>
</head>
<body id="body">
<textarea id="text" readonly=true style="display: block; width: 100%; height: 100%; resize: none;"></textarea>
<script type="text/javascript">
var isBlock = function(block)
{
var result = false;
result =
block == BombermanBlocks.Wall ||
block == BombermanBlocks.WallDestroyable ||
block == BombermanBlocks.MeatChopper ||
block == BombermanBlocks.BombTimer1 ||
block == BombermanBlocks.BombTimer2 ||
block == BombermanBlocks.BombTimer3 ||
block == BombermanBlocks.BombTimer4 ||
block == BombermanBlocks.BombTimer5 ||
block == BombermanBlocks.OtherBomberman ||
block == BombermanBlocks.OtherBombBomberman;
return result;
};
var gcb = new GameClient("localhost:8080", "e@mail.org", "00000000000000000000")
gcb.textArea = text
gcb.run(function()
{
var done = false;
switch (Math.round(Math.random() * 5 - 0.5))
{
case 0: if (isBlock(gcb.map[gcb.playerY - 1][gcb.playerX]) == false) { gcb.up(BombAction.BeforeTurn); done = true; } break;
case 1: if (isBlock(gcb.map[gcb.playerY][gcb.playerX + 1]) == false) { gcb.right(BombAction.BeforeTurn); done = true; } break;
case 2: if (isBlock(gcb.map[gcb.playerY + 1][gcb.playerX]) == false) { gcb.down(BombAction.BeforeTurn); done = true; } break;
case 3: if (isBlock(gcb.map[gcb.playerY][gcb.playerX - 1]) == false) { gcb.left(BombAction.BeforeTurn); done = true; } break;
case 4: gcb.act(); done = true; break;
}
if (done == false)
gcb.blank();
}
);
</script>
</body>
</html>