projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TODO: debug auto mode (newmove event not triggered?). Then corr
[vchess.git]
/
client
/
src
/
components
/
Board.vue
diff --git
a/client/src/components/Board.vue
b/client/src/components/Board.vue
index
8b1055b
..
f97a2c5
100644
(file)
--- a/
client/src/components/Board.vue
+++ b/
client/src/components/Board.vue
@@
-1,8
+1,5
@@
<script>
<script>
-// This can work for squared boards (2 or 4 players), with some adaptations (TODO)
-// TODO: for 3 players, write a "board3.js"
-
-// TODO: current clicked square + moving square as parameters, + highlight
+// TODO: BoardHex for hexagonal variants (2 players)
import { getSquareId, getSquareFromId } from "@/utils/squareId";
import { ArrayFun } from "@/utils/array";
import { getSquareId, getSquareFromId } from "@/utils/squareId";
import { ArrayFun } from "@/utils/array";
@@
-11,7
+8,7
@@
export default {
name: 'my-board',
// Last move cannot be guessed from here, and is required to highlight squares
// vr: object to check moves, print board...
name: 'my-board',
// Last move cannot be guessed from here, and is required to highlight squares
// vr: object to check moves, print board...
- // userColor
: for mode HH or HC
+ // userColor
is left undefined for an external observer
props: ["vr","lastMove","analyze","orientation","userColor","vname"],
data: function () {
return {
props: ["vr","lastMove","analyze","orientation","userColor","vname"],
data: function () {
return {
@@
-41,7
+38,7
@@
export default {
attrs: { "id": "choices" },
'class': { 'row': true },
style: {
attrs: { "id": "choices" },
'class': { 'row': true },
style: {
- "display":
this.choices.length>0?"block":"none"
,
+ "display":
(this.choices.length > 0 ? "block" : "none")
,
"top": "-" + ((sizeY/2)*squareWidth+squareWidth/2) + "px",
"width": (this.choices.length * squareWidth) + "px",
"height": squareWidth + "px",
"top": "-" + ((sizeY/2)*squareWidth+squareWidth/2) + "px",
"width": (this.choices.length * squareWidth) + "px",
"height": squareWidth + "px",
@@
-99,8
+96,8
@@
export default {
let cj = (this.orientation=='w' ? j : sizeY-j-1);
let elems = [];
if (this.vr.board[ci][cj] != V.EMPTY && (this.vname!="Dark"
let cj = (this.orientation=='w' ? j : sizeY-j-1);
let elems = [];
if (this.vr.board[ci][cj] != V.EMPTY && (this.vname!="Dark"
- || this.
gameOver || this.analyze
-
|| this.vr.enlightened[this.userColor][ci][cj]
))
+ || this.
analyze || (!!this.userColor
+
&& this.vr.enlightened[this.userColor][ci][cj])
))
{
elems.push(
h(
{
elems.push(
h(
@@
-144,8
+141,9
@@
export default {
'light-square': (i+j)%2==0,
'dark-square': (i+j)%2==1,
[this.bcolor]: true,
'light-square': (i+j)%2==0,
'dark-square': (i+j)%2==1,
[this.bcolor]: true,
- 'in-shadow': this.vname=="Dark" && !this.gameOver
- && !this.analyze && !this.vr.enlightened[this.userColor][ci][cj],
+ 'in-shadow': this.vname=="Dark" && !this.analyze
+ && (!this.userColor
+ || !this.vr.enlightened[this.userColor][ci][cj]),
'highlight': showLight && !!lm && lm.end.x == ci && lm.end.y == cj,
'incheck': showLight && incheckSq[ci][cj],
},
'highlight': showLight && !!lm && lm.end.x == ci && lm.end.y == cj,
'incheck': showLight && incheckSq[ci][cj],
},
@@
-159,10
+157,11
@@
export default {
);
})
);
);
})
);
+ const playingColor = this.userColor || "w"; //default for an observer
let elementArray = [choices, gameDiv];
if (!!this.vr.reserve)
{
let elementArray = [choices, gameDiv];
if (!!this.vr.reserve)
{
- const shiftIdx = (
this.user
Color=="w" ? 0 : 1);
+ const shiftIdx = (
playing
Color=="w" ? 0 : 1);
let myReservePiecesArray = [];
for (let i=0; i<V.RESERVE_PIECES.length; i++)
{
let myReservePiecesArray = [];
for (let i=0; i<V.RESERVE_PIECES.length; i++)
{
@@
-177,17
+176,17
@@
export default {
'class': {"piece":true, "reserve":true},
attrs: {
"src": "/images/pieces/" +
'class': {"piece":true, "reserve":true},
attrs: {
"src": "/images/pieces/" +
- this.vr.getReservePpath(
this.user
Color,i) + ".svg",
+ this.vr.getReservePpath(
playing
Color,i) + ".svg",
}
}),
h('sup',
{"class": { "reserve-count": true } },
}
}),
h('sup',
{"class": { "reserve-count": true } },
- [ this.vr.reserve[
this.user
Color][V.RESERVE_PIECES[i]] ]
+ [ this.vr.reserve[
playing
Color][V.RESERVE_PIECES[i]] ]
)
]));
}
let oppReservePiecesArray = [];
)
]));
}
let oppReservePiecesArray = [];
- const oppCol = V.GetOppCol(
this.user
Color);
+ const oppCol = V.GetOppCol(
playing
Color);
for (let i=0; i<V.RESERVE_PIECES.length; i++)
{
oppReservePiecesArray.push(h('div',
for (let i=0; i<V.RESERVE_PIECES.length; i++)
{
oppReservePiecesArray.push(h('div',
@@
-291,7
+290,7
@@
export default {
this.selectedPiece.style.zIndex = 3000;
const startSquare = getSquareFromId(e.target.parentNode.id);
this.possibleMoves = [];
this.selectedPiece.style.zIndex = 3000;
const startSquare = getSquareFromId(e.target.parentNode.id);
this.possibleMoves = [];
- const color = (this.analyze
|| this.gameOver
? this.vr.turn : this.userColor);
+ const color = (this.analyze ? this.vr.turn : this.userColor);
if (this.vr.canIplay(color,startSquare))
this.possibleMoves = this.vr.getPossibleMovesFrom(startSquare);
// Next line add moving piece just after current image
if (this.vr.canIplay(color,startSquare))
this.possibleMoves = this.vr.getPossibleMovesFrom(startSquare);
// Next line add moving piece just after current image