mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Show playoff alliance numbers and 4th teams on announcer display.
This commit is contained in:
@@ -127,6 +127,18 @@ func (arena *Arena) generateMatchLoadMessage() interface{} {
|
||||
teams[station] = allianceStation.Team
|
||||
}
|
||||
|
||||
redOffFieldTeamIds, blueOffFieldTeamIds, _ := arena.Database.GetOffFieldTeamIds(arena.CurrentMatch)
|
||||
redOffFieldTeams := []*model.Team{}
|
||||
blueOffFieldTeams := []*model.Team{}
|
||||
for _, teamId := range redOffFieldTeamIds {
|
||||
team, _ := arena.Database.GetTeamById(teamId)
|
||||
redOffFieldTeams = append(redOffFieldTeams, team)
|
||||
}
|
||||
for _, teamId := range blueOffFieldTeamIds {
|
||||
team, _ := arena.Database.GetTeamById(teamId)
|
||||
blueOffFieldTeams = append(blueOffFieldTeams, team)
|
||||
}
|
||||
|
||||
rankings := make(map[string]*game.Ranking)
|
||||
for _, allianceStation := range arena.AllianceStations {
|
||||
if allianceStation.Team != nil {
|
||||
@@ -136,11 +148,13 @@ func (arena *Arena) generateMatchLoadMessage() interface{} {
|
||||
}
|
||||
|
||||
return &struct {
|
||||
MatchType string
|
||||
Match *model.Match
|
||||
Teams map[string]*model.Team
|
||||
Rankings map[string]*game.Ranking
|
||||
}{arena.CurrentMatch.CapitalizedType(), arena.CurrentMatch, teams, rankings}
|
||||
MatchType string
|
||||
Match *model.Match
|
||||
Teams map[string]*model.Team
|
||||
RedOffFieldTeams []*model.Team
|
||||
BlueOffFieldTeams []*model.Team
|
||||
Rankings map[string]*game.Ranking
|
||||
}{arena.CurrentMatch.CapitalizedType(), arena.CurrentMatch, teams, redOffFieldTeams, blueOffFieldTeams, rankings}
|
||||
}
|
||||
|
||||
func (arena *Arena) generateMatchTimeMessage() interface{} {
|
||||
|
||||
@@ -26,12 +26,29 @@ var handleAudienceDisplayMode = function(targetScreen) {
|
||||
// Handles a websocket message to update the teams for the current match.
|
||||
var handleMatchLoad = function(data) {
|
||||
$("#matchName").text(data.MatchType + " Match " + data.Match.DisplayName);
|
||||
$("#red1").html(teamTemplate(formatTeam(data.Teams["R1"])));
|
||||
$("#red2").html(teamTemplate(formatTeam(data.Teams["R2"])));
|
||||
$("#red3").html(teamTemplate(formatTeam(data.Teams["R3"])));
|
||||
$("#blue1").html(teamTemplate(formatTeam(data.Teams["B1"])));
|
||||
$("#blue2").html(teamTemplate(formatTeam(data.Teams["B2"])));
|
||||
$("#blue3").html(teamTemplate(formatTeam(data.Teams["B3"])));
|
||||
|
||||
const teams = $("#teams");
|
||||
teams.empty();
|
||||
|
||||
if (data.Match.Type === "elimination") {
|
||||
teams.append(createAllianceElement("red", data.Match.ElimRedAlliance));
|
||||
}
|
||||
teams.append(createTeamElement("red", data.Teams["R1"], false));
|
||||
teams.append(createTeamElement("red", data.Teams["R2"], false));
|
||||
teams.append(createTeamElement("red", data.Teams["R3"], false));
|
||||
for (team of data.RedOffFieldTeams) {
|
||||
teams.append(createTeamElement("red", team, true));
|
||||
}
|
||||
|
||||
if (data.Match.Type === "elimination") {
|
||||
teams.append(createAllianceElement("blue", data.Match.ElimBlueAlliance));
|
||||
}
|
||||
teams.append(createTeamElement("blue", data.Teams["B1"], false));
|
||||
teams.append(createTeamElement("blue", data.Teams["B2"], false));
|
||||
teams.append(createTeamElement("blue", data.Teams["B3"], false));
|
||||
for (team of data.BlueOffFieldTeams) {
|
||||
teams.append(createTeamElement("blue", team, true));
|
||||
}
|
||||
};
|
||||
|
||||
// Handles a websocket message to update the match time countdown.
|
||||
@@ -65,6 +82,19 @@ var handleScorePosted = function(data) {
|
||||
$("#matchResult").modal("show");
|
||||
};
|
||||
|
||||
// Creates the block containing the playoff alliance number.
|
||||
var createAllianceElement = function(alliance, allianceNumber) {
|
||||
return $(`<div class="row well-sm well-dark${alliance}"><h3><b>Alliance ${allianceNumber}</b></h3></div>`);
|
||||
};
|
||||
|
||||
// Creates the block containing the information for a single team.
|
||||
var createTeamElement = function(alliance, team, isOffField) {
|
||||
team.isOffField = isOffField;
|
||||
const element = $(`<div class="row well-sm well-dark${alliance}"></div>`)
|
||||
element.html(teamTemplate(formatTeam(team)));
|
||||
return element;
|
||||
};
|
||||
|
||||
// Replaces newlines in team fields with HTML line breaks.
|
||||
var formatTeam = function(team) {
|
||||
if (team) {
|
||||
|
||||
@@ -6,14 +6,7 @@
|
||||
<div class="col-lg-5"><h4>Name</h4></div>
|
||||
<div class="col-lg-5"><h4>Recent Accomplishments</h4></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row well-sm well-darkred" id="red1"></div>
|
||||
<div class="row well-sm well-darkred" id="red2"></div>
|
||||
<div class="row well-sm well-darkred" id="red3"></div>
|
||||
<div class="row well-sm well-darkblue" id="blue1"></div>
|
||||
<div class="row well-sm well-darkblue" id="blue2"></div>
|
||||
<div class="row well-sm well-darkblue" id="blue3"></div>
|
||||
</div>
|
||||
<div id="teams" class="row"></div>
|
||||
<br />
|
||||
<div class="row">
|
||||
<div id="matchState" class="col-lg-2 col-lg-offset-2 well well-sm text-center"> </div>
|
||||
@@ -47,7 +40,7 @@
|
||||
<script id="teamTemplate" type="text/x-handlebars-template">
|
||||
{{"{{#if this}}"}}
|
||||
<div class="col-lg-2">
|
||||
<div><h4><b>{{"{{Id}}"}}</b></h4></div>
|
||||
<div><h4><b>{{"{{Id}}"}}</b>{{"{{#if isOffField}}"}} (not on field){{"{{/if}}"}}</h4></div>
|
||||
<div class="nowrap"><h4><b>{{"{{Nickname}}"}}</b></h4></div>
|
||||
<div class="nowrap">{{"{{City}}"}}, {{"{{StateProv}}"}}, {{"{{Country}}"}}</div>
|
||||
<div class="nowrap">Robot: {{"{{RobotName}}"}}</div>
|
||||
|
||||
Reference in New Issue
Block a user