);
}
elementArray.push(gameDiv);
- if (!!this.vr.reserve) //TODO: table, show counts for reserve pieces
- //<tr style="padding:0">
- // <td style="padding:0;font-size:10px">3</td>
+ if (!!this.vr.reserve)
{
- let reservePiecesArray = [];
+ let myReservePiecesArray = [];
for (let i=0; i<VariantRules.RESERVE_PIECES.length; i++)
{
- reservePiecesArray.push(h('img',
+ myReservePiecesArray.push(h('div',
+ {
+ 'class': {'board':true, ['board'+sizeY]:true},
+ attrs: { id: this.getSquareId({x:sizeX,y:i}) }
+ },
+ [
+ h('img',
{
'class': {"piece":true},
attrs: {
"src": "/images/pieces/" +
this.vr.getReservePpath(this.mycolor,i) + ".svg",
- id: this.getSquareId({x:sizeX,y:i}),
}
- })
- );
+ }),
+ h('sup',
+ {style: { "padding-left":"40%"} },
+ [ this.vr.reserve[this.mycolor][VariantRules.RESERVE_PIECES[i]] ]
+ )
+ ]));
}
- let reserve = h('div',
- {'class':{'game':true}}, [
+ let oppReservePiecesArray = [];
+ const oppCol = this.vr.getOppCol(this.mycolor);
+ for (let i=0; i<VariantRules.RESERVE_PIECES.length; i++)
+ {
+ oppReservePiecesArray.push(h('div',
+ {
+ 'class': {'board':true, ['board'+sizeY]:true},
+ attrs: { id: this.getSquareId({x:sizeX,y:i}) }
+ },
+ [
+ h('img',
+ {
+ 'class': {"piece":true},
+ attrs: {
+ "src": "/images/pieces/" +
+ this.vr.getReservePpath(oppCol,i) + ".svg",
+ }
+ }),
+ h('sup',
+ {style: { "padding-left":"40%"} },
+ [ this.vr.reserve[oppCol][VariantRules.RESERVE_PIECES[i]] ]
+ )
+ ]));
+ }
+ let reserves = h('div',
+ {
+ 'class':{'game':true},
+ style: {"margin-bottom": "20px"},
+ },
+ [
+ h('div',
+ {
+ 'class': { 'row': true },
+ style: {"margin-bottom": "15px"},
+ },
+ myReservePiecesArray
+ ),
h('div',
{ 'class': { 'row': true }},
- [
- h('div',
- {'class':{'board':true, ['board'+sizeY]:true}},
- reservePiecesArray
- )
- ]
+ oppReservePiecesArray
)
- ],
+ ]
);
- elementArray.push(reserve);
+ elementArray.push(reserves);
}
const eogMessage = this.getEndgameMessage(this.score);
const modalEog = [
else if (m.vanish.length == 0)
this.reserve[m.appear[0].c][m.appear[0].p]--;
});
+ // TODO: keep track of promoted pawns ==> give a pawn if captured.
+ }
+
+ getColor(i,j)
+ {
+ const sizeX = VariantRules.size[0];
+ if (i >= sizeX)
+ return (i==sizeX ? "w" : "b");
+ return this.board[i][j].charAt(0);
+ }
+ getPiece(i,j)
+ {
+ const sizeX = VariantRules.size[0];
+ if (i >= sizeX)
+ return VariantRules.RESERVE_PIECES[j];
+ return this.board[i][j].charAt(1);
}
// Used by the interface:
if (this.reserve[color][p] == 0)
return [];
let moves = [];
- for (let i=0; i<sizeX; i++)
+ const [sizeX,sizeY] = VariantRules.size;
+ const pawnShift = (p==VariantRules.PAWN ? 1 : 0);
+ for (let i=pawnShift; i<sizeX-pawnShift; i++)
{
for (let j=0; j<sizeY; j++)
{
- if (this.board[i][j] != VariantRules.EMPTY)
+ if (this.board[i][j] == VariantRules.EMPTY)
{
let mv = new Move({
appear: [
c: color,
p: p
})
- ]
+ ],
+ vanish: [],
+ start: {x:sizeX, y:y}, //a bit artificial...
+ end: {x:i, y:j}
});
moves.push(mv);
}
super.updateVariables(move);
const color = this.turn;
if (move.vanish.length==2)
- this.reserve[color][move.appear[0].p]++;
+ this.reserve[color][move.vanish[1].p]++;
if (move.vanish.length==0)
this.reserve[color][move.appear[0].p]--;
}
super.unupdateVariables(move);
const color = this.turn;
if (move.vanish.length==2)
- this.reserve[color][move.appear[0].p]--;
+ this.reserve[color][move.vanish[1].p]--;
if (move.vanish.length==0)
this.reserve[color][move.appear[0].p]++;
}
return super.getNotation(move);
// Rebirth:
const piece =
- (move.appear[0].p != VariantRules.PAWN ? move.appear.p.toUpperCase() : "");
+ (move.appear[0].p != VariantRules.PAWN ? move.appear[0].p.toUpperCase() : "");
const finalSquare =
String.fromCharCode(97 + move.end.y) + (VariantRules.size[0]-move.end.x);
return piece + "@" + finalSquare;