don't play clock emergency sounds on simul - resolves #177
This commit is contained in:
parent
2f599183a8
commit
bd98f747d1
|
@ -56,7 +56,7 @@ object Round extends LilaController with TheftPrevention {
|
||||||
Env.game.crosstableApi(pov.game) zip
|
Env.game.crosstableApi(pov.game) zip
|
||||||
otherPovs(pov.gameId) flatMap {
|
otherPovs(pov.gameId) flatMap {
|
||||||
case ((tour, crosstable), playing) =>
|
case ((tour, crosstable), playing) =>
|
||||||
Env.api.roundApi.player(pov, Env.api.version) map { data =>
|
Env.api.roundApi.player(pov, Env.api.version, playing) map { data =>
|
||||||
Ok(html.round.player(pov, data, tour = tour, cross = crosstable, playing = playing))
|
Ok(html.round.player(pov, data, tour = tour, cross = crosstable, playing = playing))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ object Round extends LilaController with TheftPrevention {
|
||||||
Redirect(routes.Setup.await(fullId)).fuccess
|
Redirect(routes.Setup.await(fullId)).fuccess
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
api = apiVersion => Env.api.roundApi.player(pov, apiVersion) map { Ok(_) }
|
api = apiVersion => Env.api.roundApi.player(pov, apiVersion, Nil) map { Ok(_) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ object Round extends LilaController with TheftPrevention {
|
||||||
|
|
||||||
private def join(pov: Pov)(implicit ctx: Context): Fu[Result] =
|
private def join(pov: Pov)(implicit ctx: Context): Fu[Result] =
|
||||||
GameRepo initialFen pov.gameId zip
|
GameRepo initialFen pov.gameId zip
|
||||||
Env.api.roundApi.player(pov, Env.api.version) zip
|
Env.api.roundApi.player(pov, Env.api.version, otherPovs = Nil) zip
|
||||||
((pov.player.userId orElse pov.opponent.userId) ?? UserRepo.byId) map {
|
((pov.player.userId orElse pov.opponent.userId) ?? UserRepo.byId) map {
|
||||||
case ((fen, data), opponent) => Ok(html.setup.join(
|
case ((fen, data), opponent) => Ok(html.setup.join(
|
||||||
pov, data, opponent, Env.setup.friendConfigMemo get pov.game.id, fen))
|
pov, data, opponent, Env.setup.friendConfigMemo get pov.game.id, fen))
|
||||||
|
|
|
@ -138,7 +138,7 @@ object Setup extends LilaController with TheftPrevention with play.api.http.Cont
|
||||||
OptionFuResult(GameRepo pov fullId) { pov =>
|
OptionFuResult(GameRepo pov fullId) { pov =>
|
||||||
pov.game.started.fold(
|
pov.game.started.fold(
|
||||||
Redirect(routes.Round.player(pov.fullId)).fuccess,
|
Redirect(routes.Round.player(pov.fullId)).fuccess,
|
||||||
Env.api.roundApi.player(pov, Env.api.version) zip
|
Env.api.roundApi.player(pov, Env.api.version, otherPovs = Nil) zip
|
||||||
(userId ?? UserRepo.named) flatMap {
|
(userId ?? UserRepo.named) flatMap {
|
||||||
case (data, user) => PreventTheft(pov) {
|
case (data, user) => PreventTheft(pov) {
|
||||||
Ok(html.setup.await(
|
Ok(html.setup.await(
|
||||||
|
@ -185,7 +185,7 @@ object Setup extends LilaController with TheftPrevention with play.api.http.Cont
|
||||||
config => op(config)(ctx) flatMap {
|
config => op(config)(ctx) flatMap {
|
||||||
case (pov, call) => negotiate(
|
case (pov, call) => negotiate(
|
||||||
html = fuccess(redirectPov(pov, call)),
|
html = fuccess(redirectPov(pov, call)),
|
||||||
api = apiVersion => Env.api.roundApi.player(pov, apiVersion) map { data =>
|
api = apiVersion => Env.api.roundApi.player(pov, apiVersion, otherPovs = Nil) map { data =>
|
||||||
Created(data) as JSON
|
Created(data) as JSON
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,13 +18,13 @@ private[api] final class RoundApi(
|
||||||
analysisApi: AnalysisApi,
|
analysisApi: AnalysisApi,
|
||||||
lightUser: String => Option[LightUser]) {
|
lightUser: String => Option[LightUser]) {
|
||||||
|
|
||||||
def player(pov: Pov, apiVersion: Int)(implicit ctx: Context): Fu[JsObject] =
|
def player(pov: Pov, apiVersion: Int, otherPovs: List[Pov])(implicit ctx: Context): Fu[JsObject] =
|
||||||
jsonView.playerJson(pov, ctx.pref, apiVersion, ctx.me,
|
jsonView.playerJson(pov, ctx.pref, apiVersion, ctx.me,
|
||||||
withBlurs = ctx.me ?? Granter(_.ViewBlurs)) zip
|
withBlurs = ctx.me ?? Granter(_.ViewBlurs)) zip
|
||||||
(pov.game.tournamentId ?? TournamentRepo.byId) zip
|
(pov.game.tournamentId ?? TournamentRepo.byId) zip
|
||||||
(ctx.me ?? (me => noteApi.get(pov.gameId, me.id))) map {
|
(ctx.me ?? (me => noteApi.get(pov.gameId, me.id))) map {
|
||||||
case ((json, tourOption), note) => (
|
case ((json, tourOption), note) => (
|
||||||
blindMode _ compose withTournament(tourOption)_ compose withNote(note)_
|
blindMode _ compose withTournament(tourOption)_ compose withNote(note)_ compose withOtherPovs(otherPovs)_
|
||||||
)(json)
|
)(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ private[api] final class RoundApi(
|
||||||
)(json)
|
)(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def withOtherPovs(otherPovs: List[Pov])(json: JsObject) =
|
||||||
|
if (otherPovs.isEmpty) json else json + ("simul" -> JsBoolean(true))
|
||||||
|
|
||||||
private def withNote(note: String)(json: JsObject) =
|
private def withNote(note: String)(json: JsObject) =
|
||||||
if (note.isEmpty) json else json + ("note" -> JsString(note))
|
if (note.isEmpty) json else json + ("note" -> JsString(note))
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ module.exports = function(opts) {
|
||||||
|
|
||||||
this.clock = this.data.clock ? new clockCtrl(
|
this.clock = this.data.clock ? new clockCtrl(
|
||||||
this.data.clock,
|
this.data.clock,
|
||||||
throttle(partial(this.socket.send, 'outoftime'), this.data.player.spectator ? 1000 : 500), (this.data.player.spectator || !this.data.pref.clockSound) ? null : this.data.player.color
|
throttle(partial(this.socket.send, 'outoftime'), this.data.player.spectator ? 1000 : 500), (this.data.simul || this.data.player.spectator || !this.data.pref.clockSound) ? null : this.data.player.color
|
||||||
) : false;
|
) : false;
|
||||||
|
|
||||||
this.isClockRunning = function() {
|
this.isClockRunning = function() {
|
||||||
|
|
Loading…
Reference in a new issue