not all variants are analysable: tell the UI

This commit is contained in:
Thibault Duplessis 2015-01-22 10:48:35 +01:00
parent c4af13d7f4
commit b9357bf407
2 changed files with 13 additions and 4 deletions

View file

@ -1,6 +1,5 @@
var chessground = require('chessground');
var movableVariants = ['standard', 'chess960', 'threecheck', 'fromPosition'];
var game = require('game').game;
function makeConfig(data, situation, onMove) {
return {
@ -9,7 +8,7 @@ function makeConfig(data, situation, onMove) {
lastMove: situation.lastMove,
orientation: data.player.color,
coordinates: data.pref.coords !== 0,
viewOnly: movableVariants.indexOf(data.game.variant.key) === -1,
viewOnly: game.userAnalysableVariants.indexOf(data.game.variant.key) === -1,
movable: {
free: false,
color: situation.movable.color,

View file

@ -74,8 +74,17 @@ function hasAi(data) {
return data.player.ai || data.opponent.ai;
}
var userAnalysableVariants = [
'standard',
'fromPosition',
'chess960',
'kingOfTheHill'
];
function userAnalysable(data) {
return playable(data) && (!data.clock || !isPlayerPlaying(data));
return playable(data) &&
(!data.clock || !isPlayerPlaying(data)) &&
userAnalysableVariants.indexOf(data.game.variant.key) !== -1;
}
function setOnGame(data, color, onGame) {
@ -110,6 +119,7 @@ module.exports = {
mandatory: mandatory,
replayable: replayable,
userAnalysable: userAnalysable,
userAnalysableVariants: userAnalysableVariants,
getPlayer: getPlayer,
parsePossibleMoves: parsePossibleMoves,
nbMoves: nbMoves,