+ if (!!this.vr.reserve[playingColor]) {
+ for (let i = 0; i < V.RESERVE_PIECES.length; i++) {
+ const qty = this.vr.reserve[playingColor][V.RESERVE_PIECES[i]];
+ myReservePiecesArray.push(
+ h(
+ "div",
+ {
+ "class": { board: true, ["board" + reserveSquareNb]: true },
+ attrs: { id: getSquareId({ x: sizeX + shiftIdx, y: i }) },
+ style: { opacity: qty > 0 ? 1 : 0.35 }
+ },
+ [
+ h("img", {
+ // NOTE: class "reserve" not used currently
+ "class": { piece: true, reserve: true },
+ attrs: {
+ src:
+ "/images/pieces/" +
+ this.vr.getReservePpath(i, playingColor, orientation) +
+ ".svg"
+ }
+ }),
+ h(
+ "sup",
+ {
+ "class": { "reserve-count": true },
+ style: { top: "calc(100% + 5px)" }
+ },
+ [ qty ]
+ )
+ ]
+ )
+ );
+ }
+ }
+ let oppReservePiecesArray = [];
+ const oppCol = V.GetOppCol(playingColor);
+ if (!!this.vr.reserve[oppCol]) {
+ for (let i = 0; i < V.RESERVE_PIECES.length; i++) {
+ const qty = this.vr.reserve[oppCol][V.RESERVE_PIECES[i]];
+ oppReservePiecesArray.push(
+ h(
+ "div",
+ {
+ "class": { board: true, ["board" + reserveSquareNb]: true },
+ attrs: { id: getSquareId({ x: sizeX + (1 - shiftIdx), y: i }) },
+ style: { opacity: qty > 0 ? 1 : 0.35 }
+ },
+ [
+ h("img", {
+ "class": { piece: true, reserve: true },
+ attrs: {
+ src:
+ "/images/pieces/" +
+ this.vr.getReservePpath(i, oppCol, orientation) +
+ ".svg"
+ }
+ }),
+ h(
+ "sup",
+ {
+ "class": { "reserve-count": true },
+ style: { top: "calc(100% + 5px)" }
+ },
+ [ qty ]
+ )
+ ]
+ )
+ );
+ }
+ }
+ const myReserveTop = (
+ (playingColor == 'w' && orientation == 'b') ||
+ (playingColor == 'b' && orientation == 'w')
+ );
+ const hasReserveTop = (
+ (myReserveTop && !!this.vr.reserve[playingColor]) ||
+ (!myReserveTop && !!this.vr.reserve[oppCol])
+ );
+ // "var" because must be reachable from outside this block
+ var hasReserveBottom = (
+ (myReserveTop && !!this.vr.reserve[oppCol]) ||
+ (!myReserveTop && !!this.vr.reserve[playingColor])
+ );
+ // Center reserves, assuming same number of pieces for each side:
+ const nbReservePieces = myReservePiecesArray.length;
+ const marginLeft =
+ ((100 - nbReservePieces * (100 / reserveSquareNb)) / 2) + "%";
+ if (hasReserveTop) {
+ var reserveTop =