Implemented multi-move possibility in a moves list => better support for multi-moves...
[vchess.git] / client / src / utils / playUndo.js
CommitLineData
e71161fb
BA
1export function playMove(move, vr) {
2 if (!Array.isArray(move)) move = [move];
3 move.forEach(m => vr.play(m));
4}
5
6export function undoMove(move, vr) {
7 if (!Array.isArray(move)) move = [move];
8 for (let i = move.length - 1; i >= 0; i--)
9 vr.undo(move[i]);
10}
11
12export function getFilteredMove(move) {
13 if (!Array.isArray(move)) move = [move];
14 const filtered_move = move.map(m => {
15 return {
16 appear: m.appear,
17 vanish: m.vanish,
18 start: m.start,
19 end: m.end
20 };
21 });
22 return filtered_move.length == 1 ? filtered_move[0] : filtered_move;
23}