Enforce that pre-match scoring is set validly before starting a match.

This commit is contained in:
Patrick Fairbank
2019-08-04 13:48:14 -07:00
parent 2609f121f6
commit 06a91b8a3c
15 changed files with 217 additions and 21 deletions

View File

@@ -18,6 +18,11 @@ var toggleBypass = function(station) {
websocket.send("toggleBypass", station);
};
// Sends a websocket message to toggle the bypass state for the pre-match scoring.
var toggleBypassPreMatchScore = function() {
websocket.send("toggleBypassPreMatchScore");
};
// Sends a websocket message to start the match.
var startMatch = function() {
websocket.send("startMatch",
@@ -179,6 +184,8 @@ var handleArenaStatus = function(data) {
break;
}
$("#bypassPreMatchScore").prop("checked", data.BypassPreMatchScore);
if (data.PlcIsHealthy) {
$("#plcStatus").text("Connected");
$("#plcStatus").attr("data-ready", true);
@@ -201,6 +208,10 @@ var handleMatchTime = function(data) {
var handleRealtimeScore = function(data) {
$("#redScore").text(data.Red.ScoreSummary.Score);
$("#blueScore").text(data.Blue.ScoreSummary.Score);
if (matchStates[data.MatchState] == "PRE_MATCH") {
$("#redPreMatchScoreStatus").attr("data-ready", data.Red.IsPreMatchScoreReady);
$("#bluePreMatchScoreStatus").attr("data-ready", data.Blue.IsPreMatchScoreReady);
}
};
// Handles a websocket message to update the audience display screen selector.

View File

@@ -22,12 +22,13 @@ var handleMatchLoad = function(data) {
// Handles a websocket message to update the realtime scoring fields.
var handleRealtimeScore = function(data) {
var score;
var realtimeScore;
if (alliance === "red") {
score = data.Red.Score;
realtimeScore = data.Red;
} else {
score = data.Blue.Score;
realtimeScore = data.Blue;
}
var score = realtimeScore.Score;
for (var i = 0; i < 3; i++) {
var i1 = i + 1;
@@ -45,13 +46,21 @@ var handleRealtimeScore = function(data) {
for (var i = 0; i < 8; i++) {
getBay("cargoShip", i).attr("data-value", score.CargoBays[i]);
}
if (matchStates[data.MatchState] === "PRE_MATCH") {
if (realtimeScore.IsPreMatchScoreReady) {
$("#preMatchMessage").hide();
} else {
$("#preMatchMessage").css("display", "flex");
}
}
};
// Handles a websocket message to update the match status.
var handleMatchTime = function(data) {
switch (matchStates[data.MatchState]) {
case "PRE_MATCH":
$("#preMatchMessage").css("display", "flex");
// Pre-match message state is set in handleRealtimeScore().
$("#postMatchMessage").hide();
$("#commitMatchScore").hide();
break;