prevent autoswitch when opponent premoved - closes #1074

pull/1113/head
Thibault Duplessis 2015-10-05 23:52:41 +02:00
parent 206dd3292c
commit 598a06604a
3 changed files with 8 additions and 5 deletions

View File

@ -111,9 +111,12 @@ object Round extends LilaController with TheftPrevention {
}
}
def whatsNext(gameId: String) = Open { implicit ctx =>
OptionFuResult(GameRepo game gameId) { currentGame =>
otherPovs(currentGame) map getNext(currentGame) map { next =>
def whatsNext(fullId: String) = Open { implicit ctx =>
OptionFuResult(GameRepo pov fullId) { currentPov =>
if (currentPov.isMyTurn) fuccess {
Ok(Json.obj("next" -> null))
}
else otherPovs(currentPov.game) map getNext(currentPov.game) map { next =>
Ok(Json.obj("next" -> next.map(_.fullId)))
}
}

View File

@ -132,7 +132,7 @@ POST /$fullId<\w{12}>/resign controllers.Round.resign(fullId
POST /$gameId<\w{8}>/delete controllers.Game.delete(gameId: String)
GET /round-next/$gameId<\w{8}> controllers.Round.next(gameId: String)
GET /whats-next/$gameId<\w{8}> controllers.Round.whatsNext(gameId: String)
GET /whats-next/$fullId<\w{12}> controllers.Round.whatsNext(fullId: String)
# Round accessibility: text representation
GET /$fullId<\w{12}>/text controllers.Round.playerText(fullId: String)

View File

@ -25,7 +25,7 @@ function reload(ctrl) {
function whatsNext(ctrl) {
return m.request({
method: 'GET',
url: uncache('/whats-next/' + ctrl.data.game.id),
url: uncache('/whats-next/' + ctrl.data.game.id + ctrl.data.player.id),
config: xhrConfig
});
}