summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-11-09 23:53:24 +0100
committeremkael <emkael@tlen.pl>2019-11-09 23:53:24 +0100
commit26f7aeb88bdfd4cb89d41b51e08ac2511d06da93 (patch)
tree51cb38698dd44d7b4429d15854a846cbc4b5f54f /jfr_playoff
parent7483e898f080af54e178401fc6ebb15d505e9c1d (diff)
parentec211c53adbc6d88e58a32943adaed2ae9d802b7 (diff)
Merge branch 'master' into gui
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/data.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/jfr_playoff/data.py b/jfr_playoff/data.py
index 641a329..6649e68 100644
--- a/jfr_playoff/data.py
+++ b/jfr_playoff/data.py
@@ -16,6 +16,15 @@ class PlayoffData(object):
PlayoffLogger.get('db').warning(
PlayoffDB.DATABASE_NOT_CONFIGURED_WARNING)
self.team_settings = settings.get('teams')
+ self.custom_final_order = []
+ if settings.has_section('custom_final_order'):
+ self.custom_final_order = settings.get('custom_final_order')
+ self.custom_final_order = [
+ t for t in [
+ self.teams[i-1] if isinstance(i, int)
+ else self.get_team_data_by_name(i)
+ for i in self.custom_final_order]
+ if t is not None]
self.phases = settings.get('phases')
self.swiss = []
if settings.has_section('swiss'):
@@ -134,6 +143,13 @@ class PlayoffData(object):
leaderboard_teams[loser_key] = []
leaderboard_teams[loser_key].append(
self.match_info[match['id']].loser)
+ final_order = self.custom_final_order + [
+ t for t in self.teams if t not in self.custom_final_order]
+ PlayoffLogger.get('data').info(
+ 'custom order for final positions: %s', self.custom_final_order)
+ PlayoffLogger.get('data').info(
+ 'order of teams to fill leaderboard positions: %s',
+ final_order)
for positions, position_teams in leaderboard_teams.iteritems():
positions = list(positions)
PlayoffLogger.get('data').info(
@@ -141,7 +157,7 @@ class PlayoffData(object):
positions, position_teams)
if len(positions) == len([
team for team in position_teams if team is not None]):
- for table_team in self.teams:
+ for table_team in final_order:
if table_team[0] in position_teams:
position = positions.pop(0)
self.leaderboard[position-1] = table_team[0]
@@ -172,6 +188,12 @@ class PlayoffData(object):
PlayoffLogger.get('data').info('grid dimensions: %s', dimensions)
return dimensions
+ def get_team_data_by_name(self, fullname):
+ for team in self.teams:
+ if team[0] == fullname:
+ return team
+ return None
+
def get_shortname(self, fullname):
for team in self.teams:
if team[0] == fullname: