projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Attempt to improve scrolling on smartphone
[vchess.git]
/
client
/
src
/
variants
/
Hamilton.js
diff --git
a/client/src/variants/Hamilton.js
b/client/src/variants/Hamilton.js
index
8c3a1bd
..
8738b28
100644
(file)
--- a/
client/src/variants/Hamilton.js
+++ b/
client/src/variants/Hamilton.js
@@
-2,6
+2,11
@@
import { ChessRules, Move, PiPo } from "@/base_rules";
import { randInt } from "@/utils/alea";
export class HamiltonRules extends ChessRules {
import { randInt } from "@/utils/alea";
export class HamiltonRules extends ChessRules {
+
+ static get Options() {
+ return null;
+ }
+
static get HasFlags() {
return false;
}
static get HasFlags() {
return false;
}
@@
-10,6
+15,10
@@
export class HamiltonRules extends ChessRules {
return false;
}
return false;
}
+ get showFirstTurn() {
+ return true;
+ }
+
static get HOLE() {
return "xx";
}
static get HOLE() {
return "xx";
}
@@
-42,7
+51,7
@@
export class HamiltonRules extends ChessRules {
for (let i = 0; i < row.length; i++) {
if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
else {
for (let i = 0; i < row.length; i++) {
if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
else {
- const num = parseInt(row[i]);
+ const num = parseInt(row[i]
, 10
);
if (isNaN(num)) return false;
sumElts += num;
}
if (isNaN(num)) return false;
sumElts += num;
}
@@
-60,6
+69,10
@@
export class HamiltonRules extends ChessRules {
return side == this.turn;
}
return side == this.turn;
}
+ hoverHighlight() {
+ return this.movesCount == 0;
+ }
+
// Initiate the game by choosing a square for the knight:
doClick(square) {
if (this.movesCount > 0) return null;
// Initiate the game by choosing a square for the knight:
doClick(square) {
if (this.movesCount > 0) return null;
@@
-77,13
+90,7
@@
export class HamiltonRules extends ChessRules {
return [...Array(64).keys()].map(k => {
const i = k % 8;
const j = (k - i) / 8;
return [...Array(64).keys()].map(k => {
const i = k % 8;
const j = (k - i) / 8;
- return new Move({
- appear: [
- new PiPo({ x: i, y: j, c: 'w', p: V.KNIGHT })
- ],
- vanish: [],
- start: { x: -1, y: -1 }
- });
+ return this.doClick([i, j]);
});
}
for (let i=0; i<8; i++) {
});
}
for (let i=0; i<8; i++) {
@@
-129,6
+136,9
@@
export class HamiltonRules extends ChessRules {
for (let psq of move.appear) board[psq.x][psq.y] = psq.c + psq.p;
}
for (let psq of move.appear) board[psq.x][psq.y] = psq.c + psq.p;
}
+ postPlay() {}
+ postUndo() {}
+
getCheckSquares() {
return [];
}
getCheckSquares() {
return [];
}
@@
-150,4
+160,5
@@
export class HamiltonRules extends ChessRules {
// First game move:
return "N@" + V.CoordsToSquare(move.end);
}
// First game move:
return "N@" + V.CoordsToSquare(move.end);
}
+
};
};