diff --git a/field/arena.go b/field/arena.go index ee2afe03..30f2d18e 100755 --- a/field/arena.go +++ b/field/arena.go @@ -361,6 +361,25 @@ func (arena *Arena) StartTimeout(durationSec int) error { return nil } +// Updates the audience display screen. +func (arena *Arena) SetAudienceDisplayMode(mode string) { + if arena.AudienceDisplayMode != mode { + arena.AudienceDisplayMode = mode + arena.AudienceDisplayModeNotifier.Notify() + if mode == "score" { + arena.playSound("match_result") + } + } +} + +// Updates the alliance station display screen. +func (arena *Arena) SetAllianceStationDisplayMode(mode string) { + if arena.AllianceStationDisplayMode != mode { + arena.AllianceStationDisplayMode = mode + arena.AllianceStationDisplayModeNotifier.Notify() + } +} + // Returns the fractional number of seconds since the start of the match. func (arena *Arena) MatchTimeSec() float64 { if arena.MatchState == PreMatch || arena.MatchState == StartMatch || arena.MatchState == PostMatch { diff --git a/game/match_sounds.go b/game/match_sounds.go index 66c0fdd7..7b3155eb 100644 --- a/game/match_sounds.go +++ b/game/match_sounds.go @@ -69,5 +69,11 @@ func UpdateMatchSounds() { -1, false, }, + { + "match_result", + "wav", + -1, + false, + }, } } diff --git a/static/audio/match_result.wav b/static/audio/match_result.wav new file mode 100644 index 00000000..c9cf1080 Binary files /dev/null and b/static/audio/match_result.wav differ diff --git a/web/match_play.go b/web/match_play.go index 8b8fbe2b..d92b668a 100755 --- a/web/match_play.go +++ b/web/match_play.go @@ -283,22 +283,20 @@ func (web *Web) matchPlayWebsocketHandler(w http.ResponseWriter, r *http.Request } continue // Skip sending the status update, as the client is about to terminate and reload. case "setAudienceDisplay": - screen, ok := data.(string) + mode, ok := data.(string) if !ok { ws.WriteError(fmt.Sprintf("Failed to parse '%s' message.", messageType)) continue } - web.arena.AudienceDisplayMode = screen - web.arena.AudienceDisplayModeNotifier.Notify() + web.arena.SetAudienceDisplayMode(mode) continue case "setAllianceStationDisplay": - screen, ok := data.(string) + mode, ok := data.(string) if !ok { ws.WriteError(fmt.Sprintf("Failed to parse '%s' message.", messageType)) continue } - web.arena.AllianceStationDisplayMode = screen - web.arena.AllianceStationDisplayModeNotifier.Notify() + web.arena.SetAllianceStationDisplayMode(mode) continue case "startTimeout": durationSec, ok := data.(float64)