Don't allow committing score if co-op points don't match.

This commit is contained in:
Patrick Fairbank
2015-05-31 12:52:46 -07:00
parent 818fe7c6c6
commit 1aa206ea60
3 changed files with 19 additions and 1 deletions

View File

@@ -179,7 +179,16 @@ func ScoringDisplayWebsocketHandler(w http.ResponseWriter, r *http.Request) {
// Don't allow committing the score until the match is over.
continue
}
// TODO(pat): Don't allow committing and show an error message if the red/blue co-op points aren't equal.
redScore := mainArena.redRealtimeScore.CurrentScore
blueScore := mainArena.blueRealtimeScore.CurrentScore
if redScore.CoopertitionSet != blueScore.CoopertitionSet ||
redScore.CoopertitionStack != blueScore.CoopertitionStack {
// Don't accept the score if the red and blue co-opertition points don't match up.
websocket.ShowDialog("Cannot commit score: Red and blue co-opertition points do not match.")
continue
}
(*score).AutoCommitted = true
(*score).TeleopCommitted = true
mainArena.scoringStatusNotifier.Notify(nil)

View File

@@ -20,6 +20,11 @@ var CheesyWebsocket = function(path, events) {
}
}
// Insert an event to show a dialog when the server wishes it.
events.dialog = function(event) {
alert(event.data);
}
// Insert an event to allow the server to force-reload the client for any display.
events.reload = function(event) {
location.reload();

4
web.go
View File

@@ -74,6 +74,10 @@ func (websocket *Websocket) WriteError(errorMessage string) error {
return websocket.conn.WriteJSON(WebsocketMessage{"error", errorMessage})
}
func (websocket *Websocket) ShowDialog(message string) error {
return websocket.conn.WriteJSON(WebsocketMessage{"dialog", message})
}
// Serves the root page of Cheesy Arena.
func IndexHandler(w http.ResponseWriter, r *http.Request) {
template, err := template.ParseFiles("templates/index.html", "templates/base.html")