diff --git a/static/css/cheesy-arena.css b/static/css/cheesy-arena.css index 546f378..32cc588 100644 --- a/static/css/cheesy-arena.css +++ b/static/css/cheesy-arena.css @@ -80,6 +80,9 @@ .label-scoring[data-ready=true] { background-color: #0c6; } +.label-saved-match { + background-color: #999; +} .nowrap { white-space: nowrap; } diff --git a/templates/match_play.html b/templates/match_play.html index 3c470de..8e6acc6 100755 --- a/templates/match_play.html +++ b/templates/match_play.html @@ -290,6 +290,14 @@ +

Saved Match Result

+ + {{if .SavedMatch.DisplayName}}{{.SavedMatchType}} {{.SavedMatch.DisplayName}}{{else}}None{{end}} + +   + + Clear +

Match Sounds

diff --git a/web/match_play.go b/web/match_play.go index 26c0f44..30267d2 100755 --- a/web/match_play.go +++ b/web/match_play.go @@ -89,6 +89,8 @@ func (web *Web) matchPlayHandler(w http.ResponseWriter, r *http.Request) { BlueScore *game.Score AllowSubstitution bool IsReplay bool + SavedMatchType string + SavedMatch *model.Match PlcArmorBlockStatuses map[string]bool }{ web.arena.EventSettings, @@ -102,6 +104,8 @@ func (web *Web) matchPlayHandler(w http.ResponseWriter, r *http.Request) { web.arena.BlueScore, web.arena.CurrentMatch.ShouldAllowSubstitution(), isReplay, + web.arena.SavedMatch.CapitalizedType(), + web.arena.SavedMatch, web.arena.Plc.GetArmorBlockStatuses(), } err = template.ExecuteTemplate(w, "base", data) @@ -185,6 +189,20 @@ func (web *Web) matchPlayShowResultHandler(w http.ResponseWriter, r *http.Reques http.Redirect(w, r, "/match_play", 303) } +// Clears the match results display buffer. +func (web *Web) matchPlayClearResultHandler(w http.ResponseWriter, r *http.Request) { + if !web.userIsAdmin(w, r) { + return + } + + // Load an empty match to effectively clear the buffer. + web.arena.SavedMatch = &model.Match{} + web.arena.SavedMatchResult = model.NewMatchResult() + web.arena.ScorePostedNotifier.Notify() + + http.Redirect(w, r, "/match_play", 303) +} + // The websocket endpoint for the match play client to send control commands and receive status updates. func (web *Web) matchPlayWebsocketHandler(w http.ResponseWriter, r *http.Request) { if !web.userIsAdmin(w, r) { diff --git a/web/match_play_test.go b/web/match_play_test.go index 778e3fc..31ba3ad 100644 --- a/web/match_play_test.go +++ b/web/match_play_test.go @@ -91,7 +91,7 @@ func TestMatchPlayLoad(t *testing.T) { assert.NotContains(t, recorder.Body.String(), "106") } -func TestMatchPlayShowResult(t *testing.T) { +func TestMatchPlayShowAndClearResult(t *testing.T) { web := setupTestWeb(t) recorder := web.getHttpResponse("/match_play/1/show_result") @@ -107,6 +107,11 @@ func TestMatchPlayShowResult(t *testing.T) { assert.Equal(t, 303, recorder.Code) assert.Equal(t, match.Id, web.arena.SavedMatch.Id) assert.Equal(t, match.Id, web.arena.SavedMatchResult.MatchId) + + recorder = web.getHttpResponse("/match_play/clear_result") + assert.Equal(t, 303, recorder.Code) + assert.Equal(t, model.Match{}, *web.arena.SavedMatch) + assert.Equal(t, *model.NewMatchResult(), *web.arena.SavedMatchResult) } func TestMatchPlayErrors(t *testing.T) { diff --git a/web/web.go b/web/web.go index f19b906..49dc1e3 100755 --- a/web/web.go +++ b/web/web.go @@ -145,6 +145,7 @@ func (web *Web) newHandler() http.Handler { router.HandleFunc("/match_play", web.matchPlayHandler).Methods("GET") router.HandleFunc("/match_play/{matchId}/load", web.matchPlayLoadHandler).Methods("GET") router.HandleFunc("/match_play/{matchId}/show_result", web.matchPlayShowResultHandler).Methods("GET") + router.HandleFunc("/match_play/clear_result", web.matchPlayClearResultHandler).Methods("GET") router.HandleFunc("/match_play/websocket", web.matchPlayWebsocketHandler).Methods("GET") router.HandleFunc("/match_review", web.matchReviewHandler).Methods("GET") router.HandleFunc("/match_review/{matchId}/edit", web.matchReviewEditGetHandler).Methods("GET")