remove tournament->setup module dependency
parent
cd407a0810
commit
7638923d1c
|
@ -58,17 +58,17 @@ trait Positional { self: Config =>
|
|||
def fenGame(builder: ChessGame => Game): Game = {
|
||||
val state = fen filter (_ => variant == Variant.FromPosition) flatMap Forsyth.<<<
|
||||
val chessGame = state.fold(makeGame) {
|
||||
case sit @ SituationPlus(Situation(board, color), _) =>
|
||||
case sit@SituationPlus(Situation(board, color), _) =>
|
||||
ChessGame(
|
||||
board = board,
|
||||
player = color,
|
||||
board = board,
|
||||
player = color,
|
||||
turns = sit.turns,
|
||||
startedAtTurn = sit.turns,
|
||||
clock = makeClock)
|
||||
}
|
||||
val game = builder(chessGame)
|
||||
state.fold(game) {
|
||||
case sit @ SituationPlus(Situation(board, _), _) => game.copy(
|
||||
case sit@SituationPlus(Situation(board, _), _) => game.copy(
|
||||
variant = Variant.FromPosition,
|
||||
castleLastMoveTime = game.castleLastMoveTime.copy(
|
||||
castles = board.history.castles
|
||||
|
|
|
@ -6,7 +6,6 @@ import play.api.data.validation.Constraints._
|
|||
|
||||
import chess.{ Mode, Variant }
|
||||
import lila.common.Form._
|
||||
import lila.setup.Mappings
|
||||
|
||||
final class DataForm(isDev: Boolean) {
|
||||
|
||||
|
@ -36,8 +35,8 @@ final class DataForm(isDev: Boolean) {
|
|||
"clockIncrement" -> numberIn(clockIncrementChoices),
|
||||
"minutes" -> numberIn(minuteChoices),
|
||||
"minPlayers" -> numberIn(minPlayerChoices),
|
||||
"variant" -> Mappings.variant,
|
||||
"mode" -> Mappings.mode(true),
|
||||
"variant" -> number.verifying(Set(Variant.Standard.id, Variant.Chess960.id) contains _),
|
||||
"mode" -> number.verifying(Mode.all map (_.id) contains _),
|
||||
"password" -> optional(nonEmptyText)
|
||||
)(TournamentSetup.apply)(TournamentSetup.unapply)
|
||||
.verifying("Invalid clock", _.validClock)
|
||||
|
@ -49,7 +48,7 @@ final class DataForm(isDev: Boolean) {
|
|||
minPlayers = minPlayerDefault,
|
||||
variant = Variant.Standard.id,
|
||||
password = none,
|
||||
mode = Mode.Casual.id.some)
|
||||
mode = Mode.Casual.id)
|
||||
|
||||
lazy val joinPassword = Form(single(
|
||||
"password" -> nonEmptyText
|
||||
|
@ -62,7 +61,7 @@ private[tournament] case class TournamentSetup(
|
|||
minutes: Int,
|
||||
minPlayers: Int,
|
||||
variant: Int,
|
||||
mode: Option[Int],
|
||||
mode: Int,
|
||||
password: Option[String]) {
|
||||
|
||||
def validClock = (clockTime + clockIncrement) > 0
|
||||
|
|
|
@ -56,7 +56,7 @@ private[tournament] final class TournamentApi(
|
|||
clock = TournamentClock(setup.clockTime * 60, setup.clockIncrement),
|
||||
minutes = setup.minutes,
|
||||
minPlayers = setup.minPlayers,
|
||||
mode = Mode orDefault ~setup.mode,
|
||||
mode = Mode orDefault setup.mode,
|
||||
password = setup.password,
|
||||
variant = Variant orDefault setup.variant)
|
||||
$insert(created) >>-
|
||||
|
|
|
@ -164,7 +164,7 @@ object ApplicationBuild extends Build {
|
|||
)
|
||||
|
||||
lazy val tournament = project("tournament", Seq(
|
||||
common, hub, socket, chess, game, round, setup, security, chat, memo)).settings(
|
||||
common, hub, socket, chess, game, round, security, chat, memo)).settings(
|
||||
libraryDependencies ++= provided(play.api, RM, PRM)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue