public void setOnCourt(Team team, bool isHome) { List<string> lineup; if (isHome) { lineup = homeTeam["onField"]; } else { lineup = awayTeam["onField"]; } List<Player> onCourt = new List<Player>(); foreach (string pid in lineup) { onCourt.Add(team.getPlayer(pid)); } team.setPlayersOnCourt(onCourt); }