From 838699994a4a11a99ab5525f8cf54c31c018ac0f Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Thu, 30 Apr 2020 04:27:30 -0500 Subject: [PATCH] include more detail in the status messages --- js/pacosako_ui.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/pacosako_ui.js b/js/pacosako_ui.js index 1b2bad0..791d166 100644 --- a/js/pacosako_ui.js +++ b/js/pacosako_ui.js @@ -580,6 +580,9 @@ $(function (){ } function putMeta(extra) { + function player(side) { + return (side === PS.LIGHT ? 'light' : 'dark'); + } const gameId = $('#cb_board').data('gameId'); const lightName = $('#cb_light_name').val(); const darkName = $('#cb_dark_name').val(); @@ -588,10 +591,10 @@ $(function (){ const lastMove = currentGame.lastMove || {}; const lastMeta = lastMove.meta || {}; const status = - (currentGame.status === PS.PLAYING) ? '' : - (currentGame.status === PS.CHECKMATE) ? 'checkmate' : - (currentGame.status === PS.RESIGNED) ? 'resigned' : - 'ended'; + (currentGame.status === PS.PLAYING) ? `${player(currentGame.player)}'s turn` : + (currentGame.status === PS.CHECKMATE) ? `checkmate — ${player(winner)} won` : + (currentGame.status === PS.RESIGNED) ? `${player(lastMove.side)} resigned` : + 'game ended'; const meta = { lightName,