Revert "no longer preload study destinations, as to leverage eval cache"

This reverts commit 28103c670b.
This commit is contained in:
Thibault Duplessis 2017-02-02 13:16:32 +01:00
parent 7b18b38b37
commit e5a0e2b1de
3 changed files with 16 additions and 4 deletions

View file

@ -58,7 +58,7 @@ object Practice extends LilaController {
case (baseData, studyJson) =>
val analysis = baseData ++ Json.obj(
"treeParts" -> partitionTreeJsonWriter.writes {
lila.study.TreeBuilder(chapter.root)
lila.study.TreeBuilder(chapter.root, chapter.setup.variant)
},
"practiceGoal" -> lila.practice.PracticeGoal(chapter))
(analysis, studyJson)

View file

@ -99,7 +99,7 @@ object Study extends LilaController {
study = studyJson,
analysis = baseData ++ Json.obj(
"treeParts" -> partitionTreeJsonWriter.writes {
lila.study.TreeBuilder(chapter.root)
lila.study.TreeBuilder(chapter.root, chapter.setup.variant)
}))
res <- negotiate(
html = for {
@ -176,7 +176,7 @@ object Study extends LilaController {
import lila.tree.Node.partitionTreeJsonWriter
val analysis = baseData ++ Json.obj(
"treeParts" -> partitionTreeJsonWriter.writes {
lila.study.TreeBuilder(chapter.root)
lila.study.TreeBuilder.makeRoot(chapter.root)
})
val data = lila.study.JsonView.JsData(
study = studyJson,

View file

@ -5,7 +5,19 @@ import lila.tree
object TreeBuilder {
def apply(root: Node.Root) = tree.Root(
private val initialStandardDests = chess.Game(chess.variant.Standard).situation.destinations
def apply(root: Node.Root, variant: chess.variant.Variant) = {
val dests =
if (variant.standard && root.fen.value == chess.format.Forsyth.initial) initialStandardDests
else {
val sit = chess.Game(variant.some, root.fen.value.some).situation
sit.playable(false) ?? sit.destinations
}
makeRoot(root).copy(dests = dests.some)
}
def makeRoot(root: Node.Root) = tree.Root(
ply = root.ply,
fen = root.fen.value,
check = root.check,