diff --git a/app/controllers/Practice.scala b/app/controllers/Practice.scala index 61d9568384..2426a5679d 100644 --- a/app/controllers/Practice.scala +++ b/app/controllers/Practice.scala @@ -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) diff --git a/app/controllers/Study.scala b/app/controllers/Study.scala index bf9b422358..ec78596803 100644 --- a/app/controllers/Study.scala +++ b/app/controllers/Study.scala @@ -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, diff --git a/modules/study/src/main/TreeBuilder.scala b/modules/study/src/main/TreeBuilder.scala index d04fe22a43..0eb5838d36 100644 --- a/modules/study/src/main/TreeBuilder.scala +++ b/modules/study/src/main/TreeBuilder.scala @@ -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,