remove tournament rocket start

This commit is contained in:
Thibault Duplessis 2016-07-27 00:09:57 +02:00
parent 616145f606
commit 50dd84e41d
6 changed files with 9 additions and 29 deletions

View file

@ -32,11 +32,6 @@
<br />
For example, two wins followed by a draw will be worth 6 points: 2 + 2 + (2 x 1)
<h2>Rocket Start</h2>
If you are present at the beginning of the tournament, and you win your first game,
that's a <strong>rocket start!</strong> It puts you in a <streak>winning streak</streak>
and you get <double>double points</double> immediately.
<h2>Arena Berserk</h2>
When a player clicks the <em>Berserk</em> button at the beginning of the game,
they lose half of their clock time, but the win is worth one extra tournament point.

View file

@ -128,8 +128,7 @@ object BSONHandlers {
winner = r boolO "w" map (_.fold(user1, user2)),
turns = r intO "t",
berserk1 = r intD "b1",
berserk2 = r intD "b2",
initial = r boolD "i")
berserk2 = r intD "b2")
}
def writes(w: BSON.Writer, o: Pairing) = BSONDocument(
"_id" -> o.id,
@ -139,8 +138,7 @@ object BSONHandlers {
"w" -> o.winner.map(o.user1 ==),
"t" -> o.turns,
"b1" -> w.intO(o.berserk1),
"b2" -> w.intO(o.berserk2),
"i" -> w.boolO(o.initial))
"b2" -> w.intO(o.berserk2))
}
implicit val leaderboardEntryHandler = new BSON[LeaderboardApi.Entry] {

View file

@ -14,8 +14,7 @@ case class Pairing(
winner: Option[String],
turns: Option[Int],
berserk1: Int,
berserk2: Int,
initial: Boolean) {
berserk2: Int) {
def gameId = id
@ -58,8 +57,6 @@ case class Pairing(
colorOf(userId) map { PovRef(gameId, _) }
def similar(other: Pairing) = other.contains(user1, user2)
def setInitial = copy(initial = true)
}
private[tournament] object Pairing {
@ -75,8 +72,7 @@ private[tournament] object Pairing {
winner = none,
turns = none,
berserk1 = 0,
berserk2 = 0,
initial = false)
berserk2 = 0)
case class Prep(tourId: String, user1: String, user2: String) {
def toPairing(firstGetsWhite: Boolean) =

View file

@ -62,7 +62,7 @@ case class Tournament(
def isRecentlyFinished = isFinished && (nowSeconds - finishesAt.getSeconds) < 30 * 60
def isRecentlyStarted = isStarted && (nowSeconds - startsAt.getSeconds) < 3
def isRecentlyStarted = isStarted && (nowSeconds - startsAt.getSeconds) < 15
def duration = new Duration(minutes * 60 * 1000)

View file

@ -33,10 +33,7 @@ private[tournament] object PairingSystem extends AbstractPairingSystem {
case _ => evenOrAll(data, users)
}
pairings <- prepsToPairings(preps)
} yield {
if (data.isFirstRound) pairings.map(_.setInitial)
else pairings
}
} yield pairings
}.chronometer.logIfSlow(500, pairingLogger) { pairings =>
s"createPairings ${url(tour.id)} ${pairings.size} pairings"
}.result
@ -53,7 +50,7 @@ private[tournament] object PairingSystem extends AbstractPairingSystem {
import data._
if (users.size < 2) fuccess(Nil)
else PlayerRepo.rankedByTourAndUserIds(tour.id, users, ranking) map { idles =>
if (isFirstRound) naivePairings(tour, idles)
if (data.tour.isRecentlyStarted) naivePairings(tour, idles)
else idles.grouped(pairingGroupSize).toList match {
case a :: b :: c :: _ => smartPairings(data, a) ::: smartPairings(data, b) ::: naivePairings(tour, c take pairingGroupSize)
case a :: b :: Nil => smartPairings(data, a) ::: smartPairings(data, b)

View file

@ -27,8 +27,6 @@ private[tournament] object ScoringSystem extends AbstractScoringSystem {
def isBerserk = berserk > 0
def isWin = win contains true
def isDoubleWin = isWin && flag == Double
}
case class Sheet(scores: List[Score]) extends ScoreSheet {
@ -51,7 +49,7 @@ private[tournament] object ScoringSystem extends AbstractScoringSystem {
berserkValue)
case Some(w) if userId == w => Score(
Some(true),
if (p.initial || isOnFire(scores)) Double
if (isOnFire(scores)) Double
else if (scores.headOption ?? (_.flag == StreakStarter)) StreakStarter
else n.flatMap(_.winner) match {
case Some(w) if userId == w => StreakStarter
@ -63,12 +61,8 @@ private[tournament] object ScoringSystem extends AbstractScoringSystem {
}
}
private def isOnFire(scores: List[Score]) =
firstIsDoubleWin(scores) || firstTwoAreWins(scores)
private def isOnFire = firstTwoAreWins _
private def firstTwoAreWins(scores: List[Score]) =
(scores.size >= 2) && (scores take 2 forall (~_.win))
private def firstIsDoubleWin(scores: List[Score]) =
scores.headOption.??(_.isDoubleWin)
}