don't start or add time to swiss clocks
but start them when they expirepull/6572/head
parent
963b2eb7c1
commit
b579c416fb
|
@ -249,6 +249,11 @@ case class Game(
|
|||
mode = Mode(mode.rated && userIds.distinct.size == 2)
|
||||
)
|
||||
|
||||
def startClock =
|
||||
clock map { c =>
|
||||
start.withClock(c.start)
|
||||
}
|
||||
|
||||
def correspondenceClock: Option[CorrespondenceClock] =
|
||||
daysPerTurn map { days =>
|
||||
val increment = days * 24 * 60 * 60
|
||||
|
@ -492,7 +497,9 @@ case class Game(
|
|||
}
|
||||
|
||||
def expirable =
|
||||
!bothPlayersHaveMoved && source.exists(Source.expirable.contains) && playable && nonAi && hasClock
|
||||
!bothPlayersHaveMoved && source.exists(Source.expirable.contains) && playable && nonAi && clock.exists(
|
||||
!_.isRunning
|
||||
)
|
||||
|
||||
def timeBeforeExpiration: Option[Centis] =
|
||||
expirable option {
|
||||
|
|
|
@ -26,7 +26,7 @@ object Source {
|
|||
} toMap
|
||||
|
||||
val searchable = List(Lobby, Friend, Ai, Position, Import, Tournament, Simul, Pool, Swiss)
|
||||
val expirable: Set[Source] = Set(Lobby, Tournament, Pool)
|
||||
val expirable: Set[Source] = Set(Lobby, Tournament, Pool, Swiss)
|
||||
|
||||
def apply(id: Int): Option[Source] = byId get id
|
||||
}
|
||||
|
|
|
@ -421,7 +421,12 @@ final private[round] class RoundDuct(
|
|||
|
||||
case NoStart =>
|
||||
handle { game =>
|
||||
game.timeBeforeExpiration.exists(_.centis == 0) ?? finisher.noStart(game)
|
||||
game.timeBeforeExpiration.exists(_.centis == 0) ?? {
|
||||
if (game.isSwiss) game.startClock ?? { g =>
|
||||
proxy save g inject List(Event.Reload)
|
||||
}
|
||||
else finisher.noStart(game)
|
||||
}
|
||||
}
|
||||
|
||||
case FishnetStart =>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package lila.swiss
|
||||
|
||||
import chess.{ Black, Centis, Color, White }
|
||||
import chess.{ Black, Color, White }
|
||||
import org.joda.time.DateTime
|
||||
import scala.util.chaining._
|
||||
|
||||
|
@ -106,11 +106,7 @@ final private class SwissDirector(
|
|||
) pipe { g =>
|
||||
val turns = g.player.fold(0, 1)
|
||||
g.copy(
|
||||
clock = swiss.clock.toClock
|
||||
.giveTime(White, Centis(300))
|
||||
.giveTime(Black, Centis(300))
|
||||
.start
|
||||
.some,
|
||||
clock = swiss.clock.toClock.some,
|
||||
turns = turns,
|
||||
startedAtTurn = turns
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue