projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some fixes, problems logic now functional
[vchess.git]
/
public
/
javascripts
/
components
/
game.js
diff --git
a/public/javascripts/components/game.js
b/public/javascripts/components/game.js
index
16e1fdb
..
186c027
100644
(file)
--- a/
public/javascripts/components/game.js
+++ b/
public/javascripts/components/game.js
@@
-326,7
+326,7
@@
Vue.component('my-game', {
]
);
}
]
);
}
- if (
this.mode == "friend"
)
+ if (
["friend","problem"].includes(this.mode)
)
{
actionArray = actionArray.concat(
[
{
actionArray = actionArray.concat(
[
@@
-778,7
+778,7
@@
Vue.component('my-game', {
h('h3',
{
domProps: { innerHTML: "Show solution" },
h('h3',
{
domProps: { innerHTML: "Show solution" },
- on: { click:
"toggleShowSolution" }
+ on: { click:
this.toggleShowSolution },
}
),
h('p',
}
),
h('p',
@@
-969,9
+969,10
@@
Vue.component('my-game', {
methods: {
toggleShowSolution: function() {
let problemSolution = document.getElementById("problem-solution");
methods: {
toggleShowSolution: function() {
let problemSolution = document.getElementById("problem-solution");
- problemSolution.style.display = problemSolution.style.display == "none"
- ? "block"
- : "none";
+ problemSolution.style.display =
+ !problemSolution.style.display || problemSolution.style.display == "none"
+ ? "block"
+ : "none";
},
download: function() {
let content = document.getElementById("pgn-game").innerHTML;
},
download: function() {
let content = document.getElementById("pgn-game").innerHTML;
@@
-1142,7
+1143,7
@@
Vue.component('my-game', {
this.fenStart = localStorage.getItem(prefix+"fenStart");
}
else
this.fenStart = localStorage.getItem(prefix+"fenStart");
}
else
- this.fenStart =
fen;
+ this.fenStart =
V.ParseFen(fen).position; //this is enough
if (mode=="human")
{
// Opponent found!
if (mode=="human")
{
// Opponent found!
@@
-1168,6
+1169,8
@@
Vue.component('my-game', {
},
playComputerMove: function() {
const timeStart = Date.now();
},
playComputerMove: function() {
const timeStart = Date.now();
+ // TODO: next call asynchronous (avoid freezing interface while computer "think").
+ // This would also allow to remove some artificial setTimeouts
const compMove = this.vr.getComputerMove();
// (first move) HACK: avoid selecting elements before they appear on page:
const delay = Math.max(250-(Date.now()-timeStart), 0);
const compMove = this.vr.getComputerMove();
// (first move) HACK: avoid selecting elements before they appear on page:
const delay = Math.max(250-(Date.now()-timeStart), 0);
@@
-1375,7
+1378,18
@@
Vue.component('my-game', {
undoInGame: function() {
const lm = this.vr.lastMove;
if (!!lm)
undoInGame: function() {
const lm = this.vr.lastMove;
if (!!lm)
+ {
this.vr.undo(lm);
this.vr.undo(lm);
+ const lmBefore = this.vr.lastMove;
+ if (!!lmBefore)
+ {
+ this.vr.undo(lmBefore);
+ this.incheck = this.vr.getCheckSquares(lmBefore);
+ this.vr.play(lmBefore, "ingame");
+ }
+ else
+ this.incheck = [];
+ }
},
},
})
},
},
})