show tournament name in goodies, show tournament clock in games
This commit is contained in:
parent
84645de320
commit
deaa140432
|
@ -21,6 +21,7 @@ object Analyse extends LilaController {
|
|||
private def roundSocket = env.round.socket
|
||||
private def roundHubMaster = env.round.hubMaster
|
||||
private def analyser = env.analyse.analyser
|
||||
private def tournamentRepo = env.tournament.repo
|
||||
|
||||
def computer(id: String, color: String) = Auth { implicit ctx ⇒
|
||||
me ⇒
|
||||
|
@ -41,6 +42,7 @@ object Analyse extends LilaController {
|
|||
bookmarkers ← bookmarkApi usersByGame pov.game
|
||||
pgn ← pgnDump >> pov.game
|
||||
analysis ← analyser get pov.game.id
|
||||
tour ← tournamentRepo byId pov.game.tournamentId
|
||||
} yield html.analyse.replay(
|
||||
pov,
|
||||
pgn.toString,
|
||||
|
@ -48,7 +50,8 @@ object Analyse extends LilaController {
|
|||
bookmarkers,
|
||||
openingExplorer openingOf pov.game.pgn,
|
||||
analysis,
|
||||
roundSocket blockingVersion pov.gameId)
|
||||
roundSocket blockingVersion pov.gameId,
|
||||
tour)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
private def bookmarkApi = env.bookmark.api
|
||||
private def userRepo = env.user.userRepo
|
||||
private def analyser = env.analyse.analyser
|
||||
private def isTournamentInProgress(id: Option[String]) =
|
||||
id.fold(env.tournament.tournamentIds.contains, false)
|
||||
private def tournamentRepo = env.tournament.repo
|
||||
|
||||
def websocketWatcher(gameId: String, color: String) = WebSocket.async[JsValue] { req ⇒
|
||||
implicit val ctx = reqToCtx(req)
|
||||
|
@ -55,6 +54,7 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
u ⇒ userRepo isEngine u,
|
||||
io(false))
|
||||
analysed ← analyser has pov.gameId
|
||||
tour ← tournamentRepo byId pov.game.tournamentId
|
||||
} yield PreventTheft(pov) {
|
||||
Ok(html.round.player(
|
||||
pov,
|
||||
|
@ -63,7 +63,7 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
roomHtml map { Html(_) },
|
||||
bookmarkers,
|
||||
analysed,
|
||||
tournamentInProgress = isTournamentInProgress(pov.game.tournamentId)))
|
||||
tour = tour))
|
||||
},
|
||||
io(Redirect(routes.Setup.await(fullId)))
|
||||
)
|
||||
|
@ -89,7 +89,8 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
)
|
||||
roomHtml ← messenger renderWatcher pov.game
|
||||
analysed ← analyser has pov.gameId
|
||||
} yield Ok(html.round.watcher(pov, version(pov.gameId), Html(roomHtml), bookmarkers, analysed))
|
||||
tour ← tournamentRepo byId pov.game.tournamentId
|
||||
} yield Ok(html.round.watcher(pov, version(pov.gameId), Html(roomHtml), bookmarkers, analysed, tour))
|
||||
|
||||
def abort(fullId: String) = performAndRedirect(fullId, hand.abort)
|
||||
def resign(fullId: String) = performAndRedirect(fullId, hand.resign)
|
||||
|
@ -126,10 +127,12 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
}
|
||||
|
||||
def tablePlayer(fullId: String) = Open { implicit ctx ⇒
|
||||
IOptionOk(gameRepo pov fullId) { pov ⇒
|
||||
pov.game.playable.fold(
|
||||
html.round.table.playing(pov),
|
||||
html.round.table.end(pov, isTournamentInProgress(pov.game.tournamentId)))
|
||||
IOptionIOk(gameRepo pov fullId) { pov ⇒
|
||||
tournamentRepo byId pov.game.tournamentId map { tour ⇒
|
||||
pov.game.playable.fold(
|
||||
html.round.table.playing(pov),
|
||||
html.round.table.end(pov, tour))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import play.api.templates.Html
|
|||
|
||||
trait AssetHelper {
|
||||
|
||||
val assetVersion = 89
|
||||
val assetVersion = 90
|
||||
|
||||
def cssTag(name: String) = css("stylesheets/" + name)
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ case class Pairing(
|
|||
if (user == user1) user2.some else if (user == user2) user1.some else none
|
||||
|
||||
def wonBy(user: String): Boolean = winner.fold(user ==, false)
|
||||
def hasWinner: Boolean = winner.nonEmpty
|
||||
def draw: Boolean = finished && winner.nonEmpty
|
||||
|
||||
def colorOf(userId: String): Option[Color] =
|
||||
if (userId == user1) Color.White.some
|
||||
|
|
|
@ -42,7 +42,7 @@ sealed trait Tournament {
|
|||
|
||||
def userIds = players map (_.id)
|
||||
def activeUserIds = players filter (_.active) map (_.id)
|
||||
def nbActiveUsers = players count (_.active)
|
||||
def nbActiveUsers = players count (_.active)
|
||||
def nbPlayers = players.size
|
||||
def minPlayers = data.minPlayers
|
||||
def playerRatio = "%d/%d".format(nbPlayers, minPlayers)
|
||||
|
@ -147,9 +147,13 @@ case class Started(
|
|||
|
||||
def readyToFinish = (remainingSeconds == 0) || (nbActiveUsers < 2)
|
||||
|
||||
def remainingSeconds: Int = math.max(0, finishedAt.getSeconds - nowSeconds).toInt
|
||||
def remainingSeconds: Float = math.max(0f,
|
||||
((finishedAt.getMillis - nowMillis) / 1000).toFloat
|
||||
)
|
||||
|
||||
def clockStatus = "%02d:%02d".format(remainingSeconds / 60, remainingSeconds % 60)
|
||||
def clockStatus = remainingSeconds.toInt |> { s ⇒
|
||||
"%02d:%02d".format(s / 60, s % 60)
|
||||
}
|
||||
|
||||
def userCurrentPov(userId: String): Option[PovRef] = {
|
||||
playingPairings map { _ povRef userId }
|
||||
|
|
|
@ -74,9 +74,4 @@ final class TournamentEnv(
|
|||
api = api,
|
||||
hubMaster = hubMaster
|
||||
)), name = ActorTournamentOrganizer)
|
||||
|
||||
def tournamentIds = tournamentIdsMemo.apply
|
||||
|
||||
private lazy val tournamentIdsMemo =
|
||||
new MonoMemo(TournamentMemoTtl, repo.inProgressIds)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ class TournamentRepo(collection: MongoCollection)
|
|||
extends SalatDAO[RawTournament, String](collection) {
|
||||
|
||||
def byId(id: String): IO[Option[Tournament]] = byIdAs(id, _.any)
|
||||
def byId(id: Option[String]): IO[Option[Tournament]] = id.fold(byId, io(none))
|
||||
|
||||
def createdById(id: String): IO[Option[Created]] = byIdAs(id, _.created)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(pov: Pov, pgn: String, roomHtml: Html, bookmarkers: List[User], opening: Option[chess.OpeningExplorer.Opening], analysis: Option[lila.analyse.Analysis], version: Int)(implicit ctx: Context)
|
||||
@(pov: Pov, pgn: String, roomHtml: Html, bookmarkers: List[User], opening: Option[chess.OpeningExplorer.Opening], analysis: Option[lila.analyse.Analysis], version: Int, tour: Option[lila.tournament.Tournament])(implicit ctx: Context)
|
||||
|
||||
@import pov._
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
@analyse.layout(
|
||||
title = trans.replayAndAnalyse() + " " + gameId,
|
||||
goodies = views.html.game.infoBox(pov).some,
|
||||
goodies = views.html.game.infoBox(pov, tour).some,
|
||||
chat = round.room(roomHtml, true).some,
|
||||
underchat = underchat.some,
|
||||
moreCss = moreCss,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(pov: Pov)(implicit ctx: Context)
|
||||
@(pov: Pov, tour: Option[lila.tournament.Tournament])(implicit ctx: Context)
|
||||
|
||||
@import pov._
|
||||
|
||||
|
@ -10,8 +10,8 @@
|
|||
@game.updatedAt.map(showDate)
|
||||
}
|
||||
<br /><br />
|
||||
@game.tournamentId.map { tourId =>
|
||||
<a class="tournament_link s16" href="@routes.Tournament.show(tourId)">Tournament</a>
|
||||
@tour.map { t =>
|
||||
@tournament.linkTo(t)
|
||||
<br /><br />
|
||||
}
|
||||
@if(game.finishedOrAborted) {
|
||||
|
@ -35,4 +35,17 @@
|
|||
, @trans.rated()<br />
|
||||
}
|
||||
</div>
|
||||
|
||||
@tour match {
|
||||
case Some(t: lila.tournament.Started) => {
|
||||
<div class="game_tournament box">
|
||||
<span class="title">@t.nameT</span>
|
||||
<span class="clock" data-time="@t.remainingSeconds">
|
||||
@t.clockStatus
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
case _ => {
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(pov: Pov, version: Int, engine: Boolean, roomHtml: Option[Html], bookmarkers: List[User], analysed: Boolean, tournamentInProgress: Boolean)(implicit ctx: Context)
|
||||
@(pov: Pov, version: Int, engine: Boolean, roomHtml: Option[Html], bookmarkers: List[User], analysed: Boolean, tour: Option[lila.tournament.Tournament])(implicit ctx: Context)
|
||||
|
||||
@import pov._
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
@round.layout(
|
||||
title = title,
|
||||
goodies = views.html.game.infoBox(pov),
|
||||
goodies = views.html.game.infoBox(pov, tour),
|
||||
chat = roomHtml.map(round.room(_, false)),
|
||||
underchat = underchat.some) {
|
||||
<div class="lichess_game clearfix lichess_player_@color not_spectator"
|
||||
|
@ -36,7 +36,7 @@ underchat = underchat.some) {
|
|||
</div>
|
||||
<div class="lichess_separator"></div>
|
||||
<div class="table_inner">
|
||||
@game.playable.fold(round.table.playing(pov), round.table.end(pov, tournamentInProgress))
|
||||
@game.playable.fold(round.table.playing(pov), round.table.end(pov, tour))
|
||||
</div>
|
||||
</div>
|
||||
@game.clock.map { c =>
|
||||
|
@ -51,7 +51,7 @@ underchat = underchat.some) {
|
|||
</div>
|
||||
<script type="text/javascript">var lichess_data = @Html(roundPlayerJsData(pov, version))</script>
|
||||
@analyse.link(pov, analysed)
|
||||
@if(!tournamentInProgress) {
|
||||
@if(!tour.fold(_.isRunning, false)) {
|
||||
@views.html.game.more(pov, bookmarkers) {
|
||||
<nav>
|
||||
<a href="@routes.Analyse.replay(gameId, color.name)">@trans.replayAndAnalyse()</a>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(pov: Pov, tournamentInProgress: Boolean)(implicit ctx: Context)
|
||||
@(pov: Pov, tour: Option[lila.tournament.Tournament])(implicit ctx: Context)
|
||||
|
||||
@import pov._
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
|||
<div class="lichess_control buttons">
|
||||
@game.tournamentId.map { tourId =>
|
||||
<a
|
||||
class="button @tournamentInProgress.fold("strong", "") view_tournament"
|
||||
class="button @tour.fold(_.isRunning, false).fold("strong", "") view_tournament"
|
||||
href="@routes.Tournament.show(tourId)">Back to Tournament</a>
|
||||
}.getOrElse {
|
||||
@if(opponent.isHuman) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(pov: Pov, version: Int, roomHtml: Html, bookmarkers: List[User], analysed: Boolean)(implicit ctx: Context)
|
||||
@(pov: Pov, version: Int, roomHtml: Html, bookmarkers: List[User], analysed: Boolean, tour: Option[lila.tournament.Tournament])(implicit ctx: Context)
|
||||
|
||||
@import pov._
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
@round.layout(
|
||||
title = title,
|
||||
goodies = views.html.game.infoBox(pov),
|
||||
goodies = views.html.game.infoBox(pov, tour),
|
||||
chat = round.room(roomHtml, true).some,
|
||||
underchat = underchat.some) {
|
||||
<div class="lichess_game clearfix lichess_player_@color"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
@number
|
||||
@{ Html(pairing.users.map(u =>
|
||||
"<span class='%s'>%s</span>".format(
|
||||
pairing.finished.fold(pairing.hasWinner.fold(pairing.wonBy(u).fold("win", "loss"), "draw"), "playing"),
|
||||
pairing.finished.fold(pairing.draw.fold("draw", pairing.wonBy(u).fold("win", "loss")), "playing"),
|
||||
userIdToUsername(u)
|
||||
)).mkString(" vs "))
|
||||
}
|
||||
|
|
|
@ -15,6 +15,10 @@ $.widget("lichess.game", {
|
|||
self.options.socketUrl = self.element.data('socket-url');
|
||||
self.socketAckTimeout;
|
||||
|
||||
$("div.game_tournament .clock").each(function() {
|
||||
$(this).clock({time: $(this).data("time")}).clock("start");
|
||||
});
|
||||
|
||||
if (self.options.game.started) {
|
||||
self.indicateTurn();
|
||||
self.initSquaresAndPieces();
|
||||
|
|
|
@ -703,6 +703,21 @@ div.lichess_chat.hidden ol.lichess_messages, div.lichess_chat.hidden form {
|
|||
opacity: 0;
|
||||
}
|
||||
|
||||
div.game_tournament {
|
||||
text-align: center;
|
||||
}
|
||||
div.game_tournament .title {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
}
|
||||
div.game_tournament .clock {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
font-size: 20px;
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.inline_userlist span.list {
|
||||
display: inline;
|
||||
color: #9a9a9a;
|
||||
|
|
5
todo
5
todo
|
@ -46,4 +46,9 @@ all hub members should use userIds rather than usernames
|
|||
add opera to list of supported browsers (with websocket trick)
|
||||
tournament ties
|
||||
tournament detect leavers and withdraw them (started) (also use force resign)
|
||||
^ game with no move = withdraw
|
||||
tournament show clock on game page
|
||||
tournament withdraw resigns playing games
|
||||
tournament make pairings overflow hidden http://en.lichess.org/tournament/kswnkqr3
|
||||
tournament only show trophy when tour is over
|
||||
send lobby new forum posts html through websockets
|
||||
|
|
Loading…
Reference in a new issue