projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
On the way to problems: saving state [not functional yet]
[vchess.git]
/
public
/
javascripts
/
components
/
game.js
diff --git
a/public/javascripts/components/game.js
b/public/javascripts/components/game.js
index
202f542
..
278e078
100644
(file)
--- a/
public/javascripts/components/game.js
+++ b/
public/javascripts/components/game.js
@@
-24,7
+24,7
@@
Vue.component('my-game', {
};
},
render(h) {
};
},
render(h) {
- const [sizeX,sizeY] =
VariantRules.size
;
+ const [sizeX,sizeY] =
[V.size.x,V.size.y]
;
const smallScreen = (window.innerWidth <= 420);
// Precompute hints squares to facilitate rendering
let hintSquares = doubleArray(sizeX, sizeY, false);
const smallScreen = (window.innerWidth <= 420);
// Precompute hints squares to facilitate rendering
let hintSquares = doubleArray(sizeX, sizeY, false);
@@
-409,7
+409,7
@@
Vue.component('my-game', {
}),
h('div',
{
}),
h('div',
{
- attrs: { "role": "dialog", "aria-labelledby": "
modal-eog
" },
+ attrs: { "role": "dialog", "aria-labelledby": "
eogMessage
" },
},
[
h('div',
},
[
h('div',
@@
-425,6
+425,7
@@
Vue.component('my-game', {
),
h('h3',
{
),
h('h3',
{
+ attrs: { "id": "eogMessage" },
"class": { "section": true },
domProps: { innerHTML: eogMessage },
}
"class": { "section": true },
domProps: { innerHTML: eogMessage },
}
@@
-445,7
+446,7
@@
Vue.component('my-game', {
}),
h('div',
{
}),
h('div',
{
- attrs: { "role": "dialog", "aria-labelledby": "
modal-newgame
" },
+ attrs: { "role": "dialog", "aria-labelledby": "
newGameTxt
" },
},
[
h('div',
},
[
h('div',
@@
-461,6
+462,7
@@
Vue.component('my-game', {
),
h('h3',
{
),
h('h3',
{
+ attrs: { "id": "newGameTxt" },
"class": { "section": true },
domProps: { innerHTML: "New game" },
}
"class": { "section": true },
domProps: { innerHTML: "New game" },
}
@@
-485,7
+487,7
@@
Vue.component('my-game', {
}),
h('div',
{
}),
h('div',
{
- attrs: { "role": "dialog", "aria-labelledby": "
modal-f
enedit" },
+ attrs: { "role": "dialog", "aria-labelledby": "
titleF
enedit" },
},
[
h('div',
},
[
h('div',
@@
-501,6
+503,7
@@
Vue.component('my-game', {
),
h('h3',
{
),
h('h3',
{
+ attrs: { "id": "titleFenedit" },
"class": { "section": true },
domProps: { innerHTML: "Position + flags (FEN):" },
}
"class": { "section": true },
domProps: { innerHTML: "Position + flags (FEN):" },
}
@@
-551,7
+554,7
@@
Vue.component('my-game', {
}),
h('div',
{
}),
h('div',
{
- attrs: { "role": "dialog", "aria-labelledby": "
modal-settings
" },
+ attrs: { "role": "dialog", "aria-labelledby": "
settingsTitle
" },
},
[
h('div',
},
[
h('div',
@@
-567,6
+570,7
@@
Vue.component('my-game', {
),
h('h3',
{
),
h('h3',
{
+ attrs: { "id": "settingsTitle" },
"class": { "section": true },
domProps: { innerHTML: "Preferences" },
}
"class": { "section": true },
domProps: { innerHTML: "Preferences" },
}
@@
-1014,7
+1018,7
@@
Vue.component('my-game', {
this.endGame(this.mycolor=="w"?"0-1":"1-0");
},
newGame: function(mode, fenInit, color, oppId, moves, continuation) {
this.endGame(this.mycolor=="w"?"0-1":"1-0");
},
newGame: function(mode, fenInit, color, oppId, moves, continuation) {
- const fen =
"3N1K2/2n2q2/P1R1kPnN/p3b1p1/b7/5Q2/4r3/8 0000";//
fenInit || VariantRules.GenRandInitFen();
+ const fen = fenInit || VariantRules.GenRandInitFen();
console.log(fen); //DEBUG
if (mode=="human" && !oppId)
{
console.log(fen); //DEBUG
if (mode=="human" && !oppId)
{
@@
-1072,7
+1076,7
@@
Vue.component('my-game', {
}
else if (mode == "computer")
{
}
else if (mode == "computer")
{
- this.mycolor =
"w";//
Math.random() < 0.5 ? 'w' : 'b';
+ this.mycolor = Math.random() < 0.5 ? 'w' : 'b';
if (this.mycolor == 'b')
setTimeout(this.playComputerMove, 500);
}
if (this.mycolor == 'b')
setTimeout(this.playComputerMove, 500);
}
@@
-1083,7
+1087,10
@@
Vue.component('my-game', {
const compMove = this.vr.getComputerMove();
// (first move) HACK: avoid selecting elements before they appear on page:
const delay = Math.max(500-(Date.now()-timeStart), 0);
const compMove = this.vr.getComputerMove();
// (first move) HACK: avoid selecting elements before they appear on page:
const delay = Math.max(500-(Date.now()-timeStart), 0);
- setTimeout(() => this.play(compMove, "animate"), delay);
+ setTimeout(() => {
+ if (this.mode == "computer") //Warning: mode could have changed!
+ this.play(compMove, "animate")
+ }, delay);
},
// Get the identifier of a HTML table cell from its numeric coordinates o.x,o.y.
getSquareId: function(o) {
},
// Get the identifier of a HTML table cell from its numeric coordinates o.x,o.y.
getSquareId: function(o) {