mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Refactor Rules to have an ID that is referenced instead of copying details everywhere.
This commit is contained in:
@@ -50,11 +50,18 @@ var handleRealtimeScore = function(data) {
|
||||
|
||||
// Handles a websocket message to populate the final score data.
|
||||
var handleScorePosted = function(data) {
|
||||
$.each(data.RedFouls, function(i, foul) {
|
||||
Object.assign(foul, data.RulesViolated[foul.RuleId]);
|
||||
});
|
||||
$.each(data.BlueFouls, function(i, foul) {
|
||||
Object.assign(foul, data.RulesViolated[foul.RuleId]);
|
||||
});
|
||||
|
||||
$("#scoreMatchName").text(data.MatchType + " Match " + data.Match.DisplayName);
|
||||
$("#redScoreDetails").html(matchResultTemplate({score: data.RedScoreSummary, fouls: data.RedFouls,
|
||||
cards: data.RedCards}));
|
||||
rulesViolated: data.RulesViolated, cards: data.RedCards}));
|
||||
$("#blueScoreDetails").html(matchResultTemplate({score: data.BlueScoreSummary, fouls: data.BlueFouls,
|
||||
cards: data.BlueCards}));
|
||||
rulesViolated: data.RulesViolated, cards: data.BlueCards}));
|
||||
$("#matchResult").modal("show");
|
||||
|
||||
// Activate tooltips above the foul listings.
|
||||
|
||||
@@ -51,9 +51,7 @@ var renderResults = function(alliance) {
|
||||
if (result.score.Fouls != null) {
|
||||
$.each(result.score.Fouls, function(k, v) {
|
||||
getInputElement(alliance, "Foul" + k + "Team", v.TeamId).prop("checked", true);
|
||||
getInputElement(alliance, "Foul" + k + "RuleNumber").val(v.RuleNumber);
|
||||
getInputElement(alliance, "Foul" + k + "IsTechnical").prop("checked", v.IsTechnical);
|
||||
getInputElement(alliance, "Foul" + k + "IsRankingPoint").prop("checked", v.IsRankingPoint);
|
||||
getSelectElement(alliance, "Foul" + k + "RuleId").val(v.RuleId);
|
||||
getInputElement(alliance, "Foul" + k + "Time").val(v.TimeInMatchSec);
|
||||
});
|
||||
}
|
||||
@@ -99,9 +97,7 @@ var updateResults = function(alliance) {
|
||||
result.score.Fouls = [];
|
||||
for (var i = 0; formData[alliance + "Foul" + i + "Time"]; i++) {
|
||||
var prefix = alliance + "Foul" + i;
|
||||
var foul = {TeamId: parseInt(formData[prefix + "Team"]), RuleNumber: formData[prefix + "RuleNumber"],
|
||||
IsTechnical: formData[prefix + "IsTechnical"] === "on",
|
||||
IsRankingPoint: formData[prefix + "IsRankingPoint"] === "on",
|
||||
var foul = {TeamId: parseInt(formData[prefix + "Team"]), RuleId: parseInt(formData[prefix + "RuleId"]),
|
||||
TimeInMatchSec: parseFloat(formData[prefix + "Time"])};
|
||||
result.score.Fouls.push(foul);
|
||||
}
|
||||
|
||||
@@ -46,15 +46,13 @@ var clearFoul = function() {
|
||||
// Sends the foul to the server to add it to the list.
|
||||
var commitFoul = function() {
|
||||
websocket.send("addFoul", {Alliance: foulTeamButton.attr("data-alliance"),
|
||||
TeamId: parseInt(foulTeamButton.attr("data-team")), Rule: foulRuleButton.attr("data-rule"),
|
||||
IsTechnical: foulRuleButton.attr("data-is-technical") === "true",
|
||||
IsRankingPoint: foulRuleButton.attr("data-is-ranking-point") === "true"});
|
||||
TeamId: parseInt(foulTeamButton.attr("data-team")), RuleId: parseInt(foulRuleButton.attr("data-rule-id"))});
|
||||
};
|
||||
|
||||
// Removes the foul with the given parameters from the list.
|
||||
var deleteFoul = function(alliance, team, rule, isTechnical, isRankingPoint, timeSec) {
|
||||
websocket.send("deleteFoul", {Alliance: alliance, TeamId: parseInt(team), Rule: rule,
|
||||
IsTechnical: isTechnical, IsRankingPoint: isRankingPoint, TimeInMatchSec: timeSec});
|
||||
var deleteFoul = function(alliance, team, ruleId, timeSec) {
|
||||
websocket.send("deleteFoul", {Alliance: alliance, TeamId: parseInt(team), RuleId: parseInt(ruleId),
|
||||
TimeInMatchSec: timeSec});
|
||||
};
|
||||
|
||||
// Cycles through no card, yellow card, and red card.
|
||||
|
||||
Reference in New Issue
Block a user