Single_Player_Chess/template.html

88 lines
1.9 KiB
HTML

<html>
<head>
<style>
table {
text-align: center;
border-spacing: 0pt;
font-family: 'Arial Unicode MS';
border-collapse: collapse;
border-width: 0pt 0pt 0pt 0pt;
}
td {
width: 24pt;
height: 24pt;
border-collapse: collapse;
border-color: black;
border-style: solid;
border-width: 0pt 0pt 0pt 0pt
}
span {
font-size: 150%;
}
input[type="text"] {
width: 60px;
}
</style>
</head>
<body>
<div align="center">
<table>
<tbody>
% ranks = "87654321"
% #ranks = ranks if game.turn=="white" else ranks[::-1]
% files = "abcdefgh"
% is_black = lambda x: (ord(x[0])-ord('a')) % 2 != int(x[1]) % 2
% for i, rank in enumerate(ranks):
<tr>
<td style="width:12pt;">{{rank}}</td>
% for file in files:
% sq = file + rank
% color = 'bgcolor=silver' if is_black(sq) else ""
% widths = i==0, file=='h', i==7, file=='a'
% widths = "pt ".join(map(str, map(int, widths))) + "pt"
<td {{color}} style="border-width:{{widths}};"><span>{{game.board[sq]}}</span></td>
% end
</tr>
% end
<tr>
<td></td>
% for file in files:
<td>{{file}}</td>
% end
</tr>
</tbody>
</table>
<form method="post">
% first = "disabled" if game.index < 2 else ""
% prev = "disabled" if game.index == 0 else ""
% next = "disabled" if game.index+1 == len(game.history) else ""
% last = "disabled" if game.index+2 >= len(game.history) else ""
<input type="submit" name="first" value="{{"<<"}}" {{first}}>
<input type="submit" name="prev" value="{{"<"}}" {{prev}}>
<input type="submit" name="next" value="{{">"}}" {{next}}>
<input type="submit" name="last" value="{{">>"}}" {{last}}>
</form>
<form method="post">
% if not game.endofgame():
<input type="text" name="move">
<input type="submit" value="Move">
% else:
<input type="submit" name="newgame" value="New Game">
% end
</form>
</div>
</body>
</html>