From 4de9e4332b91909cc4c4026ebe068781bce7d13c Mon Sep 17 00:00:00 2001 From: Patrick Fairbank Date: Sun, 6 Oct 2024 11:40:21 -0700 Subject: [PATCH] Use Nexus when pre-loading teams for the next match. --- field/arena.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/field/arena.go b/field/arena.go index 37876e0c..10bacea5 100644 --- a/field/arena.go +++ b/field/arena.go @@ -792,10 +792,19 @@ func (arena *Arena) preLoadNextMatch() { return } + teamIds := [6]int{nextMatch.Red1, nextMatch.Red2, nextMatch.Red3, nextMatch.Blue1, nextMatch.Blue2, nextMatch.Blue3} + if nextMatch.ShouldAllowNexusSubstitution() && arena.EventSettings.NexusEnabled { + // Attempt to get the match lineup from Nexus for FRC. + lineup, err := arena.NexusClient.GetLineup(nextMatch.TbaMatchKey) + if err != nil { + log.Printf("Failed to load lineup from Nexus: %s", err.Error()) + } else { + teamIds = *lineup + } + } + var teams [6]*model.Team - for i, teamId := range []int{ - nextMatch.Red1, nextMatch.Red2, nextMatch.Red3, nextMatch.Blue1, nextMatch.Blue2, nextMatch.Blue3, - } { + for i, teamId := range teamIds { if teamId == 0 { continue }