not all variants are analysable: tell the UI
This commit is contained in:
parent
c4af13d7f4
commit
b9357bf407
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue