diff --git a/static/js/scoring_display.js b/static/js/scoring_display.js index f386855..e71ef18 100644 --- a/static/js/scoring_display.js +++ b/static/js/scoring_display.js @@ -12,6 +12,7 @@ var handleScore = function(data) { var score = data.Score.CurrentScore; $("#autoRuns").text(score.AutoRuns); $("#climbs").text(score.Climbs); + $("#parks").text(score.Parks); // Update component visibility. if (!data.AutoCommitted) { @@ -35,27 +36,7 @@ var handleScore = function(data) { // Handles a keyboard event and sends the appropriate websocket message. var handleKeyPress = function(event) { - var key = String.fromCharCode(event.keyCode); - switch (key) { - case "r": - websocket.send("autoRun"); - break; - case "R": - websocket.send("undoAutoRun"); - break; - case "c": - websocket.send("climb"); - break; - case "C": - websocket.send("undoClimb"); - break; - case "\r": - websocket.send("commit"); - break; - case "a": - websocket.send("uncommitAuto"); - break; - } + websocket.send(String.fromCharCode(event.keyCode)); }; // Handles a websocket message to update the match status. diff --git a/templates/scoring_display.html b/templates/scoring_display.html index 1a9955e..6b4d9ca 100644 --- a/templates/scoring_display.html +++ b/templates/scoring_display.html @@ -43,7 +43,11 @@

Use the following keyboard shortcuts:

c/C
-
Climbs +/- (ignore Levitate)
+
Climbs +/- (actual; disregard Levitate)
+
+
+
p/P
+
Parks +/-
a
@@ -58,6 +62,10 @@
Climbs
+
+
Parks
+
+
diff --git a/web/scoring_display.go b/web/scoring_display.go index d55038d..4fa1df4 100644 --- a/web/scoring_display.go +++ b/web/scoring_display.go @@ -145,35 +145,47 @@ func (web *Web) scoringDisplayWebsocketHandler(w http.ResponseWriter, r *http.Re } switch messageType { - case "autoRun": + case "r": if !autoCommitted { if (*score).CurrentScore.AutoRuns < 3 { (*score).CurrentScore.AutoRuns++ } } - case "undoAutoRun": + case "R": if !autoCommitted { if (*score).CurrentScore.AutoRuns > 0 { (*score).CurrentScore.AutoRuns-- } } - case "climb": + case "c": if autoCommitted { - if (*score).CurrentScore.Climbs < 3 { + if (*score).CurrentScore.Climbs+(*score).CurrentScore.Parks < 3 { (*score).CurrentScore.Climbs++ } } - case "undoClimb": + case "C": if autoCommitted { if (*score).CurrentScore.Climbs > 0 { (*score).CurrentScore.Climbs-- } } - case "commit": + case "p": + if autoCommitted { + if (*score).CurrentScore.Climbs+(*score).CurrentScore.Parks < 3 { + (*score).CurrentScore.Parks++ + } + } + case "P": + if autoCommitted { + if (*score).CurrentScore.Parks > 0 { + (*score).CurrentScore.Parks-- + } + } + case "\r": if web.arena.MatchState != field.PreMatch || web.arena.CurrentMatch.Type == "test" { autoCommitted = true } - case "uncommitAuto": + case "a": autoCommitted = false case "commitMatch": if web.arena.MatchState != field.PostMatch { diff --git a/web/scoring_display_test.go b/web/scoring_display_test.go index 0593aef..cc0f2fd 100644 --- a/web/scoring_display_test.go +++ b/web/scoring_display_test.go @@ -47,16 +47,16 @@ func TestScoringDisplayWebsocket(t *testing.T) { readWebsocketType(t, blueWs, "matchTime") // Send a match worth of scoring commands in. - redWs.Write("autoRun", nil) - blueWs.Write("autoRun", nil) - blueWs.Write("autoRun", nil) - blueWs.Write("autoRun", nil) - blueWs.Write("autoRun", nil) - blueWs.Write("undoAutoRun", nil) - redWs.Write("commit", nil) - blueWs.Write("commit", nil) - redWs.Write("uncommitAuto", nil) - redWs.Write("commit", nil) + redWs.Write("r", nil) + blueWs.Write("r", nil) + blueWs.Write("r", nil) + blueWs.Write("r", nil) + blueWs.Write("r", nil) + blueWs.Write("R", nil) + redWs.Write("\r", nil) + blueWs.Write("\r", nil) + redWs.Write("a", nil) + redWs.Write("\r", nil) for i := 0; i < 4; i++ { readWebsocketType(t, redWs, "score") } @@ -67,7 +67,7 @@ func TestScoringDisplayWebsocket(t *testing.T) { assert.Equal(t, 1, web.arena.RedRealtimeScore.CurrentScore.AutoRuns) assert.Equal(t, 2, web.arena.BlueRealtimeScore.CurrentScore.AutoRuns) - redWs.Write("autoRun", nil) + redWs.Write("r", nil) for i := 0; i < 1; i++ { readWebsocketType(t, redWs, "score") }