-const afterPlay = (move) => {
- const callbackAfterSend = () => {
- curMoves = [];
- const result = vr.getCurrentScore(move);
+const afterPlay = (move_s, newTurn, ops) => {
+ if (ops.send) {
+ // Pack into one moves array, then send (if turn changed)
+ if (Array.isArray(move_s))
+ // Array of simple moves (e.g. Chakart)
+ Array.prototype.push.apply(curMoves, move_s);
+ else
+ // Usual case
+ curMoves.push(move_s);
+ if (newTurn != playerColor) {
+ send("newmove",
+ {gid: gid, moves: curMoves, fen: vr.getFen()},
+ {
+ retry: true,
+ success: () => curMoves = [],
+ error: () => alert("Move not sent: reload page")
+ }
+ );
+ }
+ }
+ if (ops.res && newTurn != playerColor) {
+ toggleTurnIndicator(false); //now all moves are sent and animated
+ const result = vr.getCurrentScore(move_s);