Skip to content

Commit

Permalink
Add rank to announcer display.
Browse files Browse the repository at this point in the history
  • Loading branch information
patfair committed May 23, 2024
1 parent e17cc8f commit 0a13bc1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
10 changes: 6 additions & 4 deletions field/arena_notifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ func (arena *Arena) GenerateMatchLoadMessage() any {
teams[station] = allianceStation.Team
}

rankings := make(map[string]*game.Ranking)
rankings := make(map[string]int)
for _, allianceStation := range arena.AllianceStations {
if allianceStation.Team != nil {
rankings[strconv.Itoa(allianceStation.Team.Id)], _ =
arena.Database.GetRankingForTeam(allianceStation.Team.Id)
ranking, _ := arena.Database.GetRankingForTeam(allianceStation.Team.Id)
if ranking != nil {
rankings[strconv.Itoa(allianceStation.Team.Id)] = ranking.Rank
}
}
}

Expand Down Expand Up @@ -157,7 +159,7 @@ func (arena *Arena) GenerateMatchLoadMessage() any {
AllowSubstitution bool
IsReplay bool
Teams map[string]*model.Team
Rankings map[string]*game.Ranking
Rankings map[string]int
Matchup *playoff.Matchup
RedOffFieldTeams []*model.Team
BlueOffFieldTeams []*model.Team
Expand Down
3 changes: 1 addition & 2 deletions static/js/alliance_station_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ var handleMatchLoad = function(data) {

var ranking = data.Rankings[team.Id];
if (ranking && data.Match.Type === matchTypeQualification) {
var rankingText = ranking.Rank;
$("#teamRank").attr("data-alliance-bg", station[0]).text(rankingText);
$("#teamRank").attr("data-alliance-bg", station[0]).text(ranking);
} else {
$("#teamRank").attr("data-alliance-bg", station[0]).text("");
}
Expand Down
3 changes: 2 additions & 1 deletion templates/announcer_display.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ <h3 id="matchName" class="mt-4"></h3>
<div class="col-sm-2"><h4>Team #</h4></div>
<div class="col-sm-4"><h4>Nickname</h4></div>
<div class="col-sm-2"><h4>School</h4></div>
<div class="col-sm-4"><h4>Location</h4></div>
<div class="col-sm-3"><h4>Location</h4></div>
<div class="col-sm-1"><h4>Rank</h4></div>
</div>
</div>
<div id="teams"></div>
Expand Down
27 changes: 15 additions & 12 deletions templates/announcer_display_match_load.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
{{if eq .Match.Type playoffMatch}}
<h4><b>Alliance {{.Match.PlayoffRedAlliance}}</b></h4>
{{end}}
{{template "team" dict "alliance" "red" "team" (index .Teams "R1")}}
{{template "team" dict "alliance" "red" "team" (index .Teams "R2")}}
{{template "team" dict "alliance" "red" "team" (index .Teams "R3")}}
{{template "team" dict "alliance" "red" "team" (index .Teams "R1") "rankings" .Rankings}}
{{template "team" dict "alliance" "red" "team" (index .Teams "R2") "rankings" .Rankings}}
{{template "team" dict "alliance" "red" "team" (index .Teams "R3") "rankings" .Rankings}}
{{range $team := .RedOffFieldTeams}}
{{template "team" dict "alliance" "red" "team" $team "isOffField" true}}
{{end}}
Expand All @@ -14,9 +14,9 @@ <h4><b>Alliance {{.Match.PlayoffRedAlliance}}</b></h4>
{{if eq .Match.Type playoffMatch}}
<h4><b>Alliance {{.Match.PlayoffBlueAlliance}}</b></h4>
{{end}}
{{template "team" dict "alliance" "blue" "team" (index .Teams "B1")}}
{{template "team" dict "alliance" "blue" "team" (index .Teams "B2")}}
{{template "team" dict "alliance" "blue" "team" (index .Teams "B3")}}
{{template "team" dict "alliance" "blue" "team" (index .Teams "B1") "rankings" .Rankings}}
{{template "team" dict "alliance" "blue" "team" (index .Teams "B2") "rankings" .Rankings}}
{{template "team" dict "alliance" "blue" "team" (index .Teams "B3") "rankings" .Rankings}}
{{range $team := .BlueOffFieldTeams}}
{{template "team" dict "alliance" "blue" "team" $team "isOffField" true}}
{{end}}
Expand All @@ -28,13 +28,16 @@ <h4><b>Alliance {{.Match.PlayoffBlueAlliance}}</b></h4>
<div class="col-sm-2"><h2><b>{{.team.Id}}</b>{{if .isOffField}} (not on field){{end}}</h2></div>
<div class="col-sm-4"><h2>{{.team.Nickname}}</h2></div>
<div class="col-sm-2"><h5>{{.team.SchoolName}}</h5></div>
<div class="col-sm-3">
<div><h5>{{.team.City}}, {{.team.StateProv}}, {{.team.Country}}</h5></div>
</div>
<div class="col-sm-3"><div><h5>{{.team.City}}, {{.team.StateProv}}, {{.team.Country}}</h5></div></div>
<div class="col-sm-1">
<button type="button" class="btn btn-secondary btn-sm" onclick="$('#team{{.team.Id}}Details').modal('show');">
More
</button>
<div class="row">
<div class="col-sm-6">{{if index .rankings (itoa .team.Id)}}{{index .rankings (itoa .team.Id)}}{{end}}</div>
<div class="col-sm-6">
<button type="button" class="btn btn-secondary btn-sm" onclick="$('#team{{.team.Id}}Details').modal('show');">
More
</button>
</div>
</div>
</div>
<div id="team{{.team.Id}}Details" class="modal">
<div class="modal-dialog">
Expand Down
4 changes: 4 additions & 0 deletions web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"log"
"net/http"
"path/filepath"
"strconv"
"strings"
"text/template"

Expand Down Expand Up @@ -51,6 +52,9 @@ func NewWeb(arena *field.Arena) *Web {
"add": func(a, b int) int {
return a + b
},
"itoa": func(a int) string {
return strconv.Itoa(a)
},
"multiply": func(a, b int) int {
return a * b
},
Expand Down

0 comments on commit 0a13bc1

Please sign in to comment.