show previous moves in correspondence analysis screen - resolves #274
This commit is contained in:
parent
e3ae3d9b69
commit
0f2d59b93a
|
@ -18,9 +18,9 @@ object UserAnalysis extends LilaController with BaseGame {
|
|||
val decodedFen = fenStr.map { java.net.URLDecoder.decode(_, "UTF-8").trim }.filter(_.nonEmpty)
|
||||
val situation = (decodedFen flatMap Forsyth.<<<) | SituationPlus(Situation(chess.variant.Standard), 1)
|
||||
val pov = makePov(situation)
|
||||
val data = Env.round.jsonView.userAnalysisJson(pov, ctx.pref)
|
||||
makeListMenu map { listMenu =>
|
||||
Ok(html.board.userAnalysis(listMenu, data, none))
|
||||
Env.round.jsonView.userAnalysisJson(pov, ctx.pref) zip makeListMenu map {
|
||||
case (data, listMenu) =>
|
||||
Ok(html.board.userAnalysis(listMenu, data, none))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,9 @@ object UserAnalysis extends LilaController with BaseGame {
|
|||
def game(id: String, color: String) = Open { implicit ctx =>
|
||||
OptionFuOk(GameRepo game id) { game =>
|
||||
val pov = Pov(game, chess.Color(color == "white"))
|
||||
val data = Env.round.jsonView.userAnalysisJson(pov, ctx.pref)
|
||||
makeListMenu map { listMenu =>
|
||||
html.board.userAnalysis(listMenu, data, pov.some)
|
||||
Env.round.jsonView.userAnalysisJson(pov, ctx.pref) zip makeListMenu map {
|
||||
case (data, listMenu) =>
|
||||
html.board.userAnalysis(listMenu, data, pov.some)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,10 @@ data: @Html(play.api.libs.json.Json.stringify(data)),
|
|||
routes: roundRoutes.controllers,
|
||||
i18n: @round.jsI18n()
|
||||
};
|
||||
lichess.user_analysis.data.inGame = @pov.isDefined;
|
||||
@pov.map { p =>
|
||||
lichess.user_analysis.data.inGame = true;
|
||||
lichess.user_analysis.data.path = "@p.game.turns";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -224,31 +224,34 @@ final class JsonView(
|
|||
).noNull
|
||||
}
|
||||
|
||||
def userAnalysisJson(pov: Pov, pref: Pref) = {
|
||||
import pov._
|
||||
val fen = Forsyth >> game.toChess
|
||||
Json.obj(
|
||||
"game" -> Json.obj(
|
||||
"id" -> gameId,
|
||||
"variant" -> variantJson(game.variant),
|
||||
"initialFen" -> fen,
|
||||
"fen" -> fen,
|
||||
"player" -> game.turnColor.name,
|
||||
"status" -> statusJson(game.status)),
|
||||
"player" -> Json.obj(
|
||||
"color" -> color.name
|
||||
),
|
||||
"opponent" -> Json.obj(
|
||||
"color" -> opponent.color.name
|
||||
),
|
||||
"pref" -> Json.obj(
|
||||
"animationDuration" -> animationDuration(pov, pref),
|
||||
"highlight" -> pref.highlight,
|
||||
"destination" -> pref.destination,
|
||||
"coords" -> pref.coords
|
||||
),
|
||||
"userAnalysis" -> true)
|
||||
}
|
||||
def userAnalysisJson(pov: Pov, pref: Pref) =
|
||||
GameRepo.initialFen(pov.game) map { initialFen =>
|
||||
import pov._
|
||||
val fen = Forsyth >> game.toChess
|
||||
Json.obj(
|
||||
"game" -> Json.obj(
|
||||
"id" -> gameId,
|
||||
"variant" -> variantJson(game.variant),
|
||||
"initialFen" -> (initialFen | chess.format.Forsyth.initial),
|
||||
"fen" -> fen,
|
||||
"moves" -> game.pgnMoves.mkString(" "),
|
||||
"turns" -> game.turns,
|
||||
"player" -> game.turnColor.name,
|
||||
"status" -> statusJson(game.status)),
|
||||
"player" -> Json.obj(
|
||||
"color" -> color.name
|
||||
),
|
||||
"opponent" -> Json.obj(
|
||||
"color" -> opponent.color.name
|
||||
),
|
||||
"pref" -> Json.obj(
|
||||
"animationDuration" -> animationDuration(pov, pref),
|
||||
"highlight" -> pref.highlight,
|
||||
"destination" -> pref.destination,
|
||||
"coords" -> pref.coords
|
||||
),
|
||||
"userAnalysis" -> true)
|
||||
}
|
||||
|
||||
private def blurs(game: Game, player: lila.game.Player) = {
|
||||
val percent = game.playerBlurPercent(player.color)
|
||||
|
|
Loading…
Reference in a new issue