Bug fixes

pull/3300/head
Isaac Levy 2017-07-21 18:53:08 -04:00
parent b028b7bce5
commit 00b3c1c09e
5 changed files with 40 additions and 30 deletions

View File

@ -219,7 +219,8 @@ object Event {
def data = Json.obj(
"winner" -> game.winnerColor,
"status" -> game.status
).add("ratingDiff" -> ratingDiff.map { rds =>
).add("clock" -> game.clock.map { c => Clock(c).data })
.add("ratingDiff" -> ratingDiff.map { rds =>
Json.obj(
Color.White.name -> rds.white,
Color.Black.name -> rds.black

View File

@ -375,35 +375,43 @@ case class Game(
else history.reset(color).record(color, newClock)
})
).updatePlayer(color, _.goBerserk)) ++
List(Event.Clock(newClock), Event.Berserk(color))
List(
Event.ClockInc(color, -c.config.berserkPenalty),
Event.Clock(newClock), // BC
Event.Berserk(color)
)
}
def resignable = playable && !abortable
def drawable = playable && !abortable
def finish(status: Status, winner: Option[Color]) = Progress(
this,
copy(
status = status,
whitePlayer = whitePlayer.finish(winner contains White),
blackPlayer = blackPlayer.finish(winner contains Black),
clock = clock map (_.stop),
clockHistory = for {
clk <- clock
history <- clockHistory
} yield {
// If not already finished, we're ending due to an event
// in the middle of a turn, such as resignation or draw
// acceptance. In these cases, record a final clock time
// for the active color. This ensures the end time in
// clockHistory always matches the final clock time on
// the board.
if (!finished) history.record(turnColor, clk)
else history
}
),
List(Event.End(winner)) ::: clock.??(c => List(Event.Clock(c)))
)
def finish(status: Status, winner: Option[Color]) = {
val newClock = clock map { _.stop }
Progress(
this,
copy(
status = status,
whitePlayer = whitePlayer.finish(winner contains White),
blackPlayer = blackPlayer.finish(winner contains Black),
clock = newClock,
clockHistory = for {
clk <- clock
history <- clockHistory
} yield {
// If not already finished, we're ending due to an event
// in the middle of a turn, such as resignation or draw
// acceptance. In these cases, record a final clock time
// for the active color. This ensures the end time in
// clockHistory always matches the final clock time on
// the board.
if (!finished) history.record(turnColor, clk)
else history
}
),
// Events here for BC.
List(Event.End(winner)) ::: newClock.??(c => List(Event.Clock(c)))
)
}
def rated = mode.rated
def casual = !rated

View File

@ -53,9 +53,6 @@ object Rewind {
clock = newClock,
movedAt = DateTime.now
)
Progress(game, newGame, List(
newGame.clock.map(Event.Clock.apply),
newGame.playableCorrespondenceClock.map(Event.CorrespondenceClock.apply)
).flatten)
Progress(game, newGame)
}
}

View File

@ -225,7 +225,10 @@ private[round] final class Round(
messenger.system(game, (_.untranslated(
"%s + %d seconds".format(color, duration.toSeconds)
)))
(game withClock newClock) ++ List(Event.ClockInc(color, centis), Event.Clock(newClock))
(game withClock newClock) ++ List(
Event.ClockInc(color, centis),
Event.Clock(newClock) // BC
)
}
private def reportNetworkLag(pov: Pov) =

View File

@ -455,6 +455,7 @@ export default class RoundController {
this.moveOn.next();
this.setQuietMode();
this.setLoading(false);
if (this.clock) this.clock.setClock(d, d.clock!.white, d.clock!.black);
this.redraw();
this.autoScroll();
this.onChange();