X-Git-Url: https://git.auder.net/pieces/Checkered/cn.svg?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FMarseille.js;h=1adb83f4642ee28f41c9d4482fe29de8ca550a80;hb=26b8e4f7c71030d49e44fe1d89632ef91b886d67;hp=2eb42606756a4256fb80f33ec5e4698f0eee426c;hpb=0596f5e7f9a87acbb13445f1bb93e803e9f5ea3c;p=vchess.git
diff --git a/public/javascripts/variants/Marseille.js b/public/javascripts/variants/Marseille.js
index 2eb42606..1adb83f4 100644
--- a/public/javascripts/variants/Marseille.js
+++ b/public/javascripts/variants/Marseille.js
@@ -70,7 +70,6 @@ class MarseilleRules extends ChessRules
const firstRank = (color == 'w' ? sizeX-1 : 0);
const startRank = (color == "w" ? sizeX-2 : 1);
const lastRank = (color == "w" ? 0 : sizeX-1);
- const pawnColor = this.getColor(x,y); //can be different for checkered
const finalPieces = x + shiftX == lastRank
? [V.ROOK,V.KNIGHT,V.BISHOP,V.QUEEN]
: [V.PAWN];
@@ -81,7 +80,7 @@ class MarseilleRules extends ChessRules
for (let piece of finalPieces)
{
moves.push(this.getBasicMove([x,y], [x+shiftX,y],
- {c:pawnColor,p:piece}));
+ {c:color,p:piece}));
}
// Next condition because pawns on 1st rank can generally jump
if ([startRank,firstRank].includes(x)
@@ -101,7 +100,7 @@ class MarseilleRules extends ChessRules
for (let piece of finalPieces)
{
moves.push(this.getBasicMove([x,y], [x+shiftX,y+shiftY],
- {c:pawnColor,p:piece}));
+ {c:color,p:piece}));
}
}
}
@@ -118,6 +117,7 @@ class MarseilleRules extends ChessRules
});
if (epSqs.length == 0)
return moves;
+ const oppCol = V.GetOppCol(color);
for (let sq of epSqs)
{
if (this.subTurn == 1 || (epSqs.length == 2 &&
@@ -125,14 +125,16 @@ class MarseilleRules extends ChessRules
// (Or maybe the opponent filled the en-passant square with a piece)
this.board[epSqs[0].x][epSqs[0].y] != V.EMPTY))
{
- if (sq.x == x+shiftX && Math.abs(sq.y - y) == 1)
+ if (sq.x == x+shiftX && Math.abs(sq.y - y) == 1
+ // Add condition "enemy pawn must be present"
+ && this.getPiece(x,sq.y) == V.PAWN && this.getColor(x,sq.y) == oppCol)
{
let epMove = this.getBasicMove([x,y], [sq.x,sq.y]);
epMove.vanish.push({
x: x,
y: sq.y,
p: 'p',
- c: this.getColor(x,sq.y)
+ c: oppCol
});
moves.push(epMove);
}
@@ -159,9 +161,9 @@ class MarseilleRules extends ChessRules
this.epSquares.push([epSq]);
}
// Does this move give check on subturn 1? If yes, skip subturn 2
- else if (this.subTurn==1 && this.underCheck(this.getOppCol(this.turn)))
+ else if (this.subTurn==1 && this.underCheck(V.GetOppCol(this.turn)))
{
- this.turn = this.getOppCol(this.turn);
+ this.turn = V.GetOppCol(this.turn);
this.epSquares.push([epSq]);
move.checkOnSubturn1 = true;
}
@@ -169,7 +171,7 @@ class MarseilleRules extends ChessRules
{
if (this.subTurn == 2)
{
- this.turn = this.getOppCol(this.turn);
+ this.turn = V.GetOppCol(this.turn);
let lastEpsq = this.epSquares[this.epSquares.length-1];
lastEpsq.push(epSq);
}
@@ -194,7 +196,7 @@ class MarseilleRules extends ChessRules
}
else if (move.checkOnSubturn1)
{
- this.turn = this.getOppCol(this.turn);
+ this.turn = V.GetOppCol(this.turn);
this.subTurn = 1;
this.epSquares.pop();
}
@@ -202,7 +204,7 @@ class MarseilleRules extends ChessRules
{
if (this.subTurn == 1)
{
- this.turn = this.getOppCol(this.turn);
+ this.turn = V.GetOppCol(this.turn);
let lastEpsq = this.epSquares[this.epSquares.length-1];
lastEpsq.pop();
}
@@ -237,7 +239,7 @@ class MarseilleRules extends ChessRules
const maxeval = V.INFINITY;
const color = this.turn;
- const oppCol = this.getOppCol(this.turn);
+ const oppCol = V.GetOppCol(this.turn);
// Search best (half) move for opponent turn
const getBestMoveEval = () => {
@@ -320,15 +322,21 @@ class MarseilleRules extends ChessRules
getPGN(mycolor, score, fenStart, mode)
{
let pgn = "";
- pgn += '[Site "vchess.club"]
';
+ pgn += '[Site "vchess.club"]\n';
const opponent = mode=="human" ? "Anonymous" : "Computer";
- pgn += '[Variant "' + variant + '"]
';
- pgn += '[Date "' + getDate(new Date()) + '"]
';
- pgn += '[White "' + (mycolor=='w'?'Myself':opponent) + '"]
';
- pgn += '[Black "' + (mycolor=='b'?'Myself':opponent) + '"]
';
- pgn += '[FenStart "' + fenStart + '"]
';
- pgn += '[Fen "' + this.getFen() + '"]
';
- pgn += '[Result "' + score + '"]
';
+ pgn += '[Variant "' + variant + '"]\n';
+ pgn += '[Date "' + getDate(new Date()) + '"]\n';
+ const whiteName = ["human","computer"].includes(mode)
+ ? (mycolor=='w'?'Myself':opponent)
+ : "analyze";
+ const blackName = ["human","computer"].includes(mode)
+ ? (mycolor=='b'?'Myself':opponent)
+ : "analyze";
+ pgn += '[White "' + whiteName + '"]\n';
+ pgn += '[Black "' + blackName + '"]\n';
+ pgn += '[FenStart "' + fenStart + '"]\n';
+ pgn += '[Fen "' + this.getFen() + '"]\n';
+ pgn += '[Result "' + score + '"]\n\n';
let counter = 1;
let i = 0;
@@ -344,7 +352,7 @@ class MarseilleRules extends ChessRules
pgn += move + (i < this.moves.length-1 ? " " : "");
}
}
- pgn += "
";
+ pgn += "\n\n";
// "Complete moves" PGN (helping in ambiguous cases)
counter = 1;
@@ -362,7 +370,7 @@ class MarseilleRules extends ChessRules
}
}
- return pgn;
+ return pgn + "\n";
}
}