use autoswitch in correspondence games only

This commit is contained in:
Thibault Duplessis 2015-09-21 11:54:18 +02:00
parent a6a5343f5b
commit 043a40ff3d
2 changed files with 7 additions and 2 deletions

View file

@ -83,6 +83,10 @@ function forecastable(data) {
return playable(data) && data.correspondence && !hasAi(data) && !isPlayerTurn(data);
}
function isCorrespondence(data) {
return data.game.speed === 'correspondence';
}
function setOnGame(data, color, onGame) {
var player = getPlayer(data, color);
onGame = onGame || player.ai;
@ -118,5 +122,6 @@ module.exports = {
nbMoves: nbMoves,
setOnGame: setOnGame,
setIsGone: setIsGone,
forecastable: forecastable
forecastable: forecastable,
isCorrespondence: isCorrespondence
};

View file

@ -35,7 +35,7 @@ module.exports = function(ctrl, key) {
};
this.next = function(force) {
if (!this.value || ctrl.data.player.spectator || ctrl.data.game.tournamentId || game.isPlayerTurn(ctrl.data)) return;
if (!this.value || ctrl.data.player.spectator || !game.isCorrespondence(ctrl.data) || game.isPlayerTurn(ctrl.data)) return;
if (force) redirect('/round-next/' + ctrl.data.game.id);
else if (ctrl.data.simul) {
if (ctrl.data.simul.hostId === ctrl.userId && ctrl.data.simul.nbPlaying > 1)