-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.html
143 lines (129 loc) · 4.04 KB
/
game.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html>
<head>
<meta type="http-equiv" content="charset: utf-8">
<meta name="author" content="Yaroslav Shestakov">
<title>Game</title>
<style type="text/css">
#field { margin-left: 30% ; margin-top: 2% ; }
#grid.rotate, #grid.rotate td div {
transform:rotate(180deg);
-ms-transform:rotate(180deg); /* IE 9 */
-moz-transform:rotate(180deg); /* Firefox */
-webkit-transform:rotate(180deg); /* Safari and Chrome */
-o-transform:rotate(180deg);
}
#grid { border-collapse: collapse ; table-layout: fixed ;}
#controls { float: left ; }
#controls div { position: relative ; margin-top: 10% ; }
#rules {}
#create { }
#stats { table-layout:fixed; word-wrap:break-word; width: 300px ;}
#stats *{ border: 1px black solid ; }
#stats td { width: 160px ;}
#stats td.loss { height: 200px ; font-size: 40px ; vertical-align: top ; background-color: gray ; word-wrap:break-word}
#stats td.loss.white { color: white ;}
#stats td.hasTurn { color: blue ; text-align: center ; height: 25px ;}
#stats td.timeline { text-align: center ; height: 50px ; }
#stats td.timeline textarea { width: 95% ; height: 95% ; rows: 5 ; }
#grid td.square {
width: 70px ;
height: 70px ;
border: 1px solid black ;
opacity: 1 ;
border-collapse: collapse ;
overflow-x: auto ;
}
#grid td.square.black { background-image: url('assets/black.jpg'); }
#grid td.square.white { background-image: url('assets/white.jpg'); }
#grid td.square.move { box-shadow: inset 0 0 3px 5px green; }
#grid td.square.attack { box-shadow: inset 0 0 3px 5px red; }
#grid td div.piece { overflow: hidden ; font-size: 40px ; text-align: center ; cursor: pointer }
#grid td div.piece.black { color: black ;}
#grid td div.piece.white { color: white ;}
#grid td div.piece.selected { font-size: 50px ; }
</style>
<script>
var game, player1, player2, basefield, statsfield ;
window.onload = function(){
function createGame(){
player1 = new Player($("#whiteName").val(), "white") ;
player2 = new Player($("#blackName").val(), "black") ;
basefield = document.getElementById("grid") ;
statsfield = document.getElementById("stats") ;
game = new Chess(player1, player2, basefield, statsfield) ;
$(document).keydown(function(e){
if (e.keyCode == '9'){
$(basefield).toggleClass("rotate") ;
e.preventDefault() ;
}
}) ;
}
document.getElementById("start").onclick = function(){
createGame() ;
} ;
createGame() ;
}
</script>
<script src="js/jQuery.js"></script>
<script src="js/classes.js"></script>
<script src="js/chess.js"></script>
</head>
<body>
<content>
<div id="controls">
<div id="rules">
<ul>
<li> Click "Start new game" </li>
<li> Select a piece to see its possible path </li>
<li> To destroy an enemy piece, click on its background</li>
<li> Press Tab to rotate the board </li>
<li> Author: <a href="https://github.com/YaroslavShestakov"> Yaroslav Shestakov </a></li>
</ul>
</div>
<div id="create">
<table>
<tbody>
<tr>
<td>Player 1 (White)</td><td>Player 2 (Black)</td>
</tr>
<tr>
<td>
<input id="whiteName" placeholder="Name" type="text"/>
</td>
<td>
<input id="blackName" placeholder="Name" type="text"/>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center"><button id="start"> Start new game </button></td>
</tr>
</tbody>
</table>
</div>
<div id="stats">
<table id="stats" >
<tbody>
<tr>
<th>White</th><th>Black</th>
</tr>
<tr>
<td class="loss white"></td><td class="loss black"></td>
</tr>
<tr>
<td class="hasTurn white"></td><td class="hasTurn black"></td>
</tr>
<tr>
<td class="timeline" colspan="2"><textarea readonly="readonly" class="timeline"></textarea></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="field">
<table id="grid">
</table>
</div>
</content>
</body>
</html>