projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Typo in Minishogi
[vchess.git]
/
client
/
src
/
variants
/
Schess.js
diff --git
a/client/src/variants/Schess.js
b/client/src/variants/Schess.js
index
d2e3528
..
5f58571
100644
(file)
--- a/
client/src/variants/Schess.js
+++ b/
client/src/variants/Schess.js
@@
-1,6
+1,7
@@
import { ChessRules, PiPo } from "@/base_rules";
export class SchessRules extends ChessRules {
import { ChessRules, PiPo } from "@/base_rules";
export class SchessRules extends ChessRules {
+
static get PawnSpecs() {
return Object.assign(
{},
static get PawnSpecs() {
return Object.assign(
{},
@@
-33,10
+34,6
@@
export class SchessRules extends ChessRules {
return b;
}
return b;
}
- // TODO: maybe changes could be done to this method to show "empty"
- // instead of a piece to not use a pocket piece...
-// getPPpath(b) { }
-
static IsGoodFen(fen) {
if (!ChessRules.IsGoodFen(fen)) return false;
const fenParsed = V.ParseFen(fen);
static IsGoodFen(fen) {
if (!ChessRules.IsGoodFen(fen)) return false;
const fenParsed = V.ParseFen(fen);
@@
-54,7
+51,7
@@
export class SchessRules extends ChessRules {
setFlags(fenflags) {
super.setFlags(fenflags); //castleFlags
this.pieceFlags = {
setFlags(fenflags) {
super.setFlags(fenflags); //castleFlags
this.pieceFlags = {
- w: [...Array(8)], //p
awns can move 2 squares
?
+ w: [...Array(8)], //p
ieces can generate Hawk or Elephant
?
b: [...Array(8)]
};
const flags = fenflags.substr(4); //skip first 4 letters, for castle
b: [...Array(8)]
};
const flags = fenflags.substr(4); //skip first 4 letters, for castle
@@
-81,9
+78,9
@@
export class SchessRules extends ChessRules {
);
}
);
}
- static GenRandInitFen(
randomnes
s) {
+ static GenRandInitFen(
option
s) {
return (
return (
- ChessRules.GenRandInitFen(
randomnes
s).slice(0, -2) +
+ ChessRules.GenRandInitFen(
option
s).slice(0, -2) +
// Add pieceFlags + pocket
"1111111111111111 - 1111"
);
// Add pieceFlags + pocket
"1111111111111111 - 1111"
);
@@
-123,12
+120,12
@@
export class SchessRules extends ChessRules {
const fenParsed = V.ParseFen(fen);
this.pocket = {
"w": {
const fenParsed = V.ParseFen(fen);
this.pocket = {
"w": {
- h: parseInt(fenParsed.pocket[0]),
- e: parseInt(fenParsed.pocket[1])
+ h: parseInt(fenParsed.pocket[0]
, 10
),
+ e: parseInt(fenParsed.pocket[1]
, 10
)
},
"b": {
},
"b": {
- h: parseInt(fenParsed.pocket[2]),
- e: parseInt(fenParsed.pocket[3])
+ h: parseInt(fenParsed.pocket[2]
, 10
),
+ e: parseInt(fenParsed.pocket[3]
, 10
)
}
};
}
}
};
}
@@
-176,7
+173,8
@@
export class SchessRules extends ChessRules {
(
m.appear.length == shift+1 ||
// Special castle case: is initial king square free?
(
m.appear.length == shift+1 ||
// Special castle case: is initial king square free?
- ![m.appear[shift].y, m.appear[shift+1].y].includes(m.vanish[0].y)
+ ![m.appear[shift].y, m.appear[shift+1].y]
+ .includes(m.vanish[0].y)
)
) {
let pMove = JSON.parse(JSON.stringify(m));
)
) {
let pMove = JSON.parse(JSON.stringify(m));
@@
-193,9
+191,10
@@
export class SchessRules extends ChessRules {
}
shift = (m.appear[0].p == V.NOTHING ? 1 : 0);
if (
}
shift = (m.appear[0].p == V.NOTHING ? 1 : 0);
if (
- m.appear.length >= 2 &&
+ m.appear.length >= 2
+ shift
&&
m.vanish.length == 2 &&
m.vanish.length == 2 &&
- ![m.appear[shift].y, m.appear[shift+1].y].includes(m.vanish[1].y)
+ ![m.appear[shift].y, m.appear[shift+1].y]
+ .includes(m.vanish[1].y)
) {
// Special castle case: rook flag was necessarily on
let pMove = JSON.parse(JSON.stringify(m));
) {
// Special castle case: rook flag was necessarily on
let pMove = JSON.parse(JSON.stringify(m));
@@
-222,13
+221,13
@@
export class SchessRules extends ChessRules {
getPotentialHawkMoves(sq) {
return this.getSlideNJumpMoves(sq, V.steps[V.BISHOP]).concat(
getPotentialHawkMoves(sq) {
return this.getSlideNJumpMoves(sq, V.steps[V.BISHOP]).concat(
- this.getSlideNJumpMoves(sq, V.steps[V.KNIGHT],
"oneStep"
)
+ this.getSlideNJumpMoves(sq, V.steps[V.KNIGHT],
1
)
);
}
getPotentialElephantMoves(sq) {
return this.getSlideNJumpMoves(sq, V.steps[V.ROOK]).concat(
);
}
getPotentialElephantMoves(sq) {
return this.getSlideNJumpMoves(sq, V.steps[V.ROOK]).concat(
- this.getSlideNJumpMoves(sq, V.steps[V.KNIGHT],
"oneStep"
)
+ this.getSlideNJumpMoves(sq, V.steps[V.KNIGHT],
1
)
);
}
);
}
@@
-243,26
+242,14
@@
export class SchessRules extends ChessRules {
isAttackedByHawk(sq, color) {
return (
this.isAttackedBySlideNJump(sq, color, V.HAWK, V.steps[V.BISHOP]) ||
isAttackedByHawk(sq, color) {
return (
this.isAttackedBySlideNJump(sq, color, V.HAWK, V.steps[V.BISHOP]) ||
- this.isAttackedBySlideNJump(
- sq,
- color,
- V.HAWK,
- V.steps[V.KNIGHT],
- "oneStep"
- )
+ this.isAttackedBySlideNJump(sq, color, V.HAWK, V.steps[V.KNIGHT], 1)
);
}
isAttackedByElephant(sq, color) {
return (
this.isAttackedBySlideNJump(sq, color, V.ELEPHANT, V.steps[V.ROOK]) ||
);
}
isAttackedByElephant(sq, color) {
return (
this.isAttackedBySlideNJump(sq, color, V.ELEPHANT, V.steps[V.ROOK]) ||
- this.isAttackedBySlideNJump(
- sq,
- color,
- V.ELEPHANT,
- V.steps[V.KNIGHT],
- "oneStep"
- )
+ this.isAttackedBySlideNJump(sq, color, V.ELEPHANT, V.steps[V.KNIGHT], 1)
);
}
);
}
@@
-293,11
+280,10
@@
export class SchessRules extends ChessRules {
([V.HAWK, V.ELEPHANT, V.NOTHING].includes(move.appear[0].p) ? 1 : 0);
this.kingPos[color][0] = move.appear[shift].x;
this.kingPos[color][1] = move.appear[shift].y;
([V.HAWK, V.ELEPHANT, V.NOTHING].includes(move.appear[0].p) ? 1 : 0);
this.kingPos[color][0] = move.appear[shift].x;
this.kingPos[color][1] = move.appear[shift].y;
- return;
}
this.updateCastleFlags(move, piece);
}
this.updateCastleFlags(move, piece);
- const oppCol =
V.GetOppCol(color)
;
+ const oppCol =
this.turn
;
const firstRank = (color == 'w' ? 7 : 0);
const oppFirstRank = 7 - firstRank;
// Does this move turn off a piece init square flag?
const firstRank = (color == 'w' ? 7 : 0);
const oppFirstRank = 7 - firstRank;
// Does this move turn off a piece init square flag?
@@
-332,9
+318,11
@@
export class SchessRules extends ChessRules {
static get VALUES() {
return Object.assign(
static get VALUES() {
return Object.assign(
- {},
- ChessRules.VALUES,
- { 'h': 5, 'e': 7 }
+ {
+ 'h': 5,
+ 'e': 7
+ },
+ ChessRules.VALUES
);
}
);
}
@@
-344,7
+332,14
@@
export class SchessRules extends ChessRules {
const nothingAppear = (move.appear[0].p == V.NOTHING);
if (pPieceAppear || nothingAppear) {
let suffix = "";
const nothingAppear = (move.appear[0].p == V.NOTHING);
if (pPieceAppear || nothingAppear) {
let suffix = "";
- if (pPieceAppear) suffix = "/" + move.appear[0].p.toUpperCase();
+ if (pPieceAppear) {
+ suffix = "/" + move.appear[0].p.toUpperCase();
+ if (move.appear.length == 3) {
+ // Castling; indicate square
+ suffix +=
+ V.CoordsToSquare({ x: move.appear[0].x, y: move.appear[0].y });
+ }
+ }
let cmove = JSON.parse(JSON.stringify(move));
cmove.appear.shift();
return super.getNotation(cmove) + suffix;
let cmove = JSON.parse(JSON.stringify(move));
cmove.appear.shift();
return super.getNotation(cmove) + suffix;
@@
-352,4
+347,5
@@
export class SchessRules extends ChessRules {
}
return super.getNotation(move);
}
}
return super.getNotation(move);
}
+
};
};