Exemple #1
0
    def _load_resfile(self, fname):
        y = yaml_loader.load(fname)

        match_id = (y["arena_id"], y["match_number"])
        if match_id in self.game_points:
            raise DuplicateScoresheet(match_id)

        game_points = self._scorer(y["teams"]).calculate_scores()
        self.game_points[match_id] = game_points

        # Build the disqualification dict
        dsq = []
        for tla, scoreinfo in y["teams"].iteritems():
            # disqualifications and non-presence are effectively the same
            # in terms of league points awarding.
            if scoreinfo.get("disqualified", False) or \
                not scoreinfo.get("present", True):
                dsq.append(tla)

        self.ranked_points[match_id] = ranker.get_ranked_points(game_points, dsq)
Exemple #2
0
def perform_calc_league_points(responder, options):
    """Handle the `calc-league-points` command."""
    match = options['<match-id>']
    match_scores = yield scores.get_match_scores(match)

    if match_scores is None:
        if options.get(yaml_opt, False):
            responder(yaml.dump({'points': None}))
        else:
            responder('No scores available for match {0}'.format(match))
        return

    dsq_teams = yield scores.teams_disqualified_in_match(match)
    league_points = ranker.get_ranked_points(match_scores, dsq_teams)
    scores.set_league_points(match, league_points)

    if options.get(yaml_opt, False):
        responder(yaml.dump({'points': league_points}))
    else:
        for tla, pts in league_points.iteritems():
            responder('Team {0} earned {1} points from match {2}'.format(tla, pts, match))