more RacingKings integration

pull/892/head
Niklas Fiekas 2015-09-04 23:31:10 +02:00
parent 82e57e3285
commit 9845bdac4a
18 changed files with 58 additions and 17 deletions

View File

@ -139,6 +139,7 @@ object User extends LilaController {
antichess <- env.cached topPerf PerfType.Antichess.key
atomic <- env.cached topPerf PerfType.Atomic.key
horde <- env.cached topPerf PerfType.Horde.key
racingKings <- env.cached topPerf PerfType.RacingKings.key
nbAllTime env.cached topNbGame nb map2 { (user: UserModel) =>
user -> user.count.game
}
@ -160,6 +161,7 @@ object User extends LilaController {
antichess = antichess,
atomic = atomic,
horde = horde,
racingKings = racingKings,
nbWeek = nbWeek,
nbAllTime = nbAllTime))),
api = _ => fuccess {

View File

@ -51,6 +51,7 @@ trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHel
case chess.variant.Antichess => "Lose all your pieces to win"
case chess.variant.Atomic => "Explode or mate your opponent's king to win"
case chess.variant.Horde => "Destroy the horde to win"
case chess.variant.RacingKings => "Race to the eighth rank to win"
case _ => "Variant ending"
}
case _ => "Game is still being played"
@ -156,6 +157,7 @@ trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHel
case S.VariantEnd => game.variant match {
case chess.variant.KingOfTheHill => trans.kingInTheCenter()
case chess.variant.ThreeCheck => trans.threeChecks()
case chess.variant.RacingKings => trans.raceFinished()
case _ => trans.variantEnding()
}
case _ => Html("")

View File

@ -33,14 +33,15 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
PerfType.Correspondence,
PerfType.Antichess,
PerfType.Atomic,
PerfType.Horde)
PerfType.Horde,
PerfType.RacingKings)
private def best4Of(u: User, perfTypes: List[PerfType]) =
perfTypes.sortBy { pt => -u.perfs(pt).nb } take 4
def miniViewSortedPerfTypes(u: User): List[PerfType] =
best4Of(u, List(PerfType.Bullet, PerfType.Blitz, PerfType.Classical, PerfType.Correspondence)) :::
best4Of(u, List(PerfType.Chess960, PerfType.KingOfTheHill, PerfType.ThreeCheck, PerfType.Antichess, PerfType.Atomic, PerfType.Horde))
best4Of(u, List(PerfType.Chess960, PerfType.KingOfTheHill, PerfType.ThreeCheck, PerfType.Antichess, PerfType.Atomic, PerfType.Horde, PerfType.RacingKings))
def showPerfRating(rating: Int, name: String, nb: Int, provisional: Boolean, icon: Char, klass: String)(implicit ctx: Context) = Html {
val title = s"$name rating over ${nb.localize} games"

View File

@ -9,6 +9,7 @@ case chess.variant.Antichess => {http://en.wikipedia.org/wiki/Losing_chess}
case chess.variant.FromPosition => {@routes.Editor.index?fen=@initialFen.map(_.replace(" ", "_"))}
case chess.variant.Atomic => {http://www.freechess.org/Help/HelpFiles/atomic.html}
case chess.variant.Horde => {http://en.wikipedia.org/wiki/Dunsany%27s_chess}
case chess.variant.RacingKings => {http://www.chessvariants.org/diffobjective.dir/racing.html}
case _ => {}
}
}

View File

@ -1,4 +1,4 @@
@(tourneyWinners: List[lila.tournament.Winner], online: List[User], bullet: List[User], blitz: List[User], classical: List[User], chess960: List[User], kingOfTheHill: List[User], threeCheck: List[User], antichess: List[User], atomic: List[User], horde: List[User], nbWeek: List[(User, Int)], nbAllTime: List[(User, Int)])(implicit ctx: Context)
@(tourneyWinners: List[lila.tournament.Winner], online: List[User], bullet: List[User], blitz: List[User], classical: List[User], chess960: List[User], kingOfTheHill: List[User], threeCheck: List[User], antichess: List[User], atomic: List[User], horde: List[User], racingKings: List[User], nbWeek: List[(User, Int)], nbAllTime: List[(User, Int)])(implicit ctx: Context)
@import lila.rating.PerfType
@ -97,6 +97,7 @@ description = "Best chess players in bullet, blitz, classical, Chess960 and more
@userTopPerf(horde, PerfType.Horde)
@userTopPerf(antichess, PerfType.Antichess)
@userTopPerf(atomic, PerfType.Atomic)
@userTopPerf(racingKings, PerfType.RacingKings)
</div>
</div>

View File

@ -69,6 +69,9 @@
@if(u.perfs.horde.nonEmpty) {
@showPerf(u.perfs.horde, PerfType.Horde)
}
@if(u.perfs.racingKings.nonEmpty) {
@showPerf(u.perfs.racingKings, PerfType.RacingKings)
}
<br />
}
@showPerf(u.perfs.puzzle, PerfType.Puzzle)

View File

@ -21,6 +21,7 @@ whiteIsVictorious=White is victorious
blackIsVictorious=Black is victorious
kingInTheCenter=King in the center
threeChecks=Three checks
raceFinished=Race finished
variantEnding=Variant ending
playWithTheSameOpponentAgain=Play with the same opponent again
newOpponent=New opponent

View File

@ -21,6 +21,7 @@ whiteIsVictorious=Weiß hat gewonnen
blackIsVictorious=Schwarz hat gewonnen
kingInTheCenter=König in der Mitte
threeChecks=Dreimaliges Schachgeben
raceFinished=Rennen beendet
variantEnding=Ende der Variante
playWithTheSameOpponentAgain=Mit dem gleichen Gegner noch einmal spielen
newOpponent=Neuer Gegner

View File

@ -45,7 +45,7 @@ final class PgnDump(
p.aiLevel.fold(u.fold(p.name | lila.user.User.anonymous)(_.name))("lichess AI level " + _)
private val customStartPosition: Set[chess.variant.Variant] =
Set(chess.variant.Chess960, chess.variant.FromPosition, chess.variant.Horde)
Set(chess.variant.Chess960, chess.variant.FromPosition, chess.variant.Horde, chess.variant.RacingKings)
private def tags(game: Game, initialFen: Option[String]): List[Tag] = gameLightUsers(game) match {
case (wu, bu) => List(

View File

@ -11,6 +11,7 @@ case class History(
threeCheck: RatingsMap,
atomic: RatingsMap,
horde: RatingsMap,
racingKings: RatingsMap,
bullet: RatingsMap,
blitz: RatingsMap,
classical: RatingsMap,
@ -29,6 +30,7 @@ case class History(
case PerfType.ThreeCheck => threeCheck
case PerfType.Atomic => atomic
case PerfType.Horde => horde
case PerfType.RacingKings => racingKings
case PerfType.Puzzle => puzzle
case x => sys error s"No history for perf $x"
}
@ -59,6 +61,7 @@ object History {
antichess = ratingsMap("antichess"),
atomic = ratingsMap("atomic"),
horde = ratingsMap("horde"),
racingKings = ratingsMap("racingKings"),
bullet = ratingsMap("bullet"),
blitz = ratingsMap("blitz"),
classical = ratingsMap("classical"),

View File

@ -49,7 +49,7 @@ final class RatingChartApi(
Json stringify {
Json.toJson {
import lila.rating.PerfType._
List(Bullet, Blitz, Classical, Correspondence, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, Puzzle) map { pt =>
List(Bullet, Blitz, Classical, Correspondence, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings, Puzzle) map { pt =>
ratingsMapToJson(pt, history(pt))
}
}

File diff suppressed because one or more lines are too long

View File

@ -79,6 +79,12 @@ object PerfType {
title = "Horde variant",
iconChar = '_')
case object RacingKings extends PerfType(17,
key = "racingKings",
name = chess.variant.RacingKings.name,
title = "Racing kings variant",
iconChar = '^')
case object Puzzle extends PerfType(20,
key = "puzzle",
name = "Training",
@ -91,7 +97,7 @@ object PerfType {
title = "Opening trainer",
iconChar = ']')
val all: List[PerfType] = List(Bullet, Blitz, Classical, Correspondence, Standard, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, Puzzle, Opening)
val all: List[PerfType] = List(Bullet, Blitz, Classical, Correspondence, Standard, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings, Puzzle, Opening)
val byKey = all map { p => (p.key, p) } toMap
val default = Standard
@ -101,8 +107,8 @@ object PerfType {
def name(key: Perf.Key): Option[String] = apply(key) map (_.name)
val nonPuzzle: List[PerfType] = List(Bullet, Blitz, Classical, Correspondence, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde)
val nonPuzzle: List[PerfType] = List(Bullet, Blitz, Classical, Correspondence, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
val nonGame: List[PerfType] = List(Puzzle, Opening)
val leaderboardable: List[PerfType] = List(Bullet, Blitz, Classical, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde)
val variants: List[PerfType] = List(Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde)
val leaderboardable: List[PerfType] = List(Bullet, Blitz, Classical, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
val variants: List[PerfType] = List(Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
}

View File

@ -35,6 +35,8 @@ final class PerfsUpdater(historyApi: HistoryApi) {
updateRatings(ratingsW.atomic, ratingsB.atomic, result, system)
case chess.variant.Horde =>
updateRatings(ratingsW.horde, ratingsB.horde, result, system)
case chess.variant.RacingKings =>
updateRatings(ratingsW.racingKings, ratingsB.racingKings, result, system)
case chess.variant.Standard => game.speed match {
case Speed.Bullet =>
updateRatings(ratingsW.bullet, ratingsB.bullet, result, system)
@ -72,6 +74,7 @@ final class PerfsUpdater(historyApi: HistoryApi) {
antichess: Rating,
atomic: Rating,
horde: Rating,
racingKings: Rating,
bullet: Rating,
blitz: Rating,
classical: Rating,
@ -84,6 +87,7 @@ final class PerfsUpdater(historyApi: HistoryApi) {
antichess = perfs.antichess.toRating,
atomic = perfs.atomic.toRating,
horde = perfs.horde.toRating,
racingKings = perfs.racingKings.toRating,
bullet = perfs.bullet.toRating,
blitz = perfs.blitz.toRating,
classical = perfs.classical.toRating,
@ -122,6 +126,7 @@ final class PerfsUpdater(historyApi: HistoryApi) {
antichess = game.ratingVariant.antichess.fold(perfs.antichess.add(ratings.antichess, date), perfs.antichess),
atomic = game.ratingVariant.atomic.fold(perfs.atomic.add(ratings.atomic, date), perfs.atomic),
horde = game.ratingVariant.horde.fold(perfs.horde.add(ratings.horde, date), perfs.horde),
racingKings = game.ratingVariant.racingKings.fold(perfs.racingKings.add(ratings.racingKings, date), perfs.racingKings),
bullet = (isStd && speed == Speed.Bullet).fold(perfs.bullet.add(ratings.bullet, date), perfs.bullet),
blitz = (isStd && speed == Speed.Blitz).fold(perfs.blitz.add(ratings.blitz, date), perfs.blitz),
classical = (isStd && speed == Speed.Classical).fold(perfs.classical.add(ratings.classical, date), perfs.classical),
@ -134,6 +139,7 @@ final class PerfsUpdater(historyApi: HistoryApi) {
antichess = r(perfs.antichess, perfs1.antichess),
atomic = r(perfs.atomic, perfs1.atomic),
horde = r(perfs.horde, perfs1.horde),
racingKings = r(perfs.racingKings, perfs1.racingKings),
bullet = r(perfs.bullet, perfs1.bullet),
blitz = r(perfs.blitz, perfs1.blitz),
classical = r(perfs.classical, perfs1.classical),

View File

@ -33,8 +33,9 @@ final class DataForm {
"clockIncrement" -> numberIn(clockIncrementChoices),
"clockExtra" -> numberIn(clockExtraChoices),
"variants" -> list {
number.verifying(Set(chess.variant.Standard.id, chess.variant.Chess960.id, chess.variant.KingOfTheHill.id,
chess.variant.ThreeCheck.id, chess.variant.Antichess.id, chess.variant.Atomic.id, chess.variant.Horde.id) contains _)
number.verifying(Set(chess.variant.Standard.id, chess.variant.Chess960.id,
chess.variant.KingOfTheHill.id, chess.variant.ThreeCheck.id,
chess.variant.Antichess.id, chess.variant.Atomic.id, chess.variant.Horde.id, chess.variant.RacingKings.id) contains _)
}.verifying("At least one variant", _.nonEmpty),
"color" -> stringIn(colorChoices)
)(SimulSetup.apply)(SimulSetup.unapply)

View File

@ -43,8 +43,9 @@ final class DataForm {
"clockIncrement" -> numberIn(clockIncrementPrivateChoices),
"minutes" -> numberIn(minutePrivateChoices),
"waitMinutes" -> numberIn(waitMinuteChoices),
"variant" -> number.verifying(Set(chess.variant.Standard.id, chess.variant.Chess960.id, chess.variant.KingOfTheHill.id,
chess.variant.ThreeCheck.id, chess.variant.Antichess.id, chess.variant.Atomic.id, chess.variant.Horde.id) contains _),
"variant" -> number.verifying(Set(chess.variant.Standard.id, chess.variant.Chess960.id,
chess.variant.KingOfTheHill.id, chess.variant.ThreeCheck.id, chess.variant.Antichess.id,
chess.variant.Atomic.id, chess.variant.Horde.id, chess.variant.RacingKings.id) contains _),
"position" -> nonEmptyText.verifying(positions contains _),
"mode" -> optional(number.verifying(Mode.all map (_.id) contains _)),
"private" -> optional(text.verifying("on" == _))

View File

@ -89,6 +89,10 @@ object Tv {
name = V.Horde.name,
icon = P.Horde.iconChar.toString,
filters = Seq(variant(V.Horde), freshBlitz))
case object RacingKings extends Channel(
name = V.RacingKings.name,
icon = P.RacingKings.iconChar.toString,
filters = Seq(variant(V.RacingKings), freshBlitz))
case object Computer extends Channel(
name = "Computer",
icon = ":",
@ -96,7 +100,7 @@ object Tv {
val all = List(
Best,
Bullet, Blitz, Classical,
Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde,
Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings,
Computer)
val byKey = all.map { c => c.key -> c }.toMap
}

View File

@ -14,6 +14,7 @@ case class Perfs(
antichess: Perf,
atomic: Perf,
horde: Perf,
racingKings: Perf,
bullet: Perf,
blitz: Perf,
classical: Perf,
@ -29,6 +30,7 @@ case class Perfs(
"antichess" -> antichess,
"atomic" -> atomic,
"horde" -> horde,
"racingKings" -> racingKings,
"bullet" -> bullet,
"blitz" -> blitz,
"classical" -> classical,
@ -77,6 +79,7 @@ case class Perfs(
"antichess" -> antichess,
"atomic" -> atomic,
"horde" -> horde,
"racingKings" -> racingKings,
"bullet" -> bullet,
"blitz" -> blitz,
"classical" -> classical,
@ -102,6 +105,7 @@ case class Perfs(
case PerfType.Antichess => antichess
case PerfType.Atomic => atomic
case PerfType.Horde => horde
case PerfType.RacingKings => racingKings
case PerfType.Puzzle => puzzle
case PerfType.Opening => opening
}
@ -133,7 +137,7 @@ case object Perfs {
val default = {
val p = Perf.default
Perfs(p, p, p, p, p, p, p, p, p, p, p, p, p)
Perfs(p, p, p, p, p, p, p, p, p, p, p, p, p, p)
}
def variantLens(variant: chess.variant.Variant): Option[Perfs => Perf] = variant match {
@ -144,6 +148,7 @@ case object Perfs {
case chess.variant.Antichess => Some(_.antichess)
case chess.variant.Atomic => Some(_.atomic)
case chess.variant.Horde => Some(_.horde)
case chess.variant.RacingKings => Some(_.racingKings)
case _ => none
}
@ -169,6 +174,7 @@ case object Perfs {
antichess = perf("antichess"),
atomic = perf("atomic"),
horde = perf("horde"),
racingKings = perf("racingKings"),
bullet = perf("bullet"),
blitz = perf("blitz"),
classical = perf("classical"),
@ -187,6 +193,7 @@ case object Perfs {
"antichess" -> notNew(o.antichess),
"atomic" -> notNew(o.atomic),
"horde" -> notNew(o.horde),
"racingKings" -> notNew(o.racingKings),
"bullet" -> notNew(o.bullet),
"blitz" -> notNew(o.blitz),
"classical" -> notNew(o.classical),