Skip to content

Commit

Permalink
Rapid WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 29, 2017
1 parent 9608b6b commit a2ebdca
Show file tree
Hide file tree
Showing 28 changed files with 104 additions and 69 deletions.
1 change: 1 addition & 0 deletions app/controllers/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ object User extends LilaController {
Ok(Json.obj(
"bullet" -> leaderboards.bullet,
"blitz" -> leaderboards.blitz,
"rapid" -> leaderboards.rapid,
"classical" -> leaderboards.classical,
"crazyhouse" -> leaderboards.crazyhouse,
"chess960" -> leaderboards.chess960,
Expand Down
6 changes: 3 additions & 3 deletions app/templating/UserHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
PerfType.Chess960,
PerfType.Blitz,
PerfType.KingOfTheHill,
PerfType.Classical,
PerfType.Rapid,
PerfType.ThreeCheck,
PerfType.Correspondence,
PerfType.Classical,
PerfType.Antichess,
PerfType.Correspondence,
PerfType.Atomic,
PerfType.Horde,
PerfType.RacingKings,
PerfType.Crazyhouse
)

Expand Down
2 changes: 1 addition & 1 deletion app/views/plan/features.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ <h1 data-icon="">Mobile</h1>
Online and offline games, with 8 variants
}
@tr(unlimited) {
Bullet, Blitz, Classical and Correspondence chess
Bullet, Blitz, Rapid, Classical and Correspondence chess
}
@tr(unlimited) {
<a href="@routes.Tournament.home(1)">Arena tournaments</a>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tournament/leaderboard.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h1>Tournament winners</h1>
@freqWinners(winners.bullet, PerfType.Bullet, "Bullet")
@freqWinners(winners.superblitz, PerfType.Blitz, "SuperBlitz")
@freqWinners(winners.blitz, PerfType.Blitz, "Blitz")
@freqWinners(winners.classical, PerfType.Classical, "Classical")
@freqWinners(winners.rapid, PerfType.Blitz, "Rapid")
@marathonWinners
@lila.tournament.WinnersApi.variants.map { v =>
@PerfType.byVariant(v).map { pt =>
Expand Down
7 changes: 4 additions & 3 deletions app/views/user/list.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h2>@trans.onlinePlayers()</h2>
openGraph = lila.app.ui.OpenGraph(
title = "Chess players and leaderboards",
url = s"$netBaseUrl${routes.User.list.url}",
description = "Best chess players in bullet, blitz, classical, Chess960 and more chess variants").some,
description = "Best chess players in bullet, blitz, rapid, classical, Chess960 and more chess variants").some,
withInfScroll = false) {
<div class="content_box community">
@communityTabs("leaderboard")
Expand All @@ -82,14 +82,15 @@ <h2 class="text" data-icon="g">
@userTopPerf(leaderboards.chess960, PerfType.Chess960)
@userTopActive(nbAllTime, trans.activePlayers(), icon = 'U'.some)

@userTopPerf(leaderboards.classical, PerfType.Classical)
@userTopPerf(leaderboards.rapid, PerfType.Rapid)
@userTopPerf(leaderboards.threeCheck, PerfType.ThreeCheck)
@userTopPerf(leaderboards.antichess, PerfType.Antichess)

@userTopPerf(leaderboards.ultraBullet, PerfType.UltraBullet)
@userTopPerf(leaderboards.classical, PerfType.Classical)
@userTopPerf(leaderboards.kingOfTheHill, PerfType.KingOfTheHill)
@userTopPerf(leaderboards.horde, PerfType.Horde)

@userTopPerf(leaderboards.ultraBullet, PerfType.UltraBullet)
@userTopPerf(leaderboards.atomic, PerfType.Atomic)
@userTopPerf(leaderboards.racingKings, PerfType.RacingKings)
</div>
Expand Down
1 change: 1 addition & 0 deletions app/views/user/show/side.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h3>@name.getOrElse(perfType.name).toUpperCase</h3>
@showNonEmptyPerf(u.perfs.ultraBullet, PerfType.UltraBullet)
@showPerf(u.perfs.bullet, PerfType.Bullet)
@showPerf(u.perfs.blitz, PerfType.Blitz)
@showPerf(u.perfs.rapid, PerfType.Rapid)
@showPerf(u.perfs.classical, PerfType.Classical)
@showPerf(u.perfs.correspondence, PerfType.Correspondence)
<br />
Expand Down
Empty file added bin/mongodb/rapid-init.js
Empty file.
6 changes: 3 additions & 3 deletions modules/explorer/src/main/ExplorerIndexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ private final class ExplorerIndexer(
import lila.rating.PerfType._
game.perfType ?? {
case Correspondence => 1
case Classical if rating >= 2000 => 1
case Classical if rating >= 1800 => 2 / 5f
case Classical => 1 / 8f
case Rapid | Classical if rating >= 2000 => 1
case Rapid | Classical if rating >= 1800 => 2 / 5f
case Rapid | Classical => 1 / 8f
case Blitz if rating >= 2000 => 1
case Blitz if rating >= 1800 => 1 / 4f
case Blitz => 1 / 15f
Expand Down
4 changes: 3 additions & 1 deletion modules/game/src/main/Game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,14 @@ case class Game(
case UltraBullet => 11
case Bullet => 16
case Blitz => 21
case _ => 25
case Rapid => 25
case _ => 30
}
else speed match {
case UltraBullet => 15
case Bullet => 20
case Blitz => 25
case Rapid => 30
case _ => 35
}
if (variant == chess.variant.Chess960) (base * 2) atMost 90
Expand Down
3 changes: 3 additions & 0 deletions modules/history/src/main/History.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ case class History(
ultraBullet: RatingsMap,
bullet: RatingsMap,
blitz: RatingsMap,
rapid: RatingsMap,
classical: RatingsMap,
correspondence: RatingsMap,
puzzle: RatingsMap
Expand All @@ -24,6 +25,7 @@ case class History(
case PerfType.Standard => standard
case PerfType.Bullet => bullet
case PerfType.Blitz => blitz
case PerfType.Rapid => rapid
case PerfType.Classical => classical
case PerfType.Correspondence => correspondence
case PerfType.Chess960 => chess960
Expand Down Expand Up @@ -68,6 +70,7 @@ object History {
ultraBullet = ratingsMap("ultraBullet"),
bullet = ratingsMap("bullet"),
blitz = ratingsMap("blitz"),
rapid = ratingsMap("rapid"),
classical = ratingsMap("classical"),
correspondence = ratingsMap("correspondence"),
puzzle = ratingsMap("puzzle")
Expand Down
1 change: 1 addition & 0 deletions modules/history/src/main/HistoryApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ final class HistoryApi(coll: Coll) {
(isStd && game.speed == Speed.UltraBullet).option("ultraBullet" -> perfs.ultraBullet),
(isStd && game.speed == Speed.Bullet).option("bullet" -> perfs.bullet),
(isStd && game.speed == Speed.Blitz).option("blitz" -> perfs.blitz),
(isStd && game.speed == Speed.Rapid).option("rapid" -> perfs.rapid),
(isStd && game.speed == Speed.Classical).option("classical" -> perfs.classical),
(isStd && game.speed == Speed.Correspondence).option("correspondence" -> perfs.correspondence)
).flatten.map {
Expand Down
2 changes: 1 addition & 1 deletion modules/history/src/main/RatingChartApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class RatingChartApi(
lila.common.String.html.safeJsonValue {
Json.toJson {
import lila.rating.PerfType._
List(Bullet, Blitz, Classical, Correspondence, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings, Crazyhouse, Puzzle, UltraBullet) map { pt =>
List(Bullet, Blitz, Rapid, Classical, Correspondence, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings, Crazyhouse, Puzzle, UltraBullet) map { pt =>
Json.obj(
"name" -> pt.name,
"points" -> ratingsMapToJson(user, history(pt))
Expand Down
2 changes: 1 addition & 1 deletion modules/insight/src/main/Preset.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object Preset {
Preset(
"What is the Win-Rate of my favourite openings as white?",
Question(D.Opening, M.Result, List(
Filter(D.Perf, List(PerfType.Bullet, PerfType.Blitz, PerfType.Classical, PerfType.Correspondence)),
Filter(D.Perf, List(PerfType.Bullet, PerfType.Blitz, PerfType.Rapid, PerfType.Classical, PerfType.Correspondence)),
Filter(D.Color, List(chess.White))
))
),
Expand Down
19 changes: 14 additions & 5 deletions modules/rating/src/main/PerfType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ object PerfType {
iconChar = ')'
)

case object Rapid extends PerfType(
6,
key = "rapid",
name = Speed.Rapid.name,
title = Speed.Rapid.title,
iconChar = 'C'
)

case object Classical extends PerfType(
3,
key = "classical",
Expand Down Expand Up @@ -137,7 +145,7 @@ object PerfType {
iconChar = '-'
)

val all: List[PerfType] = List(UltraBullet, Bullet, Blitz, Classical, Correspondence, Standard, Crazyhouse, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings, Puzzle)
val all: List[PerfType] = List(UltraBullet, Bullet, Blitz, Rapid, Classical, Correspondence, Standard, Crazyhouse, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings, Puzzle)
val byKey = all map { p => (p.key, p) } toMap
val byId = all map { p => (p.id, p) } toMap

Expand All @@ -152,11 +160,11 @@ object PerfType {

def id2key(id: Perf.ID): Option[Perf.Key] = byId get id map (_.key)

val nonPuzzle: List[PerfType] = List(UltraBullet, Bullet, Blitz, Classical, Correspondence, Crazyhouse, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
val nonPuzzle: List[PerfType] = List(UltraBullet, Bullet, Blitz, Rapid, Classical, Correspondence, Crazyhouse, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
val nonGame: List[PerfType] = List(Puzzle)
val leaderboardable: List[PerfType] = List(Bullet, Blitz, Classical, UltraBullet, Crazyhouse, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
val leaderboardable: List[PerfType] = List(Bullet, Blitz, Rapid, Classical, UltraBullet, Crazyhouse, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
val variants: List[PerfType] = List(Crazyhouse, Chess960, KingOfTheHill, ThreeCheck, Antichess, Atomic, Horde, RacingKings)
val standard: List[PerfType] = List(Bullet, Blitz, Classical, Correspondence)
val standard: List[PerfType] = List(Bullet, Blitz, Rapid, Classical, Correspondence)

def isGame(pt: PerfType) = !nonGame.contains(pt)

Expand Down Expand Up @@ -193,7 +201,8 @@ object PerfType {
case UltraBullet => 25 * 100
case Bullet => 90 * 100
case Blitz => 7 * 60 * 100
case Classical => 15 * 60 * 100
case Rapid => 12 * 60 * 100
case Classical => 30 * 60 * 100
case Correspondence => 60 * 60 * 100
case _ => 7 * 60 * 100
})
Expand Down
5 changes: 5 additions & 0 deletions modules/round/src/main/PerfsUpdater.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ final class PerfsUpdater(
updateRatings(ratingsW.bullet, ratingsB.bullet, result, system)
case Speed.Blitz =>
updateRatings(ratingsW.blitz, ratingsB.blitz, result, system)
case Speed.Rapid =>
updateRatings(ratingsW.rapid, ratingsB.rapid, result, system)
case Speed.Classical =>
updateRatings(ratingsW.classical, ratingsB.classical, result, system)
case Speed.Correspondence =>
Expand Down Expand Up @@ -84,6 +86,7 @@ final class PerfsUpdater(
ultraBullet: Rating,
bullet: Rating,
blitz: Rating,
rapid: Rating,
classical: Rating,
correspondence: Rating
)
Expand All @@ -100,6 +103,7 @@ final class PerfsUpdater(
ultraBullet = perfs.ultraBullet.toRating,
bullet = perfs.bullet.toRating,
blitz = perfs.blitz.toRating,
rapid = perfs.rapid.toRating,
classical = perfs.classical.toRating,
correspondence = perfs.correspondence.toRating
)
Expand Down Expand Up @@ -143,6 +147,7 @@ final class PerfsUpdater(
ultraBullet = addRatingIf(isStd && speed == Speed.UltraBullet, perfs.ultraBullet, ratings.ultraBullet),
bullet = addRatingIf(isStd && speed == Speed.Bullet, perfs.bullet, ratings.bullet),
blitz = addRatingIf(isStd && speed == Speed.Blitz, perfs.blitz, ratings.blitz),
rapid = addRatingIf(isStd && speed == Speed.Rapid, perfs.rapid, ratings.rapid),
classical = addRatingIf(isStd && speed == Speed.Classical, perfs.classical, ratings.classical),
correspondence = addRatingIf(isStd && speed == Speed.Correspondence, perfs.correspondence, ratings.correspondence)
)
Expand Down
34 changes: 17 additions & 17 deletions modules/tournament/src/main/Schedule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ object Schedule {
case object HippoBullet extends Speed(25)
case object SuperBlitz extends Speed(30)
case object Blitz extends Speed(40)
case object Classical extends Speed(50)
val all: List[Speed] = List(UltraBullet, HyperBullet, Bullet, HippoBullet, SuperBlitz, Blitz, Classical)
val mostPopular: List[Speed] = List(Bullet, Blitz, Classical)
case object Rapid extends Speed(50)
val all: List[Speed] = List(UltraBullet, HyperBullet, Bullet, HippoBullet, SuperBlitz, Blitz, Rapid)
val mostPopular: List[Speed] = List(Bullet, Blitz, Rapid)
def apply(name: String) = all find (_.name == name)
def byId(id: Int) = all find (_.id == id)
def similar(s1: Speed, s2: Speed) = (s1, s2) match {
Expand All @@ -120,13 +120,13 @@ object Schedule {
else if (time < 120) Bullet
else if (time < 180) HippoBullet
else if (time < 480) Blitz
else Classical
else Rapid
}
def toPerfType(speed: Speed) = speed match {
case UltraBullet => PerfType.UltraBullet
case HyperBullet | Bullet | HippoBullet => PerfType.Bullet
case SuperBlitz | Blitz => PerfType.Blitz
case Classical => PerfType.Classical
case Rapid => PerfType.Rapid
}
}

Expand All @@ -146,40 +146,40 @@ object Schedule {

case (Hourly, _, UltraBullet | HyperBullet | Bullet) => 27
case (Hourly, _, HippoBullet | SuperBlitz | Blitz) => 57
case (Hourly, _, Classical) if s.hasMaxRating => 57
case (Hourly, _, Classical) => 117
case (Hourly, _, Rapid) if s.hasMaxRating => 57
case (Hourly, _, Rapid) => 117

case (Daily | Eastern, Standard, SuperBlitz) => 90
case (Daily | Eastern, Standard, Blitz) => 120
case (Daily | Eastern, _, Blitz) => 90
case (Daily | Eastern, _, Classical) => 150
case (Daily | Eastern, _, Rapid) => 150
case (Daily | Eastern, _, _) => 60

case (Weekly, _, UltraBullet | HyperBullet | Bullet) => 60 * 2
case (Weekly, _, HippoBullet | SuperBlitz | Blitz) => 60 * 3
case (Weekly, _, Classical) => 60 * 4
case (Weekly, _, Rapid) => 60 * 4

case (Weekend, _, UltraBullet | HyperBullet | Bullet) => 90
case (Weekend, _, HippoBullet | SuperBlitz) => 60 * 2
case (Weekend, _, Blitz) => 60 * 3
case (Weekend, _, Classical) => 60 * 4
case (Weekend, _, Rapid) => 60 * 4

case (Monthly, _, UltraBullet) => 60 * 2
case (Monthly, _, HyperBullet | Bullet) => 60 * 3
case (Monthly, _, HippoBullet | SuperBlitz) => 60 * 3 + 30
case (Monthly, _, Blitz) => 60 * 4
case (Monthly, _, Classical) => 60 * 5
case (Monthly, _, Rapid) => 60 * 5

case (Shield, _, UltraBullet) => 60 * 3
case (Shield, _, HyperBullet | Bullet) => 60 * 4
case (Shield, _, HippoBullet | SuperBlitz) => 60 * 5
case (Shield, _, Blitz) => 60 * 6
case (Shield, _, Classical) => 60 * 8
case (Shield, _, Rapid) => 60 * 8

case (Yearly, _, UltraBullet | HyperBullet | Bullet) => 60 * 4
case (Yearly, _, HippoBullet | SuperBlitz) => 60 * 5
case (Yearly, _, Blitz) => 60 * 6
case (Yearly, _, Classical) => 60 * 8
case (Yearly, _, Rapid) => 60 * 8

case (Marathon, _, _) => 60 * 24 // lol
case (ExperimentalMarathon, _, _) => 60 * 4
Expand Down Expand Up @@ -212,7 +212,7 @@ object Schedule {
case (_, _, HippoBullet) => TC(2 * 60, 0)
case (_, _, SuperBlitz) => TC(3 * 60, 0)
case (_, _, Blitz) => TC(5 * 60, 0)
case (_, _, Classical) => TC(10 * 60, 0)
case (_, _, Rapid) => TC(10 * 60, 0)
}
}
private[tournament] def addCondition(s: Schedule) =
Expand All @@ -229,15 +229,15 @@ object Schedule {

case (Hourly, UltraBullet | HyperBullet | Bullet) => 20
case (Hourly, HippoBullet | SuperBlitz | Blitz) => 15
case (Hourly, Classical) => 10
case (Hourly, Rapid) => 10

case (Daily | Eastern, UltraBullet | HyperBullet | Bullet) => 20
case (Daily | Eastern, HippoBullet | SuperBlitz | Blitz) => 15
case (Daily | Eastern, Classical) => 15
case (Daily | Eastern, Rapid) => 15

case (Weekly | Monthly | Shield, UltraBullet | HyperBullet | Bullet) => 30
case (Weekly | Monthly | Shield, HippoBullet | SuperBlitz | Blitz) => 20
case (Weekly | Monthly | Shield, Classical) => 15
case (Weekly | Monthly | Shield, Rapid) => 15

case (Weekend, UltraBullet | HyperBullet | Bullet) => 30
case (Weekend, HippoBullet | SuperBlitz | Blitz) => 20
Expand Down
2 changes: 1 addition & 1 deletion modules/tournament/src/main/ScheduleJsonView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class ScheduleJsonView(lightUser: LightUser.Getter) {

private val perfPositions: Map[PerfType, Int] = {
import PerfType._
List(Bullet, Blitz, Classical, UltraBullet) ::: variants
List(Bullet, Blitz, Rapid, UltraBullet) ::: variants
}.zipWithIndex.toMap

private def perfJson(p: PerfType) = Json.obj(
Expand Down
2 changes: 1 addition & 1 deletion modules/tournament/src/main/TournamentInviter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private final class TournamentInviter private (
object TournamentInviter {

val minGames = 20
val perfs = List(PerfType.Blitz, PerfType.Classical)
val perfs = List(PerfType.Blitz, PerfType.Rapid)

def bestRating(user: User) = user.perfs.bestRatingInWithMinGames(perfs, minGames)

Expand Down
Loading

0 comments on commit a2ebdca

Please sign in to comment.