aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-09-23 10:35:37 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-09-23 10:35:37 -1000
commit7fffac329b2718f0ea918cd9fd53d3e2b47cc93e (patch)
tree0a732600f1a8b767e43b54726326e4f94f395a53 /lib
parent6a3032b17d025bd77eb816648c49ffc01d7a8361 (diff)
downloadpatchfoo-7fffac329b2718f0ea918cd9fd53d3e2b47cc93e.tar.gz
patchfoo-7fffac329b2718f0ea918cd9fd53d3e2b47cc93e.zip
Render chess resigned
Diffstat (limited to 'lib')
-rw-r--r--lib/render-msg.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 1cb0936..9b69603 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -1045,7 +1045,7 @@ function chessLocToIdxs(loc) {
function lookupPiece(board, loc) {
var idxs = chessLocToIdxs(loc)
- return board[idxs[0]] && board[idxs[0]][idxs[1]]
+ return idxs && board[idxs[0]] && board[idxs[0]][idxs[1]]
}
function chessIdxsToLoc(i, j) {
@@ -1053,6 +1053,7 @@ function chessIdxsToLoc(i, j) {
}
RenderMsg.prototype.chessBoard = function (board) {
+ if (!board) return ''
return h('table.chess-board',
board.map(function (rank, i) {
return h('tr', rank.map(function (piece, j) {
@@ -1112,6 +1113,14 @@ RenderMsg.prototype.chessInviteAccept = function (cb) {
RenderMsg.prototype.chessGameEnd = function (cb) {
var self = this
var c = self.c
+ if (c.status === 'resigned') return self.link(self.c.root, function (err, rootLink) {
+ if (err) return cb(err)
+ self.wrap([
+ h('div', h('small', '> ', rootLink)),
+ h('p', h('strong', 'resigned'))
+ ], cb)
+ })
+
var fen = c.fen && c.fen.length === 2 ? c.pgnMove : c.fen
var game = parseChess(fen)
var piece = game && lookupPiece(game.board, c.dest)