Implement cemeteries
This commit is contained in:
parent
6e3da19b0a
commit
73cd4ba45c
|
@ -11,7 +11,7 @@ object Round extends LilaController {
|
|||
val socket = env.round.socket
|
||||
|
||||
def watcher(gameId: String, color: String) = Open { implicit ctx ⇒
|
||||
IOption(gameRepo pov gameId) { pov ⇒
|
||||
IOption(gameRepo.pov(gameId, color)) { pov ⇒
|
||||
html.round.watcher(pov, version(pov.gameId))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package game
|
|||
|
||||
import round.{ Event, Progress }
|
||||
import user.User
|
||||
import chess.{ History ⇒ ChessHistory, Board, Move, Pos, Game, Clock, Status, Color, Piece, Variant }
|
||||
import chess.{ History ⇒ ChessHistory, Role, Board, Move, Pos, Game, Clock, Status, Color, Piece, Variant }
|
||||
import Color._
|
||||
import chess.format.{ PgnReader, Fen }
|
||||
import chess.Pos.piotr
|
||||
|
@ -295,6 +295,10 @@ case class DbGame(
|
|||
)
|
||||
|
||||
def nextId: Option[String] = next map (_.getId.toString)
|
||||
|
||||
def deadPiecesOf(color: Color): List[Role] = toChess.deads collect {
|
||||
case (_, piece) if piece is color => piece.role
|
||||
}
|
||||
}
|
||||
|
||||
object DbGame {
|
||||
|
|
|
@ -34,6 +34,9 @@ class GameRepo(collection: MongoCollection)
|
|||
gameOption map { g ⇒ Pov(g, g player color) }
|
||||
}
|
||||
|
||||
def pov(gameId: String, color: String): IO[Option[Pov]] =
|
||||
Color(color).fold(pov(gameId, _), io(None))
|
||||
|
||||
def pov(fullId: String): IO[Option[Pov]] =
|
||||
game(fullId take gameIdSize) map { gameOption ⇒
|
||||
gameOption flatMap { g ⇒
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
@(pov: Pov, position: String)(implicit ctx: Context)
|
||||
|
||||
cemetery for @pov.color
|
||||
@import pov._
|
||||
|
||||
<div class="lichess_cemetery lichess_cemetery_@position @player.color">
|
||||
@game.deadPiecesOf(color).map { role =>
|
||||
<div class="lichess_tomb"><div class="lichess_piece @role.name @color"></div></div>
|
||||
}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue