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 == 8 || 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/BlackRook.png">';
27 else if(n == 9 || n == 45)
28 document.getElementById(sq).innerHTML = '<img src="sym/BlackKing.png">';
30 document.getElementById(sq).innerHTML = '<img src="sym/yellow.png">';
32 document.getElementById(sq).innerHTML = board[x][y];
35 function text(s, t, n) {
36 if(t == '') t = ':<br>:<br>:';
38 document.getElementById('piece').innerHTML = s + '<br>' + t;
40 document.getElementById('piece').innerHTML = ':<br>:<br>:<br>:';
43 function slide(x, y, vx, vy, d, n) {
44 xx = x + vx; yy = y + vy;
45 if(vx > 1 || vx < -1 || vy > 1 || vy < -1) n = 5*n;
48 xx = xx + vx; yy = yy + vy; d--; n = 5*n;
50 while(d-- > 0 && xx >= bw && xx < size - bw && yy >= 0 && yy < size) {
52 xx = xx + vx; yy = yy + vy;
56 function slide_n(x, y, d, n) {
57 slide(x, y, 2, 1, d, n);
58 slide(x, y, 2,-1, d, n);
59 slide(x, y,-2, 1, d, n);
60 slide(x, y,-2,-1, d, n);
61 slide(x, y, 1, 2, d, n);
62 slide(x, y, 1,-2, d, n);
63 slide(x, y,-1, 2, d, n);
64 slide(x, y,-1,-2, d, n);
67 function slide_f(x, y, d, n) {
68 slide(x, y, 0, 1, d, n);
71 function slide_b(x, y, d, n) {
72 slide(x, y, 0, -1, d, n);
75 function slide_v(x, y, d, n) {
80 function slide_s(x, y, d, n) {
81 slide(x, y, 1, 0, d, n);
82 slide(x, y,-1, 0, d, n);
85 function slide_fd(x, y, d, n) {
86 slide(x, y, 1, 1, d, n);
87 slide(x, y,-1, 1, d, n);
90 function slide_bd(x, y, d, n) {
91 slide(x, y, 1, -1, d, n);
92 slide(x, y,-1, -1, d, n);
95 function slide_diag(x, y, d, n) {
100 function slide_orth(x, y, d, n) {
105 function highlight(x, y, m, n) {
107 } else if(x > 7 && y == 9) { // castle
108 slide(x, y,-1-m, 0, 1, 9*n);
109 slide(x, y, 0, 0, 1, 10*n);
110 slide(x, y,-2-m, 0, 1, 3*n);
111 slide(x, y,5-m-x, 0, 1, 2*n);
112 text('Castling', ': <i>The King and Rook swing around each other</i><br>:<br>:', n);
113 } else if(x < 2 && y == 9) { // castle
114 slide(x, y, 2-m, 0, 1, 9*n);
115 slide(x, y, 0, 0, 1, 10*n);
116 slide(x, y, 3-m, 0, 1, 3*n);
117 slide(x, y, 5-m-x, 0, 1, 2*n);
118 text('Castling', ': <i>The King and Rook swing around each other</i><br>:<br>:', n);
119 } else if((x == 4 || x == 5) && y == 9) { // castle
120 slide(x, y, 2+m, 0, 1, 4*n);
121 slide(x, y,-2-m, 0, 1, 4*n);
122 text('Castling', ': <i>Click on Rook to see how</i><br>:<br>:', n);
123 } else if(x == 2 && y == 1) { // FL
124 slide_fd(x, y, 1, 3*n);
125 slide_f(x, y, 2, 4*n);
126 text('Pawn', ': <i>Different capture (red) and non-capture (green)</i><br>' +
127 ': <i>Initial double-push non-capture can be blocked</i><br>' +
128 ': <i>The black Pawn can e.p. capture to the skipped square', n);
129 } else if(x == 7 && y == 2) { // FL
130 slide_fd(x, y, 1, 3*n);
131 slide_f(x, y, 1, 4*n);
132 text('Pawn', ': <i>Different capture (red) and non-capture (green)</i><br>:<br>:', n);
133 } else if(x == 2 && y == 5) { // V
134 slide_v(x, y, size, n);
136 text('Vertical Mover', '', n);
137 } else if(x == 2 && y == 4) { // H
138 slide_s(x, y, size, n);
140 text('Side Mover', '', n);
141 } else if(x == 2 && y == 3) { // I
143 text('Cobra (aka Go Between)', '', n);
144 } else if(x == 3 && y == 7) { // G
145 slide_orth(x, y, 1, n);
146 slide_fd(x, y, 1, n);
147 text('Gold General', '', n);
148 } else if(x == 3 && y == 6) { // FL
149 slide_diag(x, y, 1, n);
151 text('Ferocious Leopard', '', n);
152 } else if(x == 3 && y == 5) { // +V
153 slide_diag(x, y, size, n);
154 slide_v(x, y, size, n);
155 text('Narrow Queen (aka Flying Ox)', '', n);
156 } else if(x == 3 && y == 4) { // +H
157 slide_diag(x, y, size, n);
158 slide_s(x, y, size, n);
159 text('Sleeping Queen (aka Free Boar)', '', n);
160 } else if(x == 3 && y == 3) { // Ky
161 slide_diag(x, y, 1, n);
162 slide(x, y, 2, 0, 1, n);
163 slide(x, y,-2, 0, 1, n);
164 slide(x, y, 0,-2, 1, n);
165 slide(x, y, 0, 2, 1, n);
166 text('Kylin', '', n);
167 } else if(x == 3 && y == 2) { // Ky
168 slide(x, y, 1, 2, 1, n);
169 slide(x, y,-1, 2, 1, n);
170 text('(Shogi) Knight', '', n);
171 } else if(x == 4 && y == 7) { // S
172 slide_diag(x, y, 1, n);
174 text('Silver General', '', n);
175 } else if(x == 4 && y == 6) { // +A
176 slide_v(x, y, size, n);
177 slide_bd(x, y, size, n);
178 text('Whale', '', n);
179 } else if(x == 4 && y == 5) { // +D
180 slide_orth(x, y, size, n);
181 slide_bd(x, y, size, n);
182 slide_fd(x, y, 2, n);
183 text('Soaring Eagle',
184 '<i>: Can shoot or capture en-passant what is on the cyan<br>' +
185 ': square with the first of its two steps along the forward<br>' +
186 ': diagonal, or jump directly to cyan or orange squares</i>', n);
187 } else if(x == 4 && y == 4) { // Lion
188 slide_diag(x, y, 2, n);
189 slide_orth(x, y, 2, n);
191 text('Lion', '<i>: Can shoot or capture en-passant what is on the<br>' +
192 ': cyan squares with the first of its two King steps,<br>' +
193 ': or jump directly to any of the colored squares</i>', n);
194 } else if(x == 4 && y == 3) { // +L
197 text('Knight', '', n);
199 slide_v(x, y, size, n);
200 slide_fd(x, y, size, n);
201 text('White Horse', '', n);
203 } else if(x == 4 && y == 2) { // L
204 slide_f(x, y, size, n);
205 text('Lance', '', n);
206 } else if(x == 5 && y == 7) { // C
207 slide_fd(x, y, 1, n);
209 text('Copper General', '', n);
210 } else if(x == 5 && y == 6) { // +A
211 slide_v(x, y, size, n);
212 text('Canon (aka Reverse Chariot)', '', n);
213 } else if(x == 5 && y == 5) { // +H
214 slide_diag(x, y, size, n);
215 slide_s(x, y, size, n);
216 slide_b(x, y, size, n);
218 text('Unicorn (aka Horned Falcon)',
219 '<i>: Can shoot or capture en-passant what is on the cyan<br>' +
220 ': square with the first of its two forward/backward<br>' +
221 ': steps, or jump directly to cyan or orange square</i>', n);
222 } else if(x == 5 && y == 4) { // Q
223 slide_diag(x, y, size, n);
224 slide_orth(x, y, size, n);
225 text('Queen', '', n);
226 } else if(x == 5 && y == 3) { // +BT
227 slide_v(x, y, size, n);
229 slide_diag(x, y, 1, n);
230 text('Flying Stag', '', n);
231 } else if(x == 5 && y == 2) { // BT
232 slide_diag(x, y, 1, n);
235 text('Blind Tiger', '', n);
236 } else if(x == 6 && y == 7) { // Commoner
237 slide_diag(x, y, 1, n);
238 slide_orth(x, y, 1, n);
239 text('Soldier', '', n);
240 } else if(x == 6 && y == 6) { // King
241 slide_diag(x, y, 1, n);
242 slide_orth(x, y, 1, n);
244 } else if(x == 6 && y == 5) { // dragon
245 slide_orth(x, y, size, n);
246 slide_diag(x, y, 1, n);
247 text('Dragon King', '', n);
248 } else if(x == 6 && y == 4) { // horse
249 slide_diag(x, y, size, n);
250 slide_orth(x, y, 1, n);
251 text('Dragon Horse', '', n);
252 } else if(x == 6 && y == 3) { // Ph
253 slide_orth(x, y, 1, n);
254 slide(x, y, 2, 2, 1, n);
255 slide(x, y,-2, 2, 1, n);
256 slide(x, y, 2,-2, 1, n);
257 slide(x, y,-2,-2, 1, n);
258 text('Phoenix', '', n);
259 } else if(x == 6 && y == 2) { // P
262 } else if(x == 7 && y == 6) { // E
263 slide_diag(x, y, 1, n);
266 text('Elephant', '', n);
267 } else if(x == 7 && y == 5) { // rook
268 slide_orth(x, y, size, n);
270 } else if(x == 7 && y == 4) { // bishop
271 slide_diag(x, y, size, n);
272 text('Bishop', '', n);
276 function down_click(x, y) {
280 for(i=0; i<12; i = i + 1) board[i] = new Array();
281 if(document.getElementById('sq0x0').innerHTML[1] == ' ') bw = 1;
288 x = -x; msg = msg + 2;
290 highlight(x, y, msg, 1);
291 savx = x; savy = y; down = 1;
292 // save = document.getElementById(sq).innerHTML;
293 // document.getElementById(sq).innerHTML = '<img src="sym/yellow.png">';
296 function up_click() {
297 highlight(savx, savy, msg, 0);
299 // document.getElementById('sq' + x + 'x' + y).innerHTML = save;