use isDark/isLight more consistently
This commit is contained in:
parent
47fc9cba08
commit
a77403484c
18
js/chess.js
18
js/chess.js
|
|
@ -70,7 +70,7 @@ function boardGet(board, where, side){
|
||||||
}
|
}
|
||||||
|
|
||||||
function boardPut(board, where, side, piece){
|
function boardPut(board, where, side, piece){
|
||||||
side = isDark(side) ? 'dark' : 'light';
|
side = normalizeSide(side);
|
||||||
var column = 'abcdefgh'.indexOf(where[0]);
|
var column = 'abcdefgh'.indexOf(where[0]);
|
||||||
var row = Number(where[1]) - 1;
|
var row = Number(where[1]) - 1;
|
||||||
var data = board[side][row];
|
var data = board[side][row];
|
||||||
|
|
@ -368,11 +368,11 @@ function renderHistory(board) {
|
||||||
const took = move.took ? 'x' : '';
|
const took = move.took ? 'x' : '';
|
||||||
result += SHY + '*' + piece + took + move.to;
|
result += SHY + '*' + piece + took + move.to;
|
||||||
} else {
|
} else {
|
||||||
if (n > 0 || move.side === 'dark') {
|
if (n > 0 || isDark(move.side)) {
|
||||||
result += ' ';
|
result += ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (move.side === 'light') {
|
if (isLight(move.side)) {
|
||||||
++n;
|
++n;
|
||||||
result += String(n) + '.' + NBSP;
|
result += String(n) + '.' + NBSP;
|
||||||
}
|
}
|
||||||
|
|
@ -380,7 +380,7 @@ function renderHistory(board) {
|
||||||
if (move.pass) {
|
if (move.pass) {
|
||||||
result += '...';
|
result += '...';
|
||||||
} else if (move.alongside) {
|
} else if (move.alongside) {
|
||||||
if (move.side === 'light') {
|
if (isLight(move.side)) {
|
||||||
result += move.type.toUpperCase() + move.alongside.toUpperCase() + move.from + move.to;
|
result += move.type.toUpperCase() + move.alongside.toUpperCase() + move.from + move.to;
|
||||||
} else {
|
} else {
|
||||||
result += move.alongside.toUpperCase() + move.type.toUpperCase() + move.from + move.to;
|
result += move.alongside.toUpperCase() + move.type.toUpperCase() + move.from + move.to;
|
||||||
|
|
@ -471,7 +471,7 @@ function renderBoard(board){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var clss = board.player === 'light' ? '.cb-lt-piece' : '.cb-dk-piece';
|
var clss = isLight(board.player) ? '.cb-lt-piece' : '.cb-dk-piece';
|
||||||
|
|
||||||
if (board.phantom) {
|
if (board.phantom) {
|
||||||
var where = board.phantom.from;
|
var where = board.phantom.from;
|
||||||
|
|
@ -497,9 +497,9 @@ function renderBoard(board){
|
||||||
|
|
||||||
var msg = '';
|
var msg = '';
|
||||||
if (board.move && board.move.took === 'k') {
|
if (board.move && board.move.took === 'k') {
|
||||||
msg = (board.move.side[0] === 'd' ? 'Dark' : 'Light') + ' player won!';
|
msg = (isDark(board.move.side) ? 'Dark' : 'Light') + ' player won!';
|
||||||
} else {
|
} else {
|
||||||
msg = (board.player[0] === 'd' ? 'Dark' : 'Light') + " player's move";
|
msg = (isDark(board.player) ? 'Dark' : 'Light') + " player's move";
|
||||||
}
|
}
|
||||||
$('#cb_message').text(msg);
|
$('#cb_message').text(msg);
|
||||||
|
|
||||||
|
|
@ -615,9 +615,9 @@ function switchGameId(newId){
|
||||||
/* ignore partial moves and undo/redo */
|
/* ignore partial moves and undo/redo */
|
||||||
if (!board.phantom && !board.subsequent) {
|
if (!board.phantom && !board.subsequent) {
|
||||||
if (board.move && board.move.took === 'k') {
|
if (board.move && board.move.took === 'k') {
|
||||||
notify((board.move.side[0] === 'd' ? 'Dark' : 'Light') + ' player won!');
|
notify((isDark(board.move.side) ? 'Dark' : 'Light') + ' player won!');
|
||||||
} else {
|
} else {
|
||||||
notify((board.player[0] === 'd' ? 'Dark' : 'Light') + ' player\'s turn');
|
notify((isDark(board.player) ? 'Dark' : 'Light') + ' player\'s turn');
|
||||||
}
|
}
|
||||||
$('#cb_board').data('skip_notify', d.board);
|
$('#cb_board').data('skip_notify', d.board);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue