summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-10-21 18:05:45 +0200
committeremkael <emkael@tlen.pl>2017-10-21 18:05:45 +0200
commitd6020d42d13305cb6c830da6499ce7a51c9cf0ac (patch)
tree8dd71a4a3df63d9cb96d073f398a4bfcd618fd98 /jfr_playoff
parent54729ff05267ffddaff919dfbdc3b13d8767cd5e (diff)
Refactored swiss tournament results compiling, with added ability to interpret any chunk of swiss results as final results
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/data.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/jfr_playoff/data.py b/jfr_playoff/data.py
index 5599fe5..0190810 100644
--- a/jfr_playoff/data.py
+++ b/jfr_playoff/data.py
@@ -190,15 +190,30 @@ class PlayoffData(object):
swiss_results = sorted(swiss_results, key=lambda t: t[0])
swiss_results = sorted(
swiss_results, key=lambda t: t[1], reverse=True)
+ swiss_position = (
+ event['source_position']
+ if 'source_position' in event
+ else 1
+ )
+ position_limit = (
+ event['position_to']
+ if 'position_to' in event
+ else 9999
+ )
prev_result = None
- place = -1
+ place = 1
for team in sorted(
swiss_results, key=lambda team: team[2]):
if prev_result == team[1]:
print SWISS_TIE_WARNING % (event['database'])
prev_result = team[1]
- self.leaderboard[
- event['position'] + place] = teams[team[0]]
+ if place >= swiss_position:
+ target_position = event['position'] \
+ + place - swiss_position
+ if target_position <= min(
+ position_limit, len(self.leaderboard)):
+ self.leaderboard[
+ target_position - 1] = teams[team[0]]
place += 1
def fill_leaderboard(self):