mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-10 06:06:47 -04:00
Identify saved match on Match Play screen and provide mechanism to clear it.
This commit is contained in:
@@ -80,6 +80,9 @@
|
||||
.label-scoring[data-ready=true] {
|
||||
background-color: #0c6;
|
||||
}
|
||||
.label-saved-match {
|
||||
background-color: #999;
|
||||
}
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -290,6 +290,14 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<p>Saved Match Result</p>
|
||||
<span class="label label-saved-match">
|
||||
{{if .SavedMatch.DisplayName}}{{.SavedMatchType}} {{.SavedMatch.DisplayName}}{{else}}None{{end}}
|
||||
</span>
|
||||
|
||||
<a href="/match_play/clear_result">
|
||||
<b class="btn btn-info btn-xs">Clear</b>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<p>Match Sounds</p>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user