11 function set(x, y, n) {
12 sq = 'sq' + x + 'x' + y;
14 board[x][y] = document.getElementById(sq).innerHTML;
16 document.getElementById(sq).innerHTML = '<img src="sym/cyan.png">';
18 document.getElementById(sq).innerHTML = '<img src="sym/red.png">';
20 document.getElementById(sq).innerHTML = '';
21 else if(n == 4 || n == 20)
22 document.getElementById(sq).innerHTML = '<img src="sym/green.png">';
24 document.getElementById(sq).innerHTML = '<img src="sym/orange.png">';
26 document.getElementById(sq).innerHTML = '<img src="sym/BlackPawn.png">';
28 document.getElementById(sq).innerHTML = '<img src="sym/BlackRook.png">';
30 document.getElementById(sq).innerHTML = '<img src="sym/WhiteCrownedBishop.png">';
32 document.getElementById(sq).innerHTML = '<img src="sym/BlackKing.png">';
34 document.getElementById(sq).innerHTML = '<img src="sym/WhiteKing.png">';
36 document.getElementById(sq).innerHTML = '<img src="sym/yellow.png">';
38 document.getElementById(sq).innerHTML = board[x][y];
41 function text(s, t, n) {
42 if(t == '') t = ':<br>:<br>:';
44 document.getElementById('piece').innerHTML = s + '<br>' + t;
46 document.getElementById('piece').innerHTML = ':<br>:<br>:<br>:';
49 function slide(x, y, vx, vy, d, n) {
50 xx = x + vx; yy = y + vy; c = d;
51 if(vx > 1 || vx < -1 || vy > 1 || vy < -1) n = 5*n;
52 while(d-- > 0 && xx >= bw && xx < size - bw && yy >= 0 && yy < size) {
54 xx = xx + vx; yy = yy + vy;
55 if(c == 2 && n == 1) n = 5;
59 function slide_n(x, y, d, n) {
60 slide(x, y, 2, 1, d, n);
61 slide(x, y, 2,-1, d, n);
62 slide(x, y,-2, 1, d, n);
63 slide(x, y,-2,-1, d, n);
64 slide(x, y, 1, 2, d, n);
65 slide(x, y, 1,-2, d, n);
66 slide(x, y,-1, 2, d, n);
67 slide(x, y,-1,-2, d, n);
70 function slide_f(x, y, d, n) {
71 slide(x, y, 0, 1, d, n);
74 function slide_b(x, y, d, n) {
75 slide(x, y, 0, -1, d, n);
78 function slide_v(x, y, d, n) {
83 function slide_s(x, y, d, n) {
84 slide(x, y, 1, 0, d, n);
85 slide(x, y,-1, 0, d, n);
88 function slide_fd(x, y, d, n) {
89 slide(x, y, 1, 1, d, n);
90 slide(x, y,-1, 1, d, n);
93 function slide_bd(x, y, d, n) {
94 slide(x, y, 1, -1, d, n);
95 slide(x, y,-1, -1, d, n);
98 function slide_diag(x, y, d, n) {
100 slide_bd(x, y, d, n);
103 function slide_orth(x, y, d, n) {
108 function highlight(x, y, m, n) {
110 } else if(x == 1 && y == 9) { // castle
111 slide(x, y, 0, 0, 1, 10*n);
112 slide(x, y, 2, 0, 1, 10*n);
113 slide(x, y, 3, 0, 1, 3*n);
114 slide(x, y, 4, 0, 1, 2*n);
115 text('Castling', ': <i>King and corner piece swing around each other</i><br>:<br>:', n);
116 } else if(x == 8 && y == 9) { // castle
117 slide(x, y, 0, 0, 1, 10*n);
118 slide(x, y,-1, 0, 1, 50*n);
119 slide(x, y,-2, 0, 1, 3*n);
120 slide(x, y,-3, 0, 1, 2*n);
121 text('Castling', ': <i>King and corner piece swing around each other</i><br>:<br>:', n);
122 } else if(x == 5 && y == 9) { // castle
123 slide(x, y, 2, 0, 1, 4*n);
124 slide(x, y,-2, 0, 1, 4*n);
125 text('Castling', ': <i>Click on a corner piece to see how</i><br>:<br>:', n);
126 } else if(x == 1 && y == 0) { // castle
127 slide(x, y, 0, 0, 1, 10*n);
128 slide(x, y, 1, 0, 1, 60*n);
129 slide(x, y, 2, 0, 1, 6*n);
130 slide(x, y, 4, 0, 1, 2*n);
131 text('Castling', ': <i>King and corner piece swing around each other</i><br>' +
132 ': <b>King goes to b1, to keep its partner on same color!</b><br>:', n);
133 } else if(x == 8 && y == 0) { // castle
134 slide(x, y, 0, 0, 1, 10*n);
135 slide(x, y,-1, 0, 1, 60*n);
136 slide(x, y,-2, 0, 1, 6*n);
137 slide(x, y,-3, 0, 1, 2*n);
138 text('Castling', ': <i>King and corner piece swing around each other</i><br>:<br>:', n);
139 } else if(x == 5 && y == 0) { // castle
140 slide(x, y, 2, 0, 1, 4*n);
141 slide(x, y,-3, 0, 1, 4*n);
142 text('Castling <b>with color-bound corner piece</b>', ': <i>Click on a corner piece to see how</i><br>:<br>:', n);
143 } else if(x == 1 && y == 3) { // FL
144 slide(x, y, 1, 0, 1, 10*n);
145 slide(x, y, 1,-1, 1, 11*n);
146 slide(x, y, 0, 0, 1, 10*n);
147 text('en-passant capture', ': <i>A Pawn that just made a double-push past you</i><br>: <i>is caught by its tail</i><br>:', n);
148 } else if(x == 2 && y == 1) { // FL
149 slide_fd(x, y, 1, 3*n);
150 slide_f(x, y, 2, 4*n);
151 if(m == 2) text('Pawn', ': <i>Different capture (red) and non-capture (green)</i><br>' +
152 ': <i>Initial double-push non-capture can be blocked</i><br>' +
153 ': <i>The black Pawn can e.p. capture to the skipped square', n);
154 else text('Pawn', ': <i>Different capture (red) and non-capture (green)</i><br>:<br>:', n);
155 } else if(x == 2 && y == 3) { // FL
156 slide_fd(x, y, 1, 3*n);
157 slide_f(x, y, 1, 4*n);
158 text('Pawn', ': <i>Different capture (red) and non-capture (green)</i><br>:<br>:', n);
159 } else if(x == 3 && y == 6) { // FL
160 slide_orth(x, y, size, n);
162 } else if(x == 3 && y == 5) { // +V
163 slide_orth(x, y, 4, n);
164 text('Short Rook', ': <i>Slides upto 4 squares</i><br>:<br>:', n);
165 } else if(x == 3 && y == 4) { // +H
166 slide_orth(x, y, 1, n);
167 slide(x, y, 2, 2, 1, n);
168 slide(x, y,-2, 2, 1, n);
169 slide(x, y, 2,-2, 1, n);
170 slide(x, y,-2,-2, 1, n);
171 text('Elephant', '', n);
172 } else if(x == 3 && y == 3) { // fibnif
173 slide_diag(x, y, 1, n);
174 slide(x, y, 1, 2, 1, n);
175 slide(x, y,-1, 2, 1, n);
176 slide(x, y, 1,-2, 1, n);
177 slide(x, y,-1,-2, 1, n);
178 text('Horse', '', n);
179 } else if(x == 4 && y == 6) { // +A
181 text('Knight', '', n);
182 } else if(x == 4 && y == 5) { // +D
183 slide_diag(x, y, 1, n);
184 slide(x, y, 2, 0, 1, n);
185 slide(x, y,-2, 0, 1, n);
186 slide(x, y, 0,-2, 1, n);
187 slide(x, y, 0, 2, 1, n);
188 slide(x, y, 3, 0, 1, n);
189 slide(x, y,-3, 0, 1, n);
190 slide(x, y, 0,-3, 1, n);
191 slide(x, y, 0, 3, 1, n);
192 text('Half-Duck', '', n);
193 } else if(x == 4 && y == 4) { // Lion
194 slide_diag(x, y, size, n);
195 slide(x, y, 2, 0, 1, n);
196 slide(x, y,-2, 0, 1, n);
197 slide(x, y, 0,-2, 1, n);
198 slide(x, y, 0, 2, 1, n);
199 text('Leaping Bishop', ': <i>Color bound</i><br>:<br>:', n);
200 } else if(x == 4 && y == 3) { // +L
201 slide(x, y, 1, 2, 1, n);
202 slide(x, y,-1, 2, 1, n);
203 slide(x, y, 2, 1, 1, n);
204 slide(x, y,-2, 1, 1, n);
207 slide_bd(x, y, 1, n);
208 text('Unicorn', '', n);
209 } else if(x == 5 && y == 6) { // +A
210 slide_orth(x, y, size, n);
211 slide_diag(x, y, size, n);
212 text('Queen', '', n);
213 } else if(x == 5 && y == 5) { // +H
214 slide_orth(x, y, size, n);
216 text('Marshall', '', n);
217 } else if(x == 5 && y == 4) { // Q
218 slide_diag(x, y, size, n);
220 text('Archbishop', '', n);
221 } else if(x == 5 && y == 3) {
222 slide(x, y, 1, 2, 1, n);
223 slide(x, y,-1, 2, 1, n);
224 slide(x, y, 2, 1, 1, n);
225 slide(x, y,-2, 1, 1, n);
226 slide_diag(x, y, 1, n);
227 slide_f(x, y, size, n);
228 slide_s(x, y, size, n);
230 text('Colonel', '', n);
231 } else if(x == 6 && y == 6) { // B
232 slide_diag(x, y, size, n);
233 text('Bishop', '', n);
234 } else if(x == 6 && y == 5) { // dragon
235 slide_orth(x, y, 2, n);
236 text('Woody', '', n);
237 } else if(x == 6 && y == 4) { // horse
238 slide(x, y, 2, 0, 1, n);
239 slide(x, y,-2, 0, 1, n);
240 slide(x, y, 0,-2, 1, n);
241 slide(x, y, 0, 2, 1, n);
242 slide_diag(x, y, 2, n);
243 text('Clobberer', ': <i>Color bound</i><br>:<br>:', n);
244 } else if(x == 6 && y == 3) { // Ph
246 slide_bd(x, y, 1, n);
247 slide_f(x, y, size, n);
248 slide_s(x, y, size, n);
249 text('Turret', '', n);
250 } else if(x == 7 && y == 6) { // Ph
251 slide_diag(x, y, 1, n);
252 slide_orth(x, y, 1, n);
257 function down_click(x, y) {
261 for(i=0; i<12; i = i + 1) board[i] = new Array();
262 if(document.getElementById('sq0x0').innerHTML[1] == ' ') bw = 1;
269 x = -x; msg = msg + 2;
271 highlight(x, y, msg, 1);
272 savx = x; savy = y; down = 1;
273 // save = document.getElementById(sq).innerHTML;
274 // document.getElementById(sq).innerHTML = '<img src="sym/yellow.png">';
277 function up_click() {
278 highlight(savx, savy, msg, 0);
280 // document.getElementById('sq' + x + 'x' + y).innerHTML = save;