Skip to content

Commit

Permalink
Merge branch 'master' into round-berserk
Browse files Browse the repository at this point in the history
* master:
  add more data to mod export API - closes lichess-org#2372
  more tournament standing UI tweaks
  reformat tournament standing, again
  fix check in prev move display on game init
  careful... chess.variant.Variant is not sealed
  assets version
  ru "русский язык" translation lichess-org#16952. Author: Vasaka.
  tweak client compilation
  sk "slovenčina" translation lichess-org#16949. Author: HoSantaSK. Some sentences translated from czech to slovak
  pl "polski" translation lichess-org#16948. Author: rzenaikrzys. 522-".....nie dla pieniędzy"-is correct,530-"Korespondencyjne i nielimitowane"-is correct,532-"Obserwuj i zapraszaj znajomych"-is correct translation-Captain Kristo
  kamon includes setting is now required (since 6.0)
  fix simul help - closes lichess-org#2374
  reformat schedule tournament parameters
  implement daily/weekly/monthly tournament conditions
  let titled players bypass tournament nbGames & minRating conditions
  secure resign endpoint
  remove unused code
  crisp board - thanks to apetresc
  • Loading branch information
ornicar committed Nov 6, 2016
2 parents 842fffa + 99fa8e9 commit ad3046f
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 163 deletions.
14 changes: 10 additions & 4 deletions app/controllers/Round.scala
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,16 @@ object Round extends LilaController with TheftPrevention {

def resign(fullId: String) = Open { implicit ctx =>
OptionFuRedirect(GameRepo pov fullId) { pov =>
env resign pov
import scala.concurrent.duration._
val scheduler = lila.common.PlayApp.system.scheduler
akka.pattern.after(500 millis, scheduler)(fuccess(routes.Lobby.home))
if (isTheft(pov)) {
controllerLogger.warn(s"theft resign $fullId ${HTTPRequest.lastRemoteAddress(ctx.req)}")
fuccess(routes.Lobby.home)
}
else {
env resign pov
import scala.concurrent.duration._
val scheduler = lila.common.PlayApp.system.scheduler
akka.pattern.after(500 millis, scheduler)(fuccess(routes.Lobby.home))
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion bin/prod/compile-client
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ for file in tv.js puzzle.js user.js coordinate.js; do
fi
done

orig="$SRC/util.js $SRC/socket.js $SRC/main.js $LILA_AB_FILE"
orig="$SRC/util.js $SRC/socket.js $LILA_AB_FILE $SRC/main.js"
comp=$TARGET/lichess.js
lilalog "Compiling $comp"
closure-compiler --js $orig --js_output_file $comp
Expand Down
4 changes: 2 additions & 2 deletions conf/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ net {
ip = "5.196.91.160"
asset {
domain = ${net.domain}
version = 1219
version = 1223
}
email = "[email protected]"
crawlable = false
Expand Down Expand Up @@ -715,7 +715,7 @@ kamon {
track-unmatched-entities = no
filters {
trace {
includes = [ ]
includes = [ "round.move.trace" ]
excludes = [ ]
}
}
Expand Down
2 changes: 0 additions & 2 deletions modules/game/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ final class Env(

lazy val rewind = Rewind

lazy val gameJs = new GameJs(path = jsPath, useCache = isProd)

lazy val uciMemo = new UciMemo(UciMemoTtl)

lazy val pgnDump = new PgnDump(
Expand Down
17 changes: 0 additions & 17 deletions modules/game/src/main/GameJs.scala

This file was deleted.

6 changes: 3 additions & 3 deletions modules/i18n/messages/messages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -519,16 +519,16 @@
kidMode=Dla dzieci
playChessEverywhere=Graj w szachy wszędzie
asFreeAsLichess=Darmowa jak całe lichess
builtForTheLoveOfChessNotMoney=Stworzona z miłości do szachów, nie pieniędzy
builtForTheLoveOfChessNotMoney=Stworzona z miłości do szachów, nie dla pieniędzy
everybodyGetsAllFeaturesForFree=Wszystkie usługi darmowe dla wszystkich
zeroAdvertisement=Żadnych reklam
fullFeatured=Dostępne wszystkie usługi
phoneAndTablet=Telefon i tablet
bulletBlitzClassical=Bullet, blitz, classical
correspondenceChess=Szachy korespondencyjne
onlineAndOfflinePlay=Graj offline i w sieci
correspondenceAndUnlimited=Korespondencja i nielimitowane
correspondenceAndUnlimited=Korespondencyjne i nielimitowane
viewTheSolution=Zobacz rozwiązania
followAndChallengeFriends=Śledź i zaproś znajomych
followAndChallengeFriends=Obserwuj i zapraszaj znajomych
availableInNbLanguages=Dostępny w %s językach!
gameAnalysis=Analizuj grę
2 changes: 1 addition & 1 deletion modules/i18n/messages/messages.ru
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ thisMoveGivesYourOpponentTheAdvantage=Этот ход даёт вашему со
openingFailed=Дебют проигран
openingSolved=Дебют решён
recentlyPlayedOpenings=Недавно сыгранные дебюты
puzzles=Головоломки
puzzles=Задачки
coordinates=Координаты
openings=Дебюты
latestUpdates=Последние обновления
Expand Down
16 changes: 9 additions & 7 deletions modules/i18n/messages/messages.sk
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ tournamentHomeDescription=Hraj šachové turnaje s rýchlym tempom! Pridaj sa k
tournamentNotFound=Turnaj nebyl nalezen
tournamentDoesNotExist=Zvolený turnaj neexistuje
tournamentMayHaveBeenCanceled=Turnaj sa môže uzatvoriť, ak všetci hráči opustia turnaj pred jeho začatím.
returnToTournamentsHomepage=Zpátky na přehled turnajů
returnToTournamentsHomepage=Speť na prehľad turnajov
weeklyPerfTypeRatingDistribution=Týždenné %s ratingové hodnotenie
nbPerfTypePlayersThisWeek=%s %s hráčov tento týždeň.
yourPerfTypeRatingisRating=Tvoje %s hodnotenie je %s.
Expand All @@ -510,19 +510,21 @@ downloadRaw=Stiahnuť bez komentárov
downloadImported=Stiahnuť vložené
printFriendlyPDF=Tlačiteľné PDF
crosstable=Tabuľka
youCanAlsoScrollOverTheBoardToMoveInTheGame=K pohybu v partii môžete tiež použiť scrollovacie koliečko myši nad šachovnicou.
pressShiftPlusClickOrRightClickToDrawCirclesAndArrowsOnTheBoard=Stlač shift+ľavé tlačidlo na myši alebo pravé tlačidlo na myši na kreslenie kruhov a šípok na šachovnici.
confirmResignation=Potvrď registráciu
letOtherPlayersMessageYou=Povoliť ostatným hráčom ti napísať správu
shareYourInsightsData=Zdiaľajte výsledky analýzy vašeho hrania
youHaveAlreadyRegisteredTheEmail=Ste registrovaný na tento e-mail: %s
kidMode=Dětský režim
playChessEverywhere=Hrajte šachy kdekoliv
asFreeAsLichess=Svobodný jako lichess
builtForTheLoveOfChessNotMoney=Vytvoreno z lásky k šachům, ne pro peňáze
kidMode=Detský režim
playChessEverywhere=Hrajte šachy kdekoľvek
asFreeAsLichess=Slobodný ako lichess
builtForTheLoveOfChessNotMoney=Vytvorené z lásky k šachom, nie pre peniaze
everybodyGetsAllFeaturesForFree=Každý dostane všetky možnosti zadarmo
zeroAdvertisement=Bez reklám
fullFeatured=Plně vybavený
fullFeatured=Plne vybavený
phoneAndTablet=Mobil a tablet
bulletBlitzClassical=ultrarychlá hra, blesková hra, klasická hra
bulletBlitzClassical=Ultrarychlá hra, blesková hra, klasická hra
correspondenceChess=Korespondenčné šachy
onlineAndOfflinePlay=Hra online i offline
correspondenceAndUnlimited=Korešpondenčný a nekonečný
Expand Down
8 changes: 7 additions & 1 deletion modules/mod/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ final class Env(
notifyApi: lila.notify.NotifyApi,
historyApi: lila.history.HistoryApi,
rankingApi: lila.user.RankingApi,
relationApi: lila.relation.RelationApi,
userJson: lila.user.JsonView,
emailAddress: lila.security.EmailAddress) {

private object settings {
Expand Down Expand Up @@ -87,7 +89,9 @@ final class Env(
emailAddress = emailAddress)

lazy val jsonView = new JsonView(
assessApi = assessApi)
assessApi = assessApi,
relationApi = relationApi,
userJson = userJson)

lazy val userHistory = new UserHistory(
logApi = logApi,
Expand Down Expand Up @@ -128,5 +132,7 @@ object Env {
notifyApi = lila.notify.Env.current.api,
historyApi = lila.history.Env.current.api,
rankingApi = lila.user.Env.current.rankingApi,
relationApi = lila.relation.Env.current.api,
userJson = lila.user.Env.current.jsonView,
emailAddress = lila.security.Env.current.emailAddress)
}
30 changes: 20 additions & 10 deletions modules/mod/src/main/JsonView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,30 @@ import lila.evaluation._
import lila.game.{ Game, GameRepo }
import lila.user.User

final class JsonView(assessApi: AssessApi) {
final class JsonView(
assessApi: AssessApi,
relationApi: lila.relation.RelationApi,
userJson: lila.user.JsonView) {

def apply(user: User): Fu[Option[JsObject]] =
assessApi.getPlayerAggregateAssessmentWithGames(user.id) flatMap {
_ ?? {
case PlayerAggregateAssessment.WithGames(pag, games) =>
GameRepo withInitialFens games map { gamesWithFen =>
Json.obj(
"assessment" -> pag,
"games" -> JsObject(gamesWithFen.map { g =>
g._1.id -> gameWithFenWrites.writes(g)
})
).some
}
case PlayerAggregateAssessment.WithGames(pag, games) => for {
followers <- relationApi.countFollowers(user.id)
following <- relationApi.countFollowing(user.id)
blockers <- relationApi.countBlockers(user.id)
gamesWithFen <- GameRepo withInitialFens games
} yield Json.obj(
"user" -> userJson(user),
"relation" -> Json.obj(
"followers" -> followers,
"following" -> following,
"blockers" -> blockers),
"assessment" -> pag,
"games" -> JsObject(gamesWithFen.map { g =>
g._1.id -> gameWithFenWrites.writes(g)
})
).some
}
}

Expand Down
6 changes: 4 additions & 2 deletions modules/tournament/src/main/Condition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ object Condition {
case class NbRatedGame(perf: Option[PerfType], nb: Int) extends Condition with FlatCond {

def apply(user: User) =
perf match {
if (user.hasTitle) Accepted
else perf match {
case Some(p) if user.perfs(p).nb >= nb => Accepted
case Some(p) => Refused(s"Only ${user.perfs(p).nb} of $nb rated ${p.name} games played")
case None if user.count.rated >= nb => Accepted
Expand Down Expand Up @@ -58,7 +59,8 @@ object Condition {
case class MinRating(perf: PerfType, rating: Int) extends Condition with FlatCond {

def apply(user: User) =
if (user.perfs(perf).provisional) Refused(s"Provisional ${perf.name} rating")
if (user.hasTitle) Accepted
else if (user.perfs(perf).provisional) Refused(s"Provisional ${perf.name} rating")
else if (user.perfs(perf).intRating < rating) Refused(s"Current ${perf.name} rating is too low")
else Accepted

Expand Down
127 changes: 82 additions & 45 deletions modules/tournament/src/main/Schedule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ case class Schedule(
def similarTo(other: Schedule) =
similarSpeed(other) && sameVariant(other) && sameFreq(other) && sameConditions(other)

def perfType = PerfType.byVariant(variant) | Schedule.Speed.toPerfType(speed)

override def toString = s"$freq $variant $speed $conditions $at"
}

Expand Down Expand Up @@ -126,41 +128,41 @@ object Schedule {
private[tournament] def durationFor(s: Schedule): Option[Int] = {
import Freq._, Speed._
import chess.variant._
Some((s.freq, s.speed, s.variant) match {

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

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

case (Daily | Eastern, Blitz, Crazyhouse) => 120
case (Daily | Eastern, Blitz, _) => 60 // variant daily is shorter

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

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

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

case (Yearly, HyperBullet | Bullet, _) => 60 * 4
case (Yearly, SuperBlitz, _) => 60 * 5
case (Yearly, Blitz, _) => 60 * 6
case (Yearly, Classical, _) => 60 * 8
Some((s.freq, s.variant, s.speed) match {

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

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

case (Daily | Eastern, Crazyhouse, Blitz) => 120
case (Daily | Eastern, _, Blitz) => 60 // variant daily is shorter

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

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

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

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

case (Marathon, _, _) => 60 * 24 // lol
case (ExperimentalMarathon, _, _) => 60 * 4
Expand All @@ -180,17 +182,52 @@ object Schedule {

val TC = TournamentClock

(s.speed, s.variant, s.freq) match {
(s.freq, s.variant, s.speed) match {
// Special cases.
case (SuperBlitz, Crazyhouse, Hourly) if zhInc(s) => TC(3 * 60, 1)
case (Blitz, Crazyhouse, Hourly) if zhInc(s) => TC(4 * 60, 2)
case (Blitz, Standard, Hourly) if standardInc(s) => TC(3 * 60, 2)

case (HyperBullet, _, _) => TC(30, 0)
case (Bullet, _, _) => TC(60, 0)
case (SuperBlitz, _, _) => TC(3 * 60, 0)
case (Blitz, _, _) => TC(5 * 60, 0)
case (Classical, _, _) => TC(10 * 60, 0)
case (Hourly, Crazyhouse, SuperBlitz) if zhInc(s) => TC(3 * 60, 1)
case (Hourly, Crazyhouse, Blitz) if zhInc(s) => TC(4 * 60, 2)
case (Hourly, Standard, Blitz) if standardInc(s) => TC(3 * 60, 2)

case (_, _, HyperBullet) => TC(30, 0)
case (_, _, Bullet) => TC(60, 0)
case (_, _, SuperBlitz) => TC(3 * 60, 0)
case (_, _, Blitz) => TC(5 * 60, 0)
case (_, _, Classical) => TC(10 * 60, 0)
}
}

private[tournament] def conditionFor(s: Schedule) =
if (s.conditions.relevant) s.conditions
else {
import Freq._, Speed._

val nbRatedGame = (s.freq, s.speed) match {
case (Daily, HyperBullet | Bullet) => 20
case (Daily, SuperBlitz | Blitz) => 15
case (Daily, Classical) => 10

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

case (Weekend, HyperBullet | Bullet) => 30
case (Weekend, SuperBlitz | Blitz) => 20

case _ => 0
}

val minRating = s.freq match {
case Weekend => 2200
case _ => 0
}

Condition.All(
nbRatedGame = nbRatedGame.some.filter(0<).map {
Condition.NbRatedGame(s.perfType.some, _)
},
minRating = minRating.some.filter(0<).map {
Condition.MinRating(s.perfType, _)
},
maxRating = none)
}
}
Loading

0 comments on commit ad3046f

Please sign in to comment.