fix game variant when from a position
This commit is contained in:
parent
5d3c4d5b56
commit
4e82c37137
|
@ -1,6 +1,7 @@
|
||||||
package lila.setup
|
package lila.setup
|
||||||
|
|
||||||
import chess.{ Game => ChessGame, Situation, Clock, Speed }
|
import chess.{ Game => ChessGame, Situation, Clock, Speed }
|
||||||
|
import chess.variant.FromPosition
|
||||||
|
|
||||||
import lila.game.Game
|
import lila.game.Game
|
||||||
import lila.lobby.Color
|
import lila.lobby.Color
|
||||||
|
@ -54,12 +55,14 @@ trait Positional { self: Config =>
|
||||||
|
|
||||||
def strictFen: Boolean
|
def strictFen: Boolean
|
||||||
|
|
||||||
lazy val validFen = variant != chess.variant.FromPosition || {
|
lazy val validFen = variant != FromPosition || {
|
||||||
fen ?? { f => ~(Forsyth <<< f).map(_.situation playable strictFen) }
|
fen ?? { f => ~(Forsyth <<< f).map(_.situation playable strictFen) }
|
||||||
}
|
}
|
||||||
|
|
||||||
def fenGame(builder: ChessGame => Game): Game = {
|
def fenGame(builder: ChessGame => Game): Game = {
|
||||||
val baseState = fen ifTrue (variant == chess.variant.FromPosition) flatMap Forsyth.<<<
|
val baseState = fen ifTrue (variant == FromPosition) flatMap {
|
||||||
|
Forsyth.<<<@(FromPosition, _)
|
||||||
|
}
|
||||||
val (chessGame, state) = baseState.fold(makeGame -> none[SituationPlus]) {
|
val (chessGame, state) = baseState.fold(makeGame -> none[SituationPlus]) {
|
||||||
case sit @ SituationPlus(s, _) =>
|
case sit @ SituationPlus(s, _) =>
|
||||||
val game = ChessGame(
|
val game = ChessGame(
|
||||||
|
@ -78,7 +81,7 @@ trait Positional { self: Config =>
|
||||||
situation = game.situation.copy(
|
situation = game.situation.copy(
|
||||||
board = game.board.copy(
|
board = game.board.copy(
|
||||||
history = board.history,
|
history = board.history,
|
||||||
variant = chess.variant.FromPosition
|
variant = FromPosition
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
turns = sit.turns
|
turns = sit.turns
|
||||||
|
@ -94,7 +97,7 @@ trait BaseConfig {
|
||||||
val variants = List(chess.variant.Standard.id, chess.variant.Chess960.id)
|
val variants = List(chess.variant.Standard.id, chess.variant.Chess960.id)
|
||||||
val variantDefault = chess.variant.Standard
|
val variantDefault = chess.variant.Standard
|
||||||
|
|
||||||
val variantsWithFen = variants :+ chess.variant.FromPosition.id
|
val variantsWithFen = variants :+ FromPosition.id
|
||||||
val aiVariants = variants :+
|
val aiVariants = variants :+
|
||||||
chess.variant.Crazyhouse.id :+
|
chess.variant.Crazyhouse.id :+
|
||||||
chess.variant.KingOfTheHill.id :+
|
chess.variant.KingOfTheHill.id :+
|
||||||
|
@ -114,7 +117,7 @@ trait BaseConfig {
|
||||||
chess.variant.Horde.id :+
|
chess.variant.Horde.id :+
|
||||||
chess.variant.RacingKings.id
|
chess.variant.RacingKings.id
|
||||||
val variantsWithFenAndVariants =
|
val variantsWithFenAndVariants =
|
||||||
variantsWithVariants :+ chess.variant.FromPosition.id
|
variantsWithVariants :+ FromPosition.id
|
||||||
|
|
||||||
val speeds = Speed.all map (_.id)
|
val speeds = Speed.all map (_.id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue