-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: choose 960 start position on the analysis board #16978
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package controllers | ||
|
||
import chess.format.Fen | ||
import chess.variant.{ FromPosition, Standard, Variant } | ||
import chess.variant.{ FromPosition, Standard, Variant, Chess960 } | ||
import chess.{ ByColor, FullMoveNumber, Situation } | ||
import play.api.libs.json.Json | ||
import play.api.mvc.* | ||
|
@@ -31,11 +31,16 @@ final class UserAnalysis( | |
case _ => load("", Standard) | ||
|
||
def load(urlFen: String, variant: Variant) = Open: | ||
val decodedFen: Option[Fen.Full] = lila.common.String | ||
val input: Option[String] = lila.common.String | ||
.decodeUriPath(urlFen) | ||
.filter(_.trim.nonEmpty) | ||
.orElse(get("fen")) | ||
.map(Fen.Full.clean) | ||
val parsed960: Option[Fen.Full] = input | ||
.ifTrue(variant.chess960) | ||
.orElse(get("position")) | ||
.flatMap(_.toIntOption.flatMap(Chess960.positionToFen)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and then, if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keeping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to account for |
||
val decodedFen: Option[Fen.Full] = parsed960 | ||
.orElse(input.map(Fen.Full.clean)) | ||
val pov = makePov(decodedFen, variant) | ||
val orientation = get("color").flatMap(Color.fromName) | pov.color | ||
for | ||
|
@@ -46,7 +51,7 @@ final class UserAnalysis( | |
orientation, | ||
owner = false | ||
) | ||
page <- renderPage(views.board.userAnalysis(data, pov)) | ||
page <- renderPage(views.board.userAnalysis(data, pov, decodedFen)) | ||
yield Ok(page) | ||
.withCanonical(routes.UserAnalysis.index) | ||
.enforceCrossSiteIsolation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this takes the FEN
input
, if the variant is chess960