From 5c42c64e0b43ad4d687c58a6b7e9b9ac5d212e17 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Wed, 28 Nov 2018 17:28:13 +0100 Subject: [PATCH] Fixed Crazyhouse; still have to keep track of promoted pawns --- TODO | 1 + public/javascripts/components/game.js | 73 +++++++++++++++++------ public/javascripts/variants/Crazyhouse.js | 33 ++++++++-- views/rules/Crazyhouse.pug | 2 + 4 files changed, 85 insertions(+), 24 deletions(-) diff --git a/TODO b/TODO index fe7d8473..58906a83 100644 --- a/TODO +++ b/TODO @@ -4,3 +4,4 @@ setInterval "CRON" task in sockets.js to check connected clients (every 1hour maybe, or more) Systematically show init+dest squares in PGN, maybe after short notation (2 moves list, second for de-ambiguification) +Crazyhouse: keep track of promoted pawns. diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 2897b1cd..f5bef8ef 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -240,38 +240,75 @@ Vue.component('my-game', { ); } elementArray.push(gameDiv); - if (!!this.vr.reserve) //TODO: table, show counts for reserve pieces - // - // 3 + if (!!this.vr.reserve) { - let reservePiecesArray = []; + let myReservePiecesArray = []; for (let i=0; i 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: @@ -52,11 +68,13 @@ class CrazyhouseRules extends ChessRules if (this.reserve[color][p] == 0) return []; let moves = []; - for (let i=0; i