예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 def _check_position_constraint(self, position: str):
     if position not in self.available_positions:
         raise LineupOptimizerIncorrectPositionName(
             '%s is incorrect position name. Chocies are [%s]' %
             (position, ','.join(self.available_positions)))
예제 #4
0
 def _check_position_constraint(self, position):
     # type: (str) -> None
     if position not in self.available_positions:
         raise LineupOptimizerIncorrectPositionName(
             '%s is incorrect position name.' % position)