9 function set(x, y, n) {
10 sq = 'sq' + x + 'x' + y;
12 board[x][y] = document.getElementById(sq).innerHTML;
14 document.getElementById(sq).innerHTML = '<img src="sym/yellow.png">';
16 document.getElementById(sq).innerHTML = '<img src="sym/red.png">';
18 document.getElementById(sq).innerHTML = '<img src="sym/cyan.png">';
20 document.getElementById(sq).innerHTML = board[x][y];
23 function text(s, t, n) {
24 if(t == '') t = ':<br>:<br>:';
26 document.getElementById('piece').innerHTML = s + '<br>' + t;
28 document.getElementById('piece').innerHTML = ':<br>:<br>:<br>:';
31 function slide(x, y, vx, vy, d, n) {
32 xx = x + vx; yy = y + vy;
35 xx = xx + vx; yy = yy + vy; d--; n = 3*n;
37 while(d-- > 0 && xx >= 0 && xx < size && yy >= 0 && yy < size) {
39 xx = xx + vx; yy = yy + vy;
43 function slide_n(x, y, d, n) {
44 slide(x, y, 2, 1, d, 3*n);
45 slide(x, y, 2,-1, d, 3*n);
46 slide(x, y,-2, 1, d, 3*n);
47 slide(x, y,-2,-1, d, 3*n);
48 slide(x, y, 1, 2, d, 3*n);
49 slide(x, y, 1,-2, d, 3*n);
50 slide(x, y,-1, 2, d, 3*n);
51 slide(x, y,-1,-2, d, 3*n);
54 function slide_f(x, y, d, n) {
55 slide(x, y, 0, 1, d, n);
58 function slide_b(x, y, d, n) {
59 slide(x, y, 0, -1, d, n);
62 function slide_v(x, y, d, n) {
67 function slide_s(x, y, d, n) {
68 slide(x, y, 1, 0, d, n);
69 slide(x, y,-1, 0, d, n);
72 function slide_fd(x, y, d, n) {
73 slide(x, y, 1, 1, d, n);
74 slide(x, y,-1, 1, d, n);
77 function slide_bd(x, y, d, n) {
78 slide(x, y, 1, -1, d, n);
79 slide(x, y,-1, -1, d, n);
82 function slide_diag(x, y, d, n) {
87 function slide_orth(x, y, d, n) {
92 function highlight(x, y, n) {
94 } else if(x == 2 && y == 5) { // V
95 slide_v(x, y, size, n);
97 text('Vertical Mover', '', n);
98 } else if(x == 2 && y == 4) { // H
99 slide_s(x, y, size, n);
101 text('Side Mover', '', n);
102 } else if(x == 2 && y == 3) { // I
104 text('Cobra (aka Go Between)', '', n);
105 } else if(x == 3 && y == 7) { // G
106 slide_orth(x, y, 1, n);
107 slide_fd(x, y, 1, n);
108 text('Gold General', '', n);
109 } else if(x == 3 && y == 6) { // FL
110 slide_diag(x, y, 1, n);
112 text('Ferocious Leopard', '', n);
113 } else if(x == 3 && y == 5) { // +V
114 slide_diag(x, y, size, n);
115 slide_v(x, y, size, n);
116 text('Narrow Queen (aka Flying Ox)', '', n);
117 } else if(x == 3 && y == 4) { // +H
118 slide_diag(x, y, size, n);
119 slide_s(x, y, size, n);
120 text('Sleeping Queen (aka Free Boar)', '', n);
121 } else if(x == 3 && y == 3) { // Ky
122 slide_diag(x, y, 1, n);
123 slide(x, y, 2, 0, 1, n);
124 slide(x, y,-2, 0, 1, n);
125 slide(x, y, 0,-2, 1, n);
126 slide(x, y, 0, 2, 1, n);
127 text('Kylin', '', n);
128 } else if(x == 4 && y == 7) { // S
129 slide_diag(x, y, 1, n);
131 text('Silver General', '', n);
132 } else if(x == 4 && y == 6) { // +A
133 slide_v(x, y, size, n);
134 slide_bd(x, y, size, n);
135 text('Whale', '', n);
136 } else if(x == 4 && y == 5) { // +D
137 slide_orth(x, y, size, n);
138 slide_bd(x, y, size, n);
139 slide_fd(x, y, 2, n);
140 text('Soaring Eagle',
141 '<i>: Can shoot or capture en-passant what is on the cyan<br>' +
142 ': square with the first of its two steps along the forward<br>' +
143 ': diagonal, or jump directly to cyan or red squares</i>', n);
144 } else if(x == 4 && y == 4) { // Lion
145 slide_diag(x, y, 2, n);
146 slide_orth(x, y, 2, n);
148 text('Lion', '<i>: Can shoot or capture en-passant what is on the<br>' +
149 ': cyan squares with the first of its two King steps,<br>' +
150 ': or jump directly to any of the colored squares</i>', n);
151 } else if(x == 4 && y == 3) { // +L
152 slide_v(x, y, size, n);
153 slide_fd(x, y, size, n);
154 text('White Horse', '', n);
155 } else if(x == 4 && y == 2) { // L
156 slide_f(x, y, size, n);
157 text('Lance', '', n);
158 } else if(x == 5 && y == 7) { // C
159 slide_fd(x, y, 1, n);
161 text('Copper General', '', n);
162 } else if(x == 5 && y == 6) { // +A
163 slide_v(x, y, size, n);
164 text('Canon (aka Reverse Chariot)', '', n);
165 } else if(x == 5 && y == 5) { // +H
166 slide_diag(x, y, size, n);
167 slide_s(x, y, size, n);
168 slide_b(x, y, size, n);
170 text('Unicorn (aka Horned Falcon)',
171 '<i>: Can shoot or capture en-passant what is on the cyan<br>' +
172 ': square with the first of its two forward/backward<br>' +
173 ': steps, or jump directly to cyan or red square</i>', n);
174 } else if(x == 5 && y == 4) { // Q
175 slide_diag(x, y, size, n);
176 slide_orth(x, y, size, n);
177 text('Queen', '', n);
178 } else if(x == 5 && y == 3) { // +BT
179 slide_v(x, y, size, n);
181 slide_diag(x, y, 1, n);
182 text('Flying Stag', '', n);
183 } else if(x == 5 && y == 2) { // BT
184 slide_diag(x, y, 1, n);
187 text('Blind Tiger', '', n);
188 } else if(x == 6 && y == 6) { // King
189 slide_diag(x, y, 1, n);
190 slide_orth(x, y, 1, n);
192 } else if(x == 6 && y == 5) { // dragon
193 slide_orth(x, y, size, n);
194 slide_diag(x, y, 1, n);
195 text('Dragon King', '', n);
196 } else if(x == 6 && y == 4) { // horse
197 slide_diag(x, y, size, n);
198 slide_orth(x, y, 1, n);
199 text('Dragon Horse', '', n);
200 } else if(x == 6 && y == 3) { // Ph
201 slide_orth(x, y, 1, n);
202 slide(x, y, 2, 2, 1, n);
203 slide(x, y,-2, 2, 1, n);
204 slide(x, y, 2,-2, 1, n);
205 slide(x, y,-2,-2, 1, n);
206 text('Phoenix', '', n);
207 } else if(x == 6 && y == 2) { // P
210 } else if(x == 7 && y == 6) { // E
211 slide_diag(x, y, 1, n);
214 text('Elephant', '', n);
215 } else if(x == 7 && y == 5) { // rook
216 slide_orth(x, y, size, n);
218 } else if(x == 7 && y == 4) { // bishop
219 slide_diag(x, y, size, n);
220 text('Bishop', '', n);
224 function down_click(x, y) {
228 for(i=0; i<12; i = i + 1) board[i] = new Array();
232 savx = x; savy = y; down = 1;
233 // sq = 'sq' + x + 'x' + y;
235 // save = document.getElementById(sq).innerHTML;
236 // document.getElementById(sq).innerHTML = '<img src="sym/yellow.png">';
239 function up_click() {
240 highlight(savx, savy, 0);
242 // document.getElementById('sq' + x + 'x' + y).innerHTML = save;