Can't do a move on non-playable game

pull/1/merge
Thibault Duplessis 2012-03-04 16:59:39 +01:00
parent 661f5891c0
commit 62b82e91af
2 changed files with 6 additions and 3 deletions

View File

@ -17,11 +17,12 @@ final class Server(repo: GameRepo) {
promotion Role promotable promString toValid "Wrong promotion " + promString
gameAndPlayer repo player fullId toValid "Wrong ID " + fullId
(g1, _) = gameAndPlayer
chessGame = g1.toChess
g2 if (g1.playable) success(g1) else failure("Game is not playable" wrapNel)
chessGame = g2.toChess
newChessGameAndMove chessGame(orig, dest, promotion)
(newChessGame, move) = newChessGameAndMove
g2 = g1.update(newChessGame, move)
result unsafe { repo save g2 }
g3 = g2.update(newChessGame, move)
result unsafe { repo save g3 }
} yield newChessGame.situation.destinations
private def moveToEvents(move: Move): Map[DbPlayer, EventStack] = Map.empty

View File

@ -114,6 +114,8 @@ case class DbGame(
else status
)
}
def playable = status < DbGame.ABORTED
}
object DbGame {