def _check_team_constraint(self, team, num_of_players): # type: (str, int) -> None if team not in self.available_teams: raise LineupOptimizerIncorrectTeamName('%s is incorrect team name.' % team) if self.max_from_one_team and num_of_players > self.max_from_one_team: raise LineupOptimizerException('You can\'t set more than %s players from one team.' % self.max_from_one_team)
def _check_team_constraint(self, team: str, num_of_players: int): if team not in self.player_pool.available_teams: raise LineupOptimizerIncorrectTeamName('%s is incorrect team name. Choices are [%s]' % (team, ','.join(self.player_pool.available_teams))) if self.max_from_one_team and num_of_players > self.max_from_one_team: raise LineupOptimizerException('You can\'t set more than %s players from one team.' % self.max_from_one_team)
def validate(self, optimizer: 'LineupOptimizer') -> None: settings = optimizer.settings max_from_one_team = settings.max_from_one_team or settings.get_total_players() if self.size > max_from_one_team: raise LineupOptimizerException( 'Stack size should be smaller than max players from one team (%d)' % max_from_one_team) for team in self.for_teams or []: if team not in optimizer.available_teams: raise LineupOptimizerIncorrectTeamName('%s is incorrect team name.' % team) for position in self.for_positions or []: if position not in optimizer.player_pool.available_positions: raise LineupOptimizerIncorrectPositionName('%s is incorrect position name.' % position)
def validate(self, optimizer: 'LineupOptimizer') -> None: if not self.positions or not all(self.positions): raise LineupOptimizerException('Positions stack can\'t be empty') settings = optimizer.settings max_from_one_team = settings.max_from_one_team or settings.get_total_players() if len(self.positions) > max_from_one_team: raise LineupOptimizerException('You can\'t set more than %s players from one team.' % max_from_one_team) for position in set(chain.from_iterable(self.positions)): if position not in optimizer.player_pool.available_positions: raise LineupOptimizerIncorrectPositionName('%s is incorrect position name.' % position) for team in self.for_teams or []: if team not in optimizer.player_pool.available_teams: raise LineupOptimizerIncorrectTeamName('%s is incorrect team name.' % team)