@@ -128,4 +128,37 @@ private boolean isTeamsTie() {
128128 int referencePoints = teams .get (0 ).getTotalPoints ();
129129 return teams .stream ().allMatch (team -> team .getTotalPoints () == referencePoints );
130130 }
131+
132+ /**
133+ * @param battleHostName name of host to search
134+ * @return Team instance containing name of host or null if no team found */
135+ public Team getTeam (String battleHostName ) {
136+ List <Team > list = getTeams (battleHostName );
137+ return list .isEmpty () ? null : list .get (0 );
138+ }
139+
140+ /**
141+ * @param battleHostName name of host to search
142+ * @return Team instances not containing name of host */
143+ public List <Team > getOpponentTeams (String battleHostName ) {
144+ List <Team > list = getTeams (battleHostName );
145+ return list .isEmpty () ? null : list ;
146+ }
147+
148+ /**
149+ * @param battleHostName name of host to search
150+ * @return {@link List<Team>} with host team first, then opponent teams
151+ * <p> If host is in neither or teams is empty, returns empty
152+ * <p> Otherwise always teams.length in length;
153+ */
154+ public List <Team > getTeams (String battleHostName ) {
155+ if (teams .isEmpty () || teams .stream ().noneMatch (team -> team .contains (battleHostName )))
156+ return Collections .EMPTY_LIST ;
157+ Team hostTeam = teams .stream ().filter (team -> team .contains (battleHostName )).findFirst ().orElseThrow ();
158+ List <Team > opponentTeams = teams .stream ().filter (team -> !team .contains (battleHostName )).toList ();
159+ List <Team > teams = new ArrayList <>();
160+ teams .add (hostTeam );
161+ teams .addAll (opponentTeams );
162+ return teams ;
163+ }
131164}
0 commit comments