can't properly divide horde games
parent
dde8965561
commit
826365789b
|
@ -42,16 +42,17 @@ final class Cached(
|
|||
timeToLive = 5.seconds)
|
||||
|
||||
private val count = mongoCache(
|
||||
prefix = "game:count",
|
||||
f = (o: JsObject) => $count(o),
|
||||
timeToLive = defaultTtl)
|
||||
prefix = "game:count",
|
||||
f = (o: JsObject) => $count(o),
|
||||
timeToLive = defaultTtl)
|
||||
|
||||
object Divider {
|
||||
|
||||
private val cache = Builder.size[String, chess.Division](5000)
|
||||
|
||||
def apply(game: Game, initialFen: Option[String]): chess.Division = {
|
||||
Option(cache getIfPresent game.id) | {
|
||||
def apply(game: Game, initialFen: Option[String]): chess.Division =
|
||||
if (!Game.divisionSensiblevariants.contains(game.variant)) chess.Division.empty
|
||||
else Option(cache getIfPresent game.id) | {
|
||||
val div = chess.Replay.boards(
|
||||
moveStrs = game.pgnMoves,
|
||||
initialFen = initialFen,
|
||||
|
@ -60,6 +61,5 @@ final class Cached(
|
|||
cache.put(game.id, div)
|
||||
div
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -455,6 +455,14 @@ object Game {
|
|||
chess.variant.ThreeCheck,
|
||||
chess.variant.KingOfTheHill)
|
||||
|
||||
val divisionSensiblevariants: Set[Variant] = Set(
|
||||
chess.variant.Standard,
|
||||
chess.variant.Chess960,
|
||||
chess.variant.ThreeCheck,
|
||||
chess.variant.KingOfTheHill,
|
||||
chess.variant.Antichess,
|
||||
chess.variant.FromPosition)
|
||||
|
||||
val analysableVariants: Set[Variant] = Set(
|
||||
chess.variant.Standard,
|
||||
chess.variant.Chess960,
|
||||
|
|
Loading…
Reference in New Issue