projects
/
xogo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Align4, fix mushrooms effect for Chakart
[xogo.git]
/
app.js
diff --git
a/app.js
b/app.js
index
79aa6e0
..
4c0b5e4
100644
(file)
--- a/
app.js
+++ b/
app.js
@@
-191,7
+191,9
@@
function getGameLink() {
const vname = $.getElementById("selectVariant").value;
const color = $.getElementById("selectColor").value;
for (const select of $.querySelectorAll("#gameOptions select")) {
const vname = $.getElementById("selectVariant").value;
const color = $.getElementById("selectColor").value;
for (const select of $.querySelectorAll("#gameOptions select")) {
- const value = parseInt(select.value, 10) || select.value;
+ let value = parseInt(select.value, 10);
+ if (isNaN(value)) //not an integer
+ value = select.value;
options[ select.id.split("_")[1] ] = value;
}
for (const input of $.querySelectorAll("#gameOptions input")) {
options[ select.id.split("_")[1] ] = value;
}
for (const input of $.querySelectorAll("#gameOptions input")) {
@@
-229,7
+231,7
@@
function fillGameInfos(gameInfos, oppIndex) {
if (j == options.length)
break;
const opt = options[j];
if (j == options.length)
break;
const opt = options[j];
- if (!opt[1])
+ if (!opt[1])
//includes 0 and false (lighter display)
continue;
htmlContent +=
'<span class="option">' +
continue;
htmlContent +=
'<span class="option">' +
@@
-454,10
+456,10
@@
function notifyMe(code) {
let curMoves = [],
lastFen;
let curMoves = [],
lastFen;
-const afterPlay = (move) => {
+const afterPlay = (move
_s
) => {
const callbackAfterSend = () => {
curMoves = [];
const callbackAfterSend = () => {
curMoves = [];
- const result = vr.getCurrentScore(move);
+ const result = vr.getCurrentScore(move
_s
);
if (result != "*") {
setTimeout(() => {
toggleVisible("gameStopped");
if (result != "*") {
setTimeout(() => {
toggleVisible("gameStopped");
@@
-466,7
+468,12
@@
const afterPlay = (move) => {
}
};
// Pack into one moves array, then send
}
};
// Pack into one moves array, then send
- curMoves.push(move);
+ 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 (vr.turn != playerColor) {
toggleTurnIndicator(false);
send("newmove",
if (vr.turn != playerColor) {
toggleTurnIndicator(false);
send("newmove",
@@
-538,8
+545,9
@@
function initializeGame(obj) {
break;
}
}
break;
}
}
- fillGameInfos(obj, playerColor == "w" ? 1 : 0);
- if (obj.randvar)
+ const playerIndex = (playerColor == "w" ? 0 : 1);
+ fillGameInfos(obj, 1 - playerIndex);
+ if (obj.players[playerIndex].randvar)
toggleVisible("gameInfos");
else
toggleVisible("boardContainer");
toggleVisible("gameInfos");
else
toggleVisible("boardContainer");