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

View file

@ -74,8 +74,17 @@ function hasAi(data) {
return data.player.ai || data.opponent.ai; return data.player.ai || data.opponent.ai;
} }
var userAnalysableVariants = [
'standard',
'fromPosition',
'chess960',
'kingOfTheHill'
];
function userAnalysable(data) { 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) { function setOnGame(data, color, onGame) {
@ -110,6 +119,7 @@ module.exports = {
mandatory: mandatory, mandatory: mandatory,
replayable: replayable, replayable: replayable,
userAnalysable: userAnalysable, userAnalysable: userAnalysable,
userAnalysableVariants: userAnalysableVariants,
getPlayer: getPlayer, getPlayer: getPlayer,
parsePossibleMoves: parsePossibleMoves, parsePossibleMoves: parsePossibleMoves,
nbMoves: nbMoves, nbMoves: nbMoves,