Skip to content

Commit

Permalink
improve tournament doc and form
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 28, 2012
1 parent 1c995a6 commit 7d03608
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 20 deletions.
2 changes: 2 additions & 0 deletions app/controllers/Tournament.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ object Tournament extends LilaController {
)
}

val faq = Open { implicit ctx Ok(html.tournament.faqPage()) }

val homeReload = Open { implicit ctx
IOk(
for {
Expand Down
4 changes: 2 additions & 2 deletions app/templating/AssetHelper.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package lila
package templating

import controllers._
import controllers.routes

import play.api.templates.Html

trait AssetHelper {

val assetVersion = 10
val assetVersion = 11

def cssTag(name: String) = css("stylesheets/" + name)

Expand Down
1 change: 1 addition & 0 deletions app/templating/Environment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object Environment
with scalaz.Options
with scalaz.Booleans
with StringHelper
with MarkdownHelper
with AssetHelper
with UiHelper
with RequestHelper
Expand Down
19 changes: 19 additions & 0 deletions app/templating/MarkdownHelper.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package lila
package templating

import com.roundeights.hasher.Implicits._
import eu.henkelmann.actuarius.ActuariusTransformer
import play.api.templates.Html

trait MarkdownHelper {

private val cache = collection.mutable.Map[String, Html]()

def markdown(text: String): Html = cache.getOrElseUpdate(text.md5, doMarkdown(text))

def markdown(text: Html): Html = markdown(text.toString)

private def doMarkdown(text: String) = Html {
new ActuariusTransformer() apply text
}
}
34 changes: 34 additions & 0 deletions app/views/tournament/faq.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@(players: String = "all")

@text = {

## When will the tournament start?
As soon as @players players join it.
You will be notified when the tournament starts, so it is safe to
<a target="_blank" href="@routes.Lobby.home()">play in another tab</a> while waiting.

## Is it rated?
No, tournament games won't impact your ELO.

## How to win?
The players with the more points at the end of the tournament duration wins.
A game win is worth 2 points, a draw 1 point, and a defeat 0 points.

## How does the pairing work?
At the beginning of the tournament, players are paired randomly.
As soon as you finish a game, return to the tournament lobby:
you will then be paired with the first available player. This ensures minimum wait time,
but you may not play every other players of the tournament. It is normal.
Play fast and return to the lobby to play more games and win more points.

## What is the win streak?
It represents the number of games won in a row. It is added to the points you win.
For instance, if you win 3 games in a row, you get 2 + 3 points for the last game.
If you lose a game, your win streak returns to zero.

## How does it end?
The tournament has a countdown clock. When it reaches zero, all current tournament games
are cancelled. The tournament ranking is frozen, and the winner is known.
}

<article class="faq">@markdown(text)</article>
17 changes: 17 additions & 0 deletions app/views/tournament/faqPage.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@()(implicit ctx: Context)

@goodies = {
<div class="tournament_links">
<a href="@routes.Tournament.home()">Back to tournaments</a>
</div>
}

@tournament.layout(title = "Tournament FAQ", goodies = goodies.some) {
<div id="tournament">
<div class="content_box small_box faq_page">
<h1>Tournament FAQ</h1>
@tournament.faq()
</div>
</div>
}

21 changes: 9 additions & 12 deletions app/views/tournament/form.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@tournament.layout(
title = "New tournament") {
<div id="tournament">
<div class="content_box tournament_box">
<div class="content_box small_box tournament_box">
<h1>New tournament</h1>
<form class="plain create content_box_content" action="@routes.Tournament.create" method="POST">
@form.globalError.map { error =>
Expand All @@ -14,31 +14,25 @@ <h1>New tournament</h1>
<table>
<tr>
<th>
<label for="@form("clockTime").id">Clock time</label>
<label>Game clock</label>
</th>
<td>
<td class="inline">
@base.select(form("clockTime"), config.clockTimeChoices)
</td>
</tr>
<tr>
<th>
<label for="@form("clockIncrement").id">Clock increment</label>
</th>
<td>
+
@base.select(form("clockIncrement"), config.clockIncrementChoices)
</td>
</tr>
<tr>
<th>
<label for="@form("minutes").id">Duration</label>
<label for="@form("minutes").id">Tournament duration</label>
</th>
<td>
@base.select(form("minutes"), config.minuteChoices)
</td>
</tr>
<tr>
<th>
<label for="@form("minPlayers").id">Players</label>
<label for="@form("minPlayers").id">Number of players</label>
</th>
<td>
@base.select(form("minPlayers"), config.minPlayerChoices)
Expand All @@ -55,5 +49,8 @@ <h1>New tournament</h1>
</table>
</form>
</div>
<div class="content_box small_box faq_box tournament_box">
<div class="content_box_content">@tournament.faq()</div>
</div>
</div>
}
9 changes: 8 additions & 1 deletion app/views/tournament/home.scala.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
@(createds: List[lila.tournament.Created], starteds: List[lila.tournament.Started], finisheds: List[lila.tournament.Finished])(implicit ctx: Context)

@goodies = {
<div class="tournament_links">
<a href="@routes.Tournament.faq()">Tournament FAQ</a>
</div>
}

@tournament.layout(
title = "Tournaments") {
title = "Tournaments",
goodies = goodies.some) {
<div id="tournament" data-href="@routes.Tournament.homeReload()">
@tournament.homeInner(createds, starteds, finisheds)
</div>
Expand Down
6 changes: 1 addition & 5 deletions app/views/tournament/show/createdInner.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,4 @@ <h1>@tour.nameT</h1>
</table>
</div>
<br />
<div class="content_box_content">
The tournament will start as soon as @tour.minPlayers players join it.<br />
Always stay on the tournament page! So you get paired with a player.
</div>

<div class="content_box_content">@tournament.faq(tour.minPlayers.toString)</div>
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ GET /tournament/$id<[\w\-]{8}>/socket controllers.Tournament.websocket(i
POST /tournament/$id<[\w\-]{8}>/join controllers.Tournament.join(id: String)
POST /tournament/$id<[\w\-]{8}>/withdraw controllers.Tournament.withdraw(id: String)
GET /tournament/$id<[\w\-]{8}>/reload controllers.Tournament.reload(id: String)
GET /tournament/faq controllers.Tournament.faq

# Analyse
GET /analyse/$gameId<[\w\-]{8}> controllers.Analyse.replay(gameId: String, color: String = "white")
Expand Down
23 changes: 23 additions & 0 deletions public/stylesheets/tournament.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

#tournament form.plain td {
padding: 0.6em;
white-space: nowrap;
}

#tournament form.plain label {
Expand All @@ -108,6 +109,9 @@
text-transform: capitalize;
width: 99%;
}
#tournament form.plain .inline select {
width: 46%;
}

#tournament form.plain input.submit {
width: 99%;
Expand Down Expand Up @@ -151,3 +155,22 @@
#tournament_side div.pairings span.draw {
color: #aaaa00;
}

#tournament article.faq h2 {
font-weight: bold;
font-style: italic;
}
#tournament article.faq p {
margin: 0.5em 0 2em 0;
}
div.faq_page h1 {
display: block;
margin-bottom: 1em;
}
div.faq_box {
margin-top: 15px;
}

div.header .tournament_links {
margin-top: 2em;
}

0 comments on commit 7d03608

Please sign in to comment.