Skip to content

Commit

Permalink
refuse to analyse old horde games
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Sep 4, 2016
1 parent 53c8e82 commit 40f62f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/explorer/src/main/ExplorerIndexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private final class ExplorerIndexer(
game.rated &&
game.turns >= 10 &&
game.variant != chess.variant.FromPosition &&
(game.variant != chess.variant.Horde || game.createdAt.isAfter(Query.hordeWhitePawnsSince))
!Game.isOldHorde(game)

private def stableRating(player: Player) = player.rating ifFalse player.provisional

Expand Down
7 changes: 4 additions & 3 deletions modules/fishnet/src/main/Analyser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import org.joda.time.DateTime

import chess.format.{ FEN, Forsyth }

import lila.game.{ Game, GameRepo, UciMemo }
import lila.analyse.AnalysisRepo
import lila.game.{ Game, GameRepo, UciMemo }

final class Analyser(
repo: FishnetRepo,
Expand All @@ -17,8 +17,9 @@ final class Analyser(

def apply(game: Game, sender: Work.Sender): Fu[Boolean] =
AnalysisRepo exists game.id flatMap {
case true => fuccess(false)
case false =>
case true => fuccess(false)
case _ if Game.isOldHorde(game) => fuccess(false)
case _ =>
limiter(sender) flatMap { accepted =>
accepted ?? {
makeWork(game, sender) flatMap { work =>
Expand Down
13 changes: 11 additions & 2 deletions modules/game/src/main/Game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package lila.game

import chess.Color.{ White, Black }
import chess.format.Uci
import chess.opening.{ FullOpening, FullOpeningDB }
import chess.Pos.piotr, chess.Role.forsyth
import chess.variant.{ Variant, Crazyhouse }
import chess.opening.{ FullOpening, FullOpeningDB }
import chess.{ History => ChessHistory, CheckCount, Castles, Role, Board, MoveOrDrop, Pos, Game => ChessGame, Clock, Status, Color, Piece, Mode, PositionHash }
import org.joda.time.DateTime
import scala.concurrent.duration.FiniteDuration
Expand Down Expand Up @@ -349,7 +349,10 @@ case class Game(

def replayable = isPgnImport || finished

def analysable = replayable && playedTurns > 4 && Game.analysableVariants(variant)
def analysable =
replayable && playedTurns > 4 &&
Game.analysableVariants(variant) &&
!Game.isOldHorde(this)

def ratingVariant =
if (isTournament && variant == chess.variant.FromPosition) chess.variant.Standard
Expand Down Expand Up @@ -507,6 +510,12 @@ object Game {
chess.variant.RacingKings,
chess.variant.Antichess)

val hordeWhitePawnsSince = new DateTime(2015, 4, 11, 10, 0)

def isOldHorde(game: Game) =
game.variant == chess.variant.Horde &&
game.createdAt.isBefore(Game.hordeWhitePawnsSince)

val gameIdSize = 8
val playerIdSize = 4
val fullIdSize = 12
Expand Down
4 changes: 1 addition & 3 deletions modules/game/src/main/Query.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ object Query {
)

lazy val sinceHordePawnsAreWhite: Bdoc =
F.createdAt $gt hordeWhitePawnsSince

val hordeWhitePawnsSince = new DateTime(2015, 4, 11, 10, 0)
F.createdAt $gt Game.hordeWhitePawnsSince

val notFromPosition: Bdoc =
F.variant $ne chess.variant.FromPosition.id
Expand Down

0 comments on commit 40f62f6

Please sign in to comment.