ssb-chess-mithril 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/chessground-examples/README.md +14 -4
- package/css/chessground-examples/assets/3d.css +24 -23
- package/css/chessground-examples/assets/chessground.css +73 -15
- package/css/chessground-examples/assets/examples.css +1 -1
- package/css/chessground-examples/assets/theme.css +37 -26
- package/css/chessground-examples/index.html +5 -5
- package/css/chessground-examples/package-lock.json +1747 -8086
- package/css/chessground-examples/package.json +32 -17
- package/css/chessground-examples/pnpm-lock.yaml +874 -0
- package/css/chessground-examples/rollup.config.mjs +20 -0
- package/css/chessground-examples/src/main.ts +81 -48
- package/css/chessground-examples/src/units/anim.ts +63 -42
- package/css/chessground-examples/src/units/basics.ts +73 -13
- package/css/chessground-examples/src/units/fen.ts +21 -18
- package/css/chessground-examples/src/units/in3d.ts +26 -26
- package/css/chessground-examples/src/units/perf.ts +29 -15
- package/css/chessground-examples/src/units/play.ts +71 -52
- package/css/chessground-examples/src/units/svg.ts +230 -102
- package/css/chessground-examples/src/units/unit.ts +47 -18
- package/css/chessground-examples/src/units/viewOnly.ts +11 -11
- package/css/chessground-examples/src/units/zh.ts +25 -23
- package/css/chessground-examples/src/util.ts +30 -18
- package/css/chessground-examples/tsconfig.json +6 -4
- package/css/miniboards.css +1 -0
- package/index.js +87 -78
- package/package.json +4 -4
- package/ui/game/PieceGraveyard.js +1 -1
- package/ui/game/chat.js +3 -3
- package/ui/game/gameHistory.js +5 -1
- package/ui/game/gameView.js +30 -11
- package/ui/miniboard/miniboard.js +8 -5
- package/ui/pageLayout/navigation.js +11 -7
- package/css/chessground-examples/gulpfile.js +0 -52
- package/css/chessground-examples/index.standalone.html +0 -17
- package/css/chessground-examples/yarn.lock +0 -3529
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import { Chessground }
|
|
2
|
-
import { DrawShape } from
|
|
3
|
-
import { Unit } from
|
|
1
|
+
import { Chessground } from "@lichess-org/chessground";
|
|
2
|
+
import { DrawShape } from "@lichess-org/chessground/draw";
|
|
3
|
+
import { Unit } from "./unit";
|
|
4
4
|
|
|
5
5
|
export const presetUserShapes: Unit = {
|
|
6
|
-
name:
|
|
7
|
-
run: el => Chessground(el, { drawable: { shapes: shapeSet1 } })
|
|
6
|
+
name: "Preset user shapes",
|
|
7
|
+
run: (el) => Chessground(el, { drawable: { shapes: shapeSet1 } }),
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const fenAndShapes: Unit = {
|
|
11
|
+
name: "FEN and shapes",
|
|
12
|
+
run: (el) =>
|
|
13
|
+
Chessground(el, {
|
|
14
|
+
fen: "2r2rk1/4bp1p/pp2p1p1/4P3/4bP2/PqN1B2Q/1P3RPP/2R3K1 w - - 1 23",
|
|
15
|
+
drawable: { shapes: shapeSet1 },
|
|
16
|
+
}),
|
|
8
17
|
};
|
|
9
18
|
|
|
10
19
|
export const changingShapesHigh: Unit = {
|
|
11
|
-
name:
|
|
20
|
+
name: "Automatically changing shapes (high diff)",
|
|
12
21
|
run(el) {
|
|
13
22
|
const cg = Chessground(el, { drawable: { shapes: shapeSet1 } });
|
|
14
23
|
const delay = 1000;
|
|
@@ -21,11 +30,11 @@ export const changingShapesHigh: Unit = {
|
|
|
21
30
|
}
|
|
22
31
|
setTimeout(run, delay);
|
|
23
32
|
return cg;
|
|
24
|
-
}
|
|
33
|
+
},
|
|
25
34
|
};
|
|
26
35
|
|
|
27
36
|
export const changingShapesLow: Unit = {
|
|
28
|
-
name:
|
|
37
|
+
name: "Automatically changing shapes (low diff)",
|
|
29
38
|
run(el) {
|
|
30
39
|
const cg = Chessground(el, { drawable: { shapes: shapeSet1 } });
|
|
31
40
|
const delay = 1000;
|
|
@@ -38,20 +47,24 @@ export const changingShapesLow: Unit = {
|
|
|
38
47
|
}
|
|
39
48
|
setTimeout(run, delay);
|
|
40
49
|
return cg;
|
|
41
|
-
}
|
|
50
|
+
},
|
|
42
51
|
};
|
|
43
52
|
|
|
44
53
|
export const brushModifiers: Unit = {
|
|
45
|
-
name:
|
|
54
|
+
name: "Brush modifiers",
|
|
46
55
|
run(el) {
|
|
47
56
|
function sets() {
|
|
48
|
-
return [shapeSet1, shapeSet1b, shapeSet1c].map(set =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
return [shapeSet1, shapeSet1b, shapeSet1c].map((set) =>
|
|
58
|
+
set.map((shape) => {
|
|
59
|
+
shape.modifiers = Math.round(Math.random())
|
|
60
|
+
? undefined
|
|
61
|
+
: {
|
|
62
|
+
lineWidth: 2 + Math.round(Math.random() * 3) * 4,
|
|
63
|
+
};
|
|
64
|
+
return shape;
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
55
68
|
const cg = Chessground(el, { drawable: { shapes: sets()[0] } });
|
|
56
69
|
const delay = 1000;
|
|
57
70
|
let i = 0;
|
|
@@ -62,20 +75,24 @@ export const brushModifiers: Unit = {
|
|
|
62
75
|
}
|
|
63
76
|
setTimeout(run, delay);
|
|
64
77
|
return cg;
|
|
65
|
-
}
|
|
78
|
+
},
|
|
66
79
|
};
|
|
67
80
|
|
|
68
81
|
export const autoShapes: Unit = {
|
|
69
|
-
name:
|
|
82
|
+
name: "Autoshapes",
|
|
70
83
|
run(el) {
|
|
71
84
|
function sets() {
|
|
72
|
-
return [shapeSet1, shapeSet1b, shapeSet1c].map(set =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
return [shapeSet1, shapeSet1b, shapeSet1c].map((set) =>
|
|
86
|
+
set.map((shape) => {
|
|
87
|
+
shape.modifiers = Math.round(Math.random())
|
|
88
|
+
? undefined
|
|
89
|
+
: {
|
|
90
|
+
lineWidth: 2 + Math.round(Math.random() * 3) * 4,
|
|
91
|
+
};
|
|
92
|
+
return shape;
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
79
96
|
const cg = Chessground(el);
|
|
80
97
|
const delay = 1000;
|
|
81
98
|
let i = 0;
|
|
@@ -86,99 +103,210 @@ export const autoShapes: Unit = {
|
|
|
86
103
|
}
|
|
87
104
|
setTimeout(run, delay);
|
|
88
105
|
return cg;
|
|
89
|
-
}
|
|
106
|
+
},
|
|
90
107
|
};
|
|
91
108
|
|
|
92
109
|
export const visibleFalse: Unit = {
|
|
93
|
-
name:
|
|
94
|
-
run: el =>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
name: "Shapes not visible",
|
|
111
|
+
run: (el) =>
|
|
112
|
+
Chessground(el, {
|
|
113
|
+
drawable: {
|
|
114
|
+
visible: false,
|
|
115
|
+
shapes: shapeSet1,
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
100
118
|
};
|
|
101
119
|
|
|
102
120
|
export const enabledFalse: Unit = {
|
|
103
|
-
name:
|
|
104
|
-
run: el =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
121
|
+
name: "Shapes not enabled, but visible",
|
|
122
|
+
run: (el) =>
|
|
123
|
+
Chessground(el, {
|
|
124
|
+
drawable: {
|
|
125
|
+
enabled: false,
|
|
126
|
+
shapes: shapeSet1,
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const eraseOnClickFalse: Unit = {
|
|
132
|
+
name: "drawable.eraseOnClick: false",
|
|
133
|
+
run: (el) =>
|
|
134
|
+
Chessground(el, {
|
|
135
|
+
drawable: {
|
|
136
|
+
eraseOnMovablePieceClick: false,
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const customSvg: Unit = {
|
|
142
|
+
name: "Custom SVG",
|
|
143
|
+
run(el) {
|
|
144
|
+
const cg = Chessground(el, { animation: { duration: 300 } });
|
|
145
|
+
|
|
146
|
+
const sleep = (msec) => new Promise((resolve) => setTimeout(resolve, msec));
|
|
147
|
+
|
|
148
|
+
const loop = async () => {
|
|
149
|
+
if (!cg.state.dom.elements.board.offsetParent) return;
|
|
150
|
+
|
|
151
|
+
cg.set({
|
|
152
|
+
fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
|
|
153
|
+
});
|
|
154
|
+
cg.setAutoShapes([]);
|
|
155
|
+
await sleep(1000);
|
|
156
|
+
|
|
157
|
+
cg.move("e2", "e4");
|
|
158
|
+
cg.setAutoShapes([{ orig: "e4", brush: "green", customSvg: glyphToSvg["??"] }]);
|
|
159
|
+
await sleep(1000);
|
|
160
|
+
|
|
161
|
+
cg.move("e7", "e5");
|
|
162
|
+
cg.setAutoShapes([{ orig: "e5", brush: "green", customSvg: glyphToSvg["?!"] }]);
|
|
163
|
+
await sleep(1000);
|
|
164
|
+
|
|
165
|
+
cg.move("d1", "e2");
|
|
166
|
+
cg.setAutoShapes([{ orig: "e2", brush: "green", customSvg: glyphToSvg["?"] }]);
|
|
167
|
+
await sleep(1000);
|
|
168
|
+
|
|
169
|
+
setTimeout(loop);
|
|
170
|
+
};
|
|
171
|
+
loop();
|
|
172
|
+
|
|
173
|
+
return cg;
|
|
174
|
+
},
|
|
110
175
|
};
|
|
111
176
|
|
|
112
177
|
const shapeSet1: DrawShape[] = [
|
|
113
|
-
{ orig:
|
|
114
|
-
{ orig:
|
|
115
|
-
{ orig:
|
|
116
|
-
{ orig:
|
|
117
|
-
{ orig:
|
|
118
|
-
{ orig:
|
|
119
|
-
{ orig:
|
|
120
|
-
{ orig:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
178
|
+
{ orig: "a3", brush: "green" },
|
|
179
|
+
{ orig: "a4", brush: "blue" },
|
|
180
|
+
{ orig: "a5", brush: "yellow" },
|
|
181
|
+
{ orig: "a6", brush: "red" },
|
|
182
|
+
{ orig: "e2", dest: "e4", brush: "green" },
|
|
183
|
+
{ orig: "a6", dest: "c8", brush: "blue" },
|
|
184
|
+
{ orig: "f8", dest: "f4", brush: "yellow" },
|
|
185
|
+
{ orig: "f2", dest: "f4", brush: "paleRed", modifiers: { hilite: "#3291ff" } },
|
|
186
|
+
{
|
|
187
|
+
orig: "h5",
|
|
188
|
+
brush: "green",
|
|
189
|
+
piece: {
|
|
190
|
+
color: "white",
|
|
191
|
+
role: "knight",
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
orig: "h6",
|
|
196
|
+
brush: "red",
|
|
197
|
+
piece: {
|
|
198
|
+
color: "black",
|
|
199
|
+
role: "queen",
|
|
200
|
+
scale: 0.6,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{ orig: "c5", brush: "paleRed", modifiers: { hilite: "#3291ff" } },
|
|
204
|
+
{ orig: "c6", brush: "paleRed", modifiers: { hilite: "#3291ff" } },
|
|
205
|
+
{ orig: "d6", brush: "paleGreen", modifiers: { hilite: "#aaa" } },
|
|
206
|
+
{ orig: "d5", brush: "paleGreen", modifiers: { hilite: "#aaa" } },
|
|
129
207
|
];
|
|
130
208
|
|
|
131
209
|
const shapeSet2: DrawShape[] = [
|
|
132
|
-
{ orig:
|
|
133
|
-
{ orig:
|
|
134
|
-
{ orig:
|
|
135
|
-
{ orig:
|
|
136
|
-
{ orig:
|
|
137
|
-
{ orig:
|
|
138
|
-
{ orig:
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
210
|
+
{ orig: "c1", brush: "green" },
|
|
211
|
+
{ orig: "d1", brush: "blue" },
|
|
212
|
+
{ orig: "e1", brush: "yellow" },
|
|
213
|
+
{ orig: "e2", dest: "e4", brush: "green" },
|
|
214
|
+
{ orig: "h6", dest: "h8", brush: "blue" },
|
|
215
|
+
{ orig: "b3", dest: "d6", brush: "red" },
|
|
216
|
+
{ orig: "a1", dest: "e1", brush: "red" },
|
|
217
|
+
{
|
|
218
|
+
orig: "f5",
|
|
219
|
+
brush: "green",
|
|
220
|
+
piece: {
|
|
221
|
+
color: "black",
|
|
222
|
+
role: "bishop",
|
|
223
|
+
},
|
|
224
|
+
},
|
|
143
225
|
];
|
|
144
226
|
|
|
145
|
-
const shapeSet3: DrawShape[] = [
|
|
146
|
-
{ orig: 'e5', brush: 'blue' }
|
|
147
|
-
];
|
|
227
|
+
const shapeSet3: DrawShape[] = [{ orig: "e5", brush: "blue" }];
|
|
148
228
|
|
|
149
229
|
const shapeSet1b: DrawShape[] = [
|
|
150
|
-
{ orig:
|
|
151
|
-
{ orig:
|
|
152
|
-
{ orig:
|
|
153
|
-
{ orig:
|
|
154
|
-
{ orig:
|
|
155
|
-
{ orig:
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
230
|
+
{ orig: "a3", brush: "green" },
|
|
231
|
+
{ orig: "a5", brush: "yellow" },
|
|
232
|
+
{ orig: "a6", brush: "red" },
|
|
233
|
+
{ orig: "e2", dest: "e4", brush: "green" },
|
|
234
|
+
{ orig: "a6", dest: "c8", brush: "blue" },
|
|
235
|
+
{ orig: "f8", dest: "f4", brush: "yellow" },
|
|
236
|
+
{
|
|
237
|
+
orig: "h5",
|
|
238
|
+
brush: "green",
|
|
239
|
+
piece: {
|
|
240
|
+
color: "white",
|
|
241
|
+
role: "knight",
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
orig: "h6",
|
|
246
|
+
brush: "red",
|
|
247
|
+
piece: {
|
|
248
|
+
color: "black",
|
|
249
|
+
role: "queen",
|
|
250
|
+
scale: 0.6,
|
|
251
|
+
},
|
|
252
|
+
},
|
|
165
253
|
];
|
|
166
254
|
|
|
167
255
|
const shapeSet1c: DrawShape[] = [
|
|
168
|
-
{ orig:
|
|
169
|
-
{ orig:
|
|
170
|
-
{ orig:
|
|
171
|
-
{ orig:
|
|
172
|
-
{ orig:
|
|
173
|
-
{ orig:
|
|
174
|
-
{ orig:
|
|
175
|
-
{
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
256
|
+
{ orig: "a3", brush: "green" },
|
|
257
|
+
{ orig: "a5", brush: "yellow" },
|
|
258
|
+
{ orig: "a6", brush: "red" },
|
|
259
|
+
{ orig: "e2", dest: "e4", brush: "green" },
|
|
260
|
+
{ orig: "a6", dest: "c8", brush: "blue" },
|
|
261
|
+
{ orig: "b6", dest: "d8", brush: "blue" },
|
|
262
|
+
{ orig: "f8", dest: "f4", brush: "yellow" },
|
|
263
|
+
{
|
|
264
|
+
orig: "h5",
|
|
265
|
+
brush: "green",
|
|
266
|
+
piece: {
|
|
267
|
+
color: "white",
|
|
268
|
+
role: "knight",
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
orig: "h6",
|
|
273
|
+
brush: "red",
|
|
274
|
+
piece: {
|
|
275
|
+
color: "black",
|
|
276
|
+
role: "queen",
|
|
277
|
+
scale: 0.6,
|
|
278
|
+
},
|
|
279
|
+
},
|
|
184
280
|
];
|
|
281
|
+
|
|
282
|
+
const glyphToSvg = {
|
|
283
|
+
// Inaccuracy
|
|
284
|
+
"?!": {
|
|
285
|
+
html: `
|
|
286
|
+
<g transform="translate(68 2) scale(0.3)">
|
|
287
|
+
<circle style="fill:#56b4e9" cx="50" cy="50" r="50" />
|
|
288
|
+
<path style="fill:#ffffff;stroke-width:0.81934" d="m 37.734375,21.947266 c -3.714341,0 -7.128696,0.463992 -10.242187,1.392578 -3.113493,0.928585 -6.009037,2.130656 -8.685547,3.605468 l 4.34375,8.765626 c 2.348774,-1.201699 4.643283,-2.157093 6.882812,-2.867188 2.239529,-0.710095 4.504676,-1.064453 6.798828,-1.064453 2.294152,0 4.069851,0.463993 5.326172,1.392578 1.310944,0.873963 1.966797,2.185668 1.966797,3.933594 0,1.747925 -0.546219,3.276946 -1.638672,4.58789 -1.037831,1.256322 -2.786121,2.757934 -5.24414,4.50586 -2.785757,2.021038 -4.751362,3.961188 -5.898438,5.818359 -1.147076,1.857171 -1.720703,4.149726 -1.720703,6.88086 v 2.951171 h 10.568359 v -2.376953 c 0,-1.147076 0.137043,-2.10247 0.410156,-2.867187 0.327737,-0.764718 0.928772,-1.557613 1.802735,-2.376953 0.873963,-0.81934 2.103443,-1.802143 3.6875,-2.949219 2.130284,-1.584057 3.905982,-3.058262 5.326172,-4.423828 1.420189,-1.42019 2.485218,-2.951164 3.195312,-4.589844 0.710095,-1.63868 1.064453,-3.576877 1.064453,-5.816406 0,-4.205946 -1.583838,-7.675117 -4.751953,-10.40625 -3.113492,-2.731134 -7.510649,-4.095703 -13.191406,-4.095703 z m 24.744141,0.818359 2.048828,39.083984 h 9.75 L 76.324219,22.765625 Z M 35.357422,68.730469 c -1.966416,0 -3.63248,0.51881 -4.998047,1.55664 -1.365567,0.983208 -2.046875,2.731498 -2.046875,5.244141 0,2.403397 0.681308,4.151687 2.046875,5.244141 1.365567,1.03783 3.031631,1.55664 4.998047,1.55664 1.911793,0 3.550449,-0.51881 4.916016,-1.55664 1.365566,-1.092454 2.048828,-2.840744 2.048828,-5.244141 0,-2.512643 -0.683262,-4.260933 -2.048828,-5.244141 -1.365567,-1.03783 -3.004223,-1.55664 -4.916016,-1.55664 z m 34.003906,0 c -1.966416,0 -3.63248,0.51881 -4.998047,1.55664 -1.365566,0.983208 -2.048828,2.731498 -2.048828,5.244141 0,2.403397 0.683262,4.151687 2.048828,5.244141 1.365567,1.03783 3.031631,1.55664 4.998047,1.55664 1.911793,0 3.550449,-0.51881 4.916016,-1.55664 1.365566,-1.092454 2.046875,-2.840744 2.046875,-5.244141 0,-2.512643 -0.681309,-4.260933 -2.046875,-5.244141 -1.365567,-1.03783 -3.004223,-1.55664 -4.916016,-1.55664 z" />
|
|
289
|
+
</g>
|
|
290
|
+
`,
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
// Mistake
|
|
294
|
+
"?": {
|
|
295
|
+
html: `
|
|
296
|
+
<g transform="translate(68 2) scale(0.3)">
|
|
297
|
+
<circle style="fill:#e69f00" cx="50" cy="50" r="50" />
|
|
298
|
+
<path style="fill:#ffffff;stroke-width:0.932208" d="m 40.435856,60.851495 q 0,-4.661041 1.957637,-7.830548 1.957637,-3.169507 6.711897,-6.618677 4.194937,-2.983065 5.966132,-5.127144 1.864416,-2.237299 1.864416,-5.220365 0,-2.983065 -2.237299,-4.474598 -2.144079,-1.584754 -6.059353,-1.584754 -3.915273,0 -7.737326,1.21187 -3.822053,1.211871 -7.830548,3.262729 L 28.13071,24.495382 q 4.567819,-2.516962 9.881405,-4.101716 5.313586,-1.584753 11.6526,-1.584753 9.694964,0 15.008549,4.66104 5.406807,4.66104 5.406807,11.839042 0,3.822053 -1.21187,6.618677 -1.211871,2.796624 -3.635612,5.220365 -2.423741,2.33052 -6.059352,5.033923 -2.703403,1.957637 -4.194936,3.355949 -1.491533,1.398312 -2.050858,2.703403 -0.466104,1.305091 -0.466104,3.262728 v 2.703403 H 40.435856 Z m -1.491533,18.923822 q 0,-4.288156 2.33052,-5.966131 2.33052,-1.771195 5.686469,-1.771195 3.262728,0 5.593248,1.771195 2.33052,1.677975 2.33052,5.966131 0,4.101716 -2.33052,5.966132 -2.33052,1.771195 -5.593248,1.771195 -3.355949,0 -5.686469,-1.771195 -2.33052,-1.864416 -2.33052,-5.966132 z" />
|
|
299
|
+
</g>
|
|
300
|
+
`,
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
// Blunder
|
|
304
|
+
"??": {
|
|
305
|
+
html: `
|
|
306
|
+
<g transform="translate(68 2) scale(0.3)">
|
|
307
|
+
<circle style="fill:#df5353" cx="50" cy="50" r="50" />
|
|
308
|
+
<path style="fill:#ffffff;stroke-width:0.810558" d="m 31.799294,22.220598 c -3.67453,-10e-7 -7.050841,0.460303 -10.130961,1.378935 -3.08012,0.918633 -5.945403,2.106934 -8.593226,3.565938 l 4.297618,8.67363 c 2.3236,-1.188818 4.592722,-2.135794 6.808247,-2.838277 2.215525,-0.702483 4.45828,-1.053299 6.727842,-1.053299 2.269562,0 4.025646,0.460305 5.268502,1.378937 1.296893,0.864596 1.945788,2.160375 1.945788,3.889565 0,1.72919 -0.541416,3.241939 -1.62216,4.538831 -1.026707,1.242856 -2.756423,2.729237 -5.188097,4.458428 -2.755898,1.999376 -4.700572,3.917682 -5.835354,5.754947 -1.13478,1.837266 -1.702564,4.106388 -1.702564,6.808248 v 2.918681 h 10.4566 v -2.34982 c 0,-1.134781 0.135856,-2.081756 0.406042,-2.838277 0.324222,-0.756521 0.918373,-1.539262 1.782969,-2.349819 0.864595,-0.810559 2.079262,-1.783901 3.646342,-2.918683 2.10745,-1.567078 3.863533,-3.025082 5.268501,-4.376012 1.404967,-1.404967 2.459422,-2.919725 3.161905,-4.540841 0.702483,-1.621116 1.053298,-3.539423 1.053298,-5.754948 0,-4.160865 -1.567492,-7.591921 -4.70165,-10.29378 -3.080121,-2.70186 -7.429774,-4.052384 -13.049642,-4.052384 z m 38.66449,0 c -3.67453,-10e-7 -7.05285,0.460303 -10.132971,1.378935 -3.08012,0.918633 -5.943393,2.106934 -8.591215,3.565938 l 4.295608,8.67363 c 2.323599,-1.188818 4.592721,-2.135794 6.808246,-2.838277 2.215526,-0.702483 4.458281,-1.053299 6.727842,-1.053299 2.269563,0 4.025647,0.460305 5.268502,1.378937 1.296893,0.864596 1.945788,2.160375 1.945788,3.889565 0,1.72919 -0.539406,3.241939 -1.62015,4.538831 -1.026707,1.242856 -2.756423,2.729237 -5.188097,4.458428 -2.755897,1.999376 -4.700572,3.917682 -5.835353,5.754947 -1.134782,1.837266 -1.702564,4.106388 -1.702564,6.808248 v 2.918681 h 10.456599 v -2.34982 c 0,-1.134781 0.133846,-2.081756 0.404032,-2.838277 0.324223,-0.756521 0.918374,-1.539262 1.782969,-2.349819 0.864596,-0.810559 2.081273,-1.783901 3.648352,-2.918683 2.107451,-1.567078 3.863534,-3.025082 5.268502,-4.376012 1.404966,-1.404967 2.45942,-2.919725 3.161904,-4.540841 0.702483,-1.621116 1.053299,-3.539423 1.053299,-5.754948 0,-4.160865 -1.567493,-7.591921 -4.701651,-10.29378 -3.08012,-2.70186 -7.429774,-4.052384 -13.049642,-4.052384 z M 29.449473,68.50341 c -1.945339,0 -3.593943,0.513038 -4.944873,1.539744 -1.350931,0.97267 -2.026192,2.702386 -2.026192,5.188098 0,2.377636 0.675261,4.107352 2.026192,5.188097 1.35093,1.026707 2.999534,1.539745 4.944873,1.539745 1.891302,0 3.51153,-0.513038 4.86246,-1.539745 1.35093,-1.080745 2.026192,-2.810461 2.026192,-5.188097 0,-2.485712 -0.675262,-4.215428 -2.026192,-5.188098 -1.35093,-1.026706 -2.971158,-1.539744 -4.86246,-1.539744 z m 38.662481,0 c -1.945339,0 -3.591933,0.513038 -4.942864,1.539744 -1.35093,0.97267 -2.026192,2.702386 -2.026192,5.188098 0,2.377636 0.675262,4.107352 2.026192,5.188097 1.350931,1.026707 2.997525,1.539745 4.942864,1.539745 1.891302,0 3.513539,-0.513038 4.864469,-1.539745 1.350931,-1.080745 2.026192,-2.810461 2.026192,-5.188097 0,-2.485712 -0.675261,-4.215428 -2.026192,-5.188098 -1.35093,-1.026706 -2.973167,-1.539744 -4.864469,-1.539744 z" />
|
|
309
|
+
</g>
|
|
310
|
+
`,
|
|
311
|
+
},
|
|
312
|
+
};
|
|
@@ -1,28 +1,57 @@
|
|
|
1
|
-
import { Api } from
|
|
1
|
+
import { Api } from "@lichess-org/chessground/api";
|
|
2
2
|
|
|
3
|
-
import * as basics from
|
|
4
|
-
import * as play from
|
|
5
|
-
import * as perf from
|
|
6
|
-
import * as zh from
|
|
7
|
-
import * as anim from
|
|
8
|
-
import * as svg from
|
|
9
|
-
import * as in3d from
|
|
10
|
-
import * as fen from
|
|
11
|
-
import * as viewOnly from
|
|
3
|
+
import * as basics from "./basics";
|
|
4
|
+
import * as play from "./play";
|
|
5
|
+
import * as perf from "./perf";
|
|
6
|
+
import * as zh from "./zh";
|
|
7
|
+
import * as anim from "./anim";
|
|
8
|
+
import * as svg from "./svg";
|
|
9
|
+
import * as in3d from "./in3d";
|
|
10
|
+
import * as fen from "./fen";
|
|
11
|
+
import * as viewOnly from "./viewOnly";
|
|
12
12
|
|
|
13
13
|
export interface Unit {
|
|
14
14
|
name: string;
|
|
15
|
-
run: (el: HTMLElement) => Api
|
|
15
|
+
run: (el: HTMLElement) => Api;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const list: Unit[] = [
|
|
19
|
-
basics.defaults,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
basics.defaults,
|
|
20
|
+
basics.fromFen,
|
|
21
|
+
basics.lastMoveCrazyhouse,
|
|
22
|
+
basics.checkHighlight,
|
|
23
|
+
basics.unselectable,
|
|
24
|
+
basics.unselectableDraggable,
|
|
25
|
+
basics.selectableUndraggable,
|
|
26
|
+
play.initial,
|
|
27
|
+
play.castling,
|
|
28
|
+
play.vsRandom,
|
|
29
|
+
play.fullRandom,
|
|
30
|
+
play.slowAnim,
|
|
31
|
+
play.conflictingHold,
|
|
32
|
+
play.jsHover,
|
|
33
|
+
perf.metaSquares,
|
|
34
|
+
perf.move,
|
|
35
|
+
perf.select,
|
|
36
|
+
anim.conflictingAnim,
|
|
37
|
+
anim.withSameRole,
|
|
38
|
+
anim.notSameRole,
|
|
39
|
+
anim.whileHolding,
|
|
40
|
+
anim.enPassant,
|
|
23
41
|
zh.lastMoveDrop,
|
|
24
|
-
svg.presetUserShapes,
|
|
25
|
-
|
|
42
|
+
svg.presetUserShapes,
|
|
43
|
+
svg.fenAndShapes,
|
|
44
|
+
svg.changingShapesHigh,
|
|
45
|
+
svg.changingShapesLow,
|
|
46
|
+
svg.brushModifiers,
|
|
47
|
+
svg.autoShapes,
|
|
48
|
+
svg.visibleFalse,
|
|
49
|
+
svg.enabledFalse,
|
|
50
|
+
svg.eraseOnClickFalse,
|
|
51
|
+
svg.customSvg,
|
|
52
|
+
in3d.defaults,
|
|
53
|
+
in3d.vsRandom,
|
|
54
|
+
in3d.fullRandom,
|
|
26
55
|
fen.autoSwitch,
|
|
27
|
-
viewOnly.fullRandom
|
|
56
|
+
viewOnly.fullRandom,
|
|
28
57
|
];
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Chess } from
|
|
2
|
-
import { Chessground }
|
|
3
|
-
import { Unit } from
|
|
1
|
+
import { Chess } from "chess.js";
|
|
2
|
+
import { Chessground } from "@lichess-org/chessground";
|
|
3
|
+
import { Unit } from "./unit";
|
|
4
4
|
|
|
5
5
|
export const fullRandom: Unit = {
|
|
6
|
-
name:
|
|
6
|
+
name: "View only: 2 random AIs",
|
|
7
7
|
run(el) {
|
|
8
8
|
const chess = new Chess();
|
|
9
9
|
const cg = Chessground(el, {
|
|
10
10
|
viewOnly: true,
|
|
11
11
|
animation: {
|
|
12
|
-
duration: 1000
|
|
12
|
+
duration: 1000,
|
|
13
13
|
},
|
|
14
14
|
movable: {
|
|
15
|
-
free: false
|
|
15
|
+
free: false,
|
|
16
16
|
},
|
|
17
17
|
drawable: {
|
|
18
|
-
visible: false
|
|
19
|
-
}
|
|
18
|
+
visible: false,
|
|
19
|
+
},
|
|
20
20
|
});
|
|
21
21
|
function makeMove() {
|
|
22
22
|
if (!cg.state.dom.elements.board.offsetParent) return;
|
|
23
|
-
const moves = chess.moves({verbose:true});
|
|
23
|
+
const moves = chess.moves({ verbose: true });
|
|
24
24
|
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
25
25
|
chess.move(move.san);
|
|
26
26
|
cg.move(move.from, move.to);
|
|
@@ -28,5 +28,5 @@ export const fullRandom: Unit = {
|
|
|
28
28
|
}
|
|
29
29
|
setTimeout(makeMove, 700);
|
|
30
30
|
return cg;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import { Unit } from
|
|
2
|
-
import { Chessground }
|
|
3
|
-
import { Key } from
|
|
1
|
+
import { Unit } from "./unit";
|
|
2
|
+
import { Chessground } from "@lichess-org/chessground";
|
|
3
|
+
import { Key } from "@lichess-org/chessground/types.d";
|
|
4
4
|
|
|
5
5
|
export const lastMoveDrop: Unit = {
|
|
6
|
-
name:
|
|
6
|
+
name: "Crazyhouse: lastMove = drop",
|
|
7
7
|
run(cont) {
|
|
8
|
-
const configs: Array<() => {fen: string; lastMove: Key[]}> = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
const configs: Array<() => { fen: string; lastMove: Key[] }> = [
|
|
9
|
+
() => {
|
|
10
|
+
return {
|
|
11
|
+
fen: "Bn2kb1r/p1p2ppp/4q3/2Pp4/3p1NP1/2B2n2/PPP2P1P/R2KqB1R/RNpp w k - 42 22",
|
|
12
|
+
lastMove: ["e5", "d4"],
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
() => {
|
|
16
|
+
return {
|
|
17
|
+
fen: "Bn2kb1r/p1p2ppp/4q3/2Pp4/3p1NP1/2B2n2/PPP2P1P/R2KqB1R/RNpp w k - 42 22",
|
|
18
|
+
lastMove: ["f4"],
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
() => {
|
|
22
|
+
return {
|
|
23
|
+
fen: "Bn2kb1r/p1p2ppp/4q3/2Pp4/3p1NP1/2B2n2/PPP2P1P/R2KqB1R/RNpp w k - 42 22",
|
|
24
|
+
lastMove: ["e1"],
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
];
|
|
24
28
|
const cg = Chessground(cont, configs[0]());
|
|
25
29
|
const delay = 2000;
|
|
26
30
|
let it = 0;
|
|
27
31
|
function run() {
|
|
28
32
|
if (!cg.state.dom.elements.board.offsetParent) return;
|
|
29
33
|
const config = configs[++it % configs.length];
|
|
30
|
-
console.log(config);
|
|
31
34
|
cg.set(config());
|
|
32
35
|
setTimeout(run, delay);
|
|
33
36
|
}
|
|
34
37
|
setTimeout(run, delay);
|
|
35
38
|
return cg;
|
|
36
|
-
}
|
|
39
|
+
},
|
|
37
40
|
};
|
|
38
|
-
|