can't properly divide horde games

pull/945/head
Thibault Duplessis 2015-09-10 17:25:25 +02:00
parent dde8965561
commit 826365789b
2 changed files with 14 additions and 6 deletions

View File

@ -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
}
}
}
}

View File

@ -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,