projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix magnetic promotions, attempt to fix Alice chess
[vchess.git]
/
public
/
javascripts
/
components
/
game.js
diff --git
a/public/javascripts/components/game.js
b/public/javascripts/components/game.js
index
8e8e277
..
ca8a6bf
100644
(file)
--- a/
public/javascripts/components/game.js
+++ b/
public/javascripts/components/game.js
@@
-16,6
+16,7
@@
Vue.component('my-game', {
seek: false,
fenStart: "",
incheck: [],
seek: false,
fenStart: "",
incheck: [],
+ pgnTxt: "",
expert: document.cookie.length>0 ? document.cookie.substr(-1)=="1" : false,
};
},
expert: document.cookie.length>0 ? document.cookie.substr(-1)=="1" : false,
};
},
@@
-216,18
+217,21
@@
Vue.component('my-game', {
);
}), choices]
);
);
}), choices]
);
- actionArray.push(
- h('button',
- {
- on: { click: this.resign },
- attrs: { "aria-label": 'Resign' },
- 'class': {
- "tooltip":true,
- "bottom": true,
+ if (this.mode != "idle")
+ {
+ actionArray.push(
+ h('button',
+ {
+ on: { click: this.resign },
+ attrs: { "aria-label": 'Resign' },
+ 'class': {
+ "tooltip":true,
+ "bottom": true,
+ },
},
},
- },
- [h('i', { 'class': { "material-icons": true } }, "flag")])
- );
+ [h('i', { 'class': { "material-icons": true } }, "flag")])
+ );
+ }
elementArray.push(gameDiv);
// if (!!vr.reserve)
// {
elementArray.push(gameDiv);
// if (!!vr.reserve)
// {
@@
-349,7
+353,7
@@
Vue.component('my-game', {
attrs: { id: "pgn-game" },
on: { click: this.download },
domProps: {
attrs: { id: "pgn-game" },
on: { click: this.download },
domProps: {
- innerHTML: this.
vr.getPGN(this.mycolor, this.score, this.fenStart, this.mode)
+ innerHTML: this.
pgnTxt
}
}
)
}
}
)
@@
-408,7
+412,6
@@
Vue.component('my-game', {
};
const socketMessageListener = msg => {
const data = JSON.parse(msg.data);
};
const socketMessageListener = msg => {
const data = JSON.parse(msg.data);
- console.log("Receive message: " + data.code);
switch (data.code)
{
case "newgame": //opponent found
switch (data.code)
{
case "newgame": //opponent found
@@
-493,6
+496,8
@@
Vue.component('my-game', {
this.score = score;
let modalBox = document.getElementById("modal-eog");
modalBox.checked = true;
this.score = score;
let modalBox = document.getElementById("modal-eog");
modalBox.checked = true;
+ // Variants may have special PGN structure (so next function isn't defined here)
+ this.pgnTxt = this.vr.getPGN(this.mycolor, this.score, this.fenStart, this.mode);
setTimeout(() => { modalBox.checked = false; }, 2000);
if (this.mode == "human")
this.clearStorage();
setTimeout(() => { modalBox.checked = false; }, 2000);
if (this.mode == "human")
this.clearStorage();
@@
-569,7
+574,7
@@
Vue.component('my-game', {
this.newGame("computer");
},
newGame: function(mode, fenInit, color, oppId, moves, continuation) {
this.newGame("computer");
},
newGame: function(mode, fenInit, color, oppId, moves, continuation) {
- const fen = fenInit || VariantRules.GenRandInitFen();
+ const fen =
"pppppppp/rnbqkbnr/8/8/8/8/PPPPPPPP/ROBQKBOR 1111"; //
fenInit || VariantRules.GenRandInitFen();
console.log(fen); //DEBUG
this.score = "*";
if (mode=="human" && !oppId)
console.log(fen); //DEBUG
this.score = "*";
if (mode=="human" && !oppId)
@@
-598,6
+603,7
@@
Vue.component('my-game', {
return;
}
this.vr = new VariantRules(fen, moves || []);
return;
}
this.vr = new VariantRules(fen, moves || []);
+ this.pgnTxt = ""; //redundant with this.score = "*", but cleaner
this.mode = mode;
this.incheck = []; //in case of
this.fenStart = continuation
this.mode = mode;
this.incheck = []; //in case of
this.fenStart = continuation
@@
-666,7
+672,7
@@
Vue.component('my-game', {
this.selectedPiece.style.display = "inline-block";
this.selectedPiece.style.zIndex = 3000;
let startSquare = this.getSquareFromId(e.target.parentNode.id);
this.selectedPiece.style.display = "inline-block";
this.selectedPiece.style.zIndex = 3000;
let startSquare = this.getSquareFromId(e.target.parentNode.id);
- this.possibleMoves = this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
+ this.possibleMoves = t
rue//t
his.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
? this.vr.getPossibleMovesFrom(startSquare)
: [];
e.target.parentNode.appendChild(this.selectedPiece);
? this.vr.getPossibleMovesFrom(startSquare)
: [];
e.target.parentNode.appendChild(this.selectedPiece);