From e197341c6f2a234b6c2b266450b8564a9125fcc1 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 22 May 2018 11:50:40 +0200 Subject: Fixing vertical positioning of match boxes if there's a single match in every phase --- jfr_playoff/generator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 6d107bd..22bdc82 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -137,7 +137,8 @@ class PlayoffGenerator(object): match_height = canvas_size[1] / len(phase.matches) row_no = 0 for match in phase.matches: - grid_y = int(row_no * match_height + + grid_y = self.page['margin'] / 2 if dimensions[1] == 1 else \ + int(row_no * match_height + 0.5 * (match_height - self.page['height'])) PlayoffLogger.get('generator').info( 'grid box (%d, %d) position: (%d, %d)', -- cgit v1.2.3 From e1f1f59ecbdf749a215e631438efaf7ddc20c247 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 01:09:50 +0200 Subject: Storing information about seeding from starting positions in match info object --- jfr_playoff/dto.py | 4 ++++ jfr_playoff/matchinfo.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/jfr_playoff/dto.py b/jfr_playoff/dto.py index a88cd2b..fa22265 100644 --- a/jfr_playoff/dto.py +++ b/jfr_playoff/dto.py @@ -10,6 +10,10 @@ def coalesce(*arg): class Team(object): name = '' score = 0.0 + place = None + + def __init__(self): + self.place = [] def __unicode__(self): return u'%s (%.1f)' % (coalesce(self.name, ''), self.score) diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index 93b997a..5a31577 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -187,6 +187,10 @@ class MatchInfo: 'fetching HTML scores for match #%d failed: %s(%s)', self.info.id, type(e).__name__, str(e)) self.info.teams = self.__get_config_teams(self.info.teams) + for team in range(0, len(self.info.teams)): + if 'place' in self.config['teams'][team]: + self.info.teams[team].place = self.config['teams'][team]['place'] + def __get_db_board_count(self): towels = self.database.fetch( -- cgit v1.2.3 From 5dc528cbd21dbc6a372dbc021e3466e802148827 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 01:12:50 +0200 Subject: Expanding canvas if starting positions are to be displayed --- jfr_playoff/generator.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 22bdc82..2c68d68 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -120,19 +120,24 @@ class PlayoffGenerator(object): return '' def get_match_grid(self, dimensions, grid, matches): - canvas_size = ( + canvas_size = [ dimensions[0] * ( self.page['width'] + self.page['margin'] - ) - self.page['margin'], + ), dimensions[1] * ( self.page['height'] + self.page['margin'] - ) - self.page['margin']) + ) - self.page['margin']] + if 'starting_position_indicators' not in self.page \ + or not self.page['starting_position_indicators']: + canvas_size[0] -= self.page['margin'] PlayoffLogger.get('generator').info( 'canvas size: %s', canvas_size) grid_boxes = '' col_no = 0 for phase in grid: - grid_x = col_no * (self.page['width'] + self.page['margin']) + grid_x = col_no * self.page['width'] + (col_no + 1) * self.page['margin'] \ + if self.page['starting_position_indicators'] \ + else col_no * (self.page['width'] + self.page['margin']) grid_boxes += self.get_phase_header(phase, grid_x) match_height = canvas_size[1] / len(phase.matches) row_no = 0 -- cgit v1.2.3 From 00bb8ac06a45fd0cb960a7161a1f9cb713429a02 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 01:14:41 +0200 Subject: Drawing starting position boxes --- jfr_playoff/generator.py | 23 +++++++++++++++++++++++ jfr_playoff/template.py | 14 ++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 2c68d68..a42130a 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -119,6 +119,22 @@ class PlayoffGenerator(object): self.get_match_table(match)) return '' + def get_starting_position_box(self, positions, dimensions): + if 'starting_position_indicators' not in self.page \ + or not self.page['starting_position_indicators']: + return '' + boxes = '' + order = 0 + for place in sorted(positions): + boxes += self.p_temp.get( + 'STARTING_POSITION_BOX', + 0, + int(float(order) / float(len(positions)) * dimensions[1]), + place, place) + order += 1 + return boxes + + def get_match_grid(self, dimensions, grid, matches): canvas_size = [ dimensions[0] * ( @@ -134,6 +150,7 @@ class PlayoffGenerator(object): 'canvas size: %s', canvas_size) grid_boxes = '' col_no = 0 + starting_positions = set() for phase in grid: grid_x = col_no * self.page['width'] + (col_no + 1) * self.page['margin'] \ if self.page['starting_position_indicators'] \ @@ -151,8 +168,13 @@ class PlayoffGenerator(object): grid_boxes += self.get_match_box( matches[match] if match is not None else None, (grid_x, grid_y)) + if match is not None: + for team in matches[match].teams: + starting_positions.update(team.place) row_no += 1 col_no += 1 + starting_positions_boxes = self.get_starting_position_box( + starting_positions, canvas_size) return self.p_temp.get( 'MATCH_GRID', canvas_size[0], canvas_size[1], @@ -160,6 +182,7 @@ class PlayoffGenerator(object): ' '.join(['data-%s="%s"' % ( setting.replace('_', '-'), str(value) ) for setting, value in self.canvas.iteritems()]), + starting_positions_boxes, grid_boxes ) diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py index 70c179b..3473530 100644 --- a/jfr_playoff/template.py +++ b/jfr_playoff/template.py @@ -51,6 +51,7 @@ class PlayoffTemplateStrings(object):
%s + %s
''' @@ -77,6 +78,19 @@ class PlayoffTemplateStrings(object): ''' + STARTING_POSITION_BOX = ''' +
+ + + + + + + +
 
%d
+
+ ''' + MATCH_BOX = '''
%s -- cgit v1.2.3 From 8a29e0818606032bdecdf794e644dbb55d5f09b5 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 01:15:34 +0200 Subject: Generating connector info between matches and starting positions --- jfr_playoff/generator.py | 27 +++++++++++++++++++++------ jfr_playoff/template.py | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index a42130a..9b7f31e 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -106,16 +106,31 @@ class PlayoffGenerator(object): def get_match_box(self, match, position): if match is not None: + winner_link = [ + str(m) for m in match.winner_matches + ] if match.winner_matches is not None else [] + loser_link = [ + str(m) for m in match.loser_matches + ] if match.loser_matches is not None else [] + place_loser_link = [] + place_winner_link = [] + if 'starting_position_indicators' in self.page \ + and self.page['starting_position_indicators']: + for team in match.teams: + if len(team.place) > 0: + place_link = ['place-' + str(pl) for pl in team.place] + if len(team.place) > 1: + place_loser_link += place_link + else: + place_winner_link += place_link return self.p_temp.get( 'MATCH_BOX', position[0], position[1], match.id, - ' '.join([ - str(m) for m in match.winner_matches - ]) if match.winner_matches is not None else '', - ' '.join([ - str(m) for m in match.loser_matches - ]) if match.loser_matches is not None else '', + ' '.join(winner_link), + ' '.join(loser_link), + ' '.join(place_winner_link), + ' '.join(place_loser_link), self.get_match_table(match)) return '' diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py index 3473530..7b91b3b 100644 --- a/jfr_playoff/template.py +++ b/jfr_playoff/template.py @@ -92,7 +92,7 @@ class PlayoffTemplateStrings(object): ''' MATCH_BOX = ''' -
+
%s
''' -- cgit v1.2.3 From 48fac33c987be28c72e49509575e1622bfd96fc2 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 01:20:35 +0200 Subject: Tweaking connector offsets on canvas --- playoff.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playoff.js b/playoff.js index a2cfa6a..890a2b6 100644 --- a/playoff.js +++ b/playoff.js @@ -1,10 +1,10 @@ var playoff = { settings: { - 'winner_h_offset': 8, - 'loser_h_offset': 14, - 'winner_v_offset': -6, - 'loser_v_offset': 6, + 'winner_h_offset': 5, + 'loser_h_offset': 20, + 'winner_v_offset': -10, + 'loser_v_offset': 10, 'loser_colour': '#ff0000', 'winner_colour': '#00ff00' }, -- cgit v1.2.3 From cf548484722bc83c18a9d771e45874cf59bc68f0 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 01:21:01 +0200 Subject: Refactoring of connector line drawing --- playoff.js | 139 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 70 insertions(+), 69 deletions(-) diff --git a/playoff.js b/playoff.js index 890a2b6..613bf66 100644 --- a/playoff.js +++ b/playoff.js @@ -49,99 +49,100 @@ var playoff = { } var canvas = document.getElementById('playoff_canvas'); this.settings = this.loadSettings(canvas, this.settings); - var ctx = canvas.getContext('2d'); - for (var type in lines) { - ctx.strokeStyle = this.settings[type + '_colour']; - for (var from in lines[type]) { - var to = lines[type][from]; - from = from.split(' '); - var horizontal_from = []; - var vertical_from = [0, canvas.height, 0, 0]; + var lineMethods = { + 'winner': 'midpoint', + 'loser': 'midpoint' + }; + var lineCalculator = { + correctLines: function(hLines, vLine, comparator) { + for (var l1 in hLines) { + for (var l2 in hLines) { + hLines[l1][2] = comparator(hLines[l1][2], hLines[l2][2]); + hLines[l2][2] = hLines[l1][2]; + } + } + for (var l1 in hLines) { + vLine[0] = vLine[2] = comparator(hLines[l1][2], vLine[2]); + vLine[1] = Math.min(vLine[1], hLines[l1][3]); + vLine[3] = Math.max(vLine[3], hLines[l1][3]); + } + }, + template: function() { + return { + hFrom: [], + vFrom: [0, canvas.height, 0, 0], + hTo: [], + vTo: [canvas.width, canvas.height, canvas.width, 0], + midpoints: [] + } + }, + midpoint: function(from, to, hOffset, vOffset) { + var lines = this.template(); for (var f = 0; f < from.length; f++) { var box = boxes_idx[from[f]]; var line = [ Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth)), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + parseFloat(this.settings[type + '_v_offset'])), - Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth) + parseFloat(this.settings[type + '_h_offset'])), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + parseFloat(this.settings[type + '_v_offset'])) + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth) + hOffset), + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) ]; - horizontal_from.push(line); - for (var l in horizontal_from) { - if (horizontal_from[l][2] < line[2]) { - horizontal_from[l][2] = line[2]; - } else { - line[2] = horizontal_from[l][2]; - } - if (vertical_from[0] < horizontal_from[l][2]) { - vertical_from[0] = horizontal_from[l][2]; - vertical_from[2] = horizontal_from[l][2]; - } - if (vertical_from[1] > horizontal_from[l][3]) { - vertical_from[1] = horizontal_from[l][3]; - } - if (vertical_from[3] < horizontal_from[l][3]) { - vertical_from[3] = horizontal_from[l][3]; - } - } + lines.hFrom.push(line); } - var horizontal_to = []; - var vertical_to = [canvas.width, canvas.height, canvas.width, 0]; + this.correctLines(lines.hFrom, lines.vFrom, Math.max); for (var t = 0; t < to.length; t++) { var box = boxes_idx[to[t]]; var line = [ parseInt(box.style.left), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + parseFloat(this.settings[type + '_v_offset'])), - Math.floor(parseInt(box.style.left) - parseFloat(this.settings[type + '_h_offset'])), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + parseFloat(this.settings[type + '_v_offset'])) + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.style.left) - hOffset), + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) ]; - horizontal_to.push(line); - for (var l in horizontal_to) { - if (horizontal_to[l][2] > line[2]) { - horizontal_to[l][2] = line[2]; - } else { - line[2] = horizontal_to[l][2]; - } - if (vertical_to[0] > horizontal_to[l][2]) { - vertical_to[0] = horizontal_to[l][2]; - vertical_to[2] = horizontal_to[l][2]; - } - if (vertical_to[1] > horizontal_to[l][3]) { - vertical_to[1] = horizontal_to[l][3]; - } - if (vertical_to[3] < horizontal_to[l][3]) { - vertical_to[3] = horizontal_to[l][3]; - } - } + lines.hTo.push(line); } - var midpoints = [ + this.correctLines(lines.hTo, lines.vTo, Math.min); + lines.midpoints = [ [ - (vertical_from[0] + vertical_from[2]) / 2, - (vertical_from[1] + vertical_from[3]) / 2 + (lines.vFrom[0] + lines.vFrom[2]) / 2, + (lines.vFrom[1] + lines.vFrom[3]) / 2 ], [ - parseFloat(this.settings[type + '_h_offset']) / 2 + (vertical_from[0] + vertical_from[2] + vertical_to[0] + vertical_to[2]) / 4, - (vertical_from[1] + vertical_from[3]) / 2 + hOffset / 2 + (lines.vFrom[0] + lines.vFrom[2] + lines.vTo[0] + lines.vTo[2]) / 4, + (lines.vFrom[1] + lines.vFrom[3]) / 2 ], [ - parseFloat(this.settings[type + '_h_offset']) / 2 + (vertical_from[0] + vertical_from[2] + vertical_to[0] + vertical_to[2]) / 4, - (vertical_to[1] + vertical_to[3]) / 2 + hOffset / 2 + (lines.vFrom[0] + lines.vFrom[2] + lines.vTo[0] + lines.vTo[2]) / 4, + (lines.vTo[1] + lines.vTo[3]) / 2 ], [ - (vertical_to[0] + vertical_to[2]) / 2, - (vertical_to[1] + vertical_to[3]) / 2 + (lines.vTo[0] + lines.vTo[2]) / 2, + (lines.vTo[1] + lines.vTo[3]) / 2 ] ] - for (var l in horizontal_from) { - this.drawLine(ctx, horizontal_from[l]); + return lines; + } + }; + var ctx = canvas.getContext('2d'); + for (var type in lines) { + styleType = type.replace('-', '_'); + ctx.strokeStyle = this.settings[styleType + '_colour']; + for (var from in lines[type]) { + var to = lines[type][from]; + from = from.split(' '); + var linesToDraw = lineCalculator[lineMethods[type]]( + from, to, + this.settings[styleType + '_h_offset'], this.settings[styleType + '_v_offset']); + for (var l in linesToDraw.hFrom) { + this.drawLine(ctx, linesToDraw.hFrom[l]); } - this.drawLine(ctx, vertical_from); - for (var l in horizontal_to) { - this.drawLine(ctx, horizontal_to[l]); + this.drawLine(ctx, linesToDraw.vFrom); + for (var l in linesToDraw.hTo) { + this.drawLine(ctx, linesToDraw.hTo[l]); } - this.drawLine(ctx, vertical_to); - for (var m = 0; m < midpoints.length-1; m++) { + this.drawLine(ctx, linesToDraw.vTo); + for (var m = 0; m < linesToDraw.midpoints.length-1; m++) { this.drawLine(ctx, [ - midpoints[m][0], midpoints[m][1], midpoints[m+1][0], midpoints[m+1][1] + linesToDraw.midpoints[m][0], linesToDraw.midpoints[m][1], + linesToDraw.midpoints[m+1][0], linesToDraw.midpoints[m+1][1] ]); } } -- cgit v1.2.3 From a68f22c766792e98371693a856a26bc6f67c59ce Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 01:21:43 +0200 Subject: Adding drawing methods for starting position connectors --- playoff.js | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/playoff.js b/playoff.js index 613bf66..c118f58 100644 --- a/playoff.js +++ b/playoff.js @@ -6,7 +6,13 @@ var playoff = { 'winner_v_offset': -10, 'loser_v_offset': 10, 'loser_colour': '#ff0000', - 'winner_colour': '#00ff00' + 'winner_colour': '#00ff00', + 'place_winner_h_offset': 10, + 'place_loser_h_offset': 15, + 'place_winner_v_offset': 8, + 'place_loser_v_offset': 14, + 'place_loser_colour': '#dddd00', + 'place_winner_colour': '#00dddd' }, drawLine: function(ctx, line) { @@ -31,7 +37,9 @@ var playoff = { var boxes = document.getElementsByClassName('playoff_matchbox'); var lines = { 'winner': {}, - 'loser': {} + 'loser': {}, + 'place-winner': {}, + 'place-loser': {} }; var boxes_idx = {}; for (var b = 0; b < boxes.length; b++) { @@ -50,6 +58,8 @@ var playoff = { var canvas = document.getElementById('playoff_canvas'); this.settings = this.loadSettings(canvas, this.settings); var lineMethods = { + 'place-winner': 'to', + 'place-loser': 'to', 'winner': 'midpoint', 'loser': 'midpoint' }; @@ -76,6 +86,66 @@ var playoff = { midpoints: [] } }, + from: function(from, to, hOffset, vOffset) { + var lines = this.template(); + for (var f = 0; f < from.length; f++) { + var box = boxes_idx[from[f]]; + var line = [ + Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth)), + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth) + hOffset), + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + ]; + lines.hFrom.push(line); + } + this.correctLines(lines.hFrom, lines.vFrom, Math.max); + for (var t = 0; t < to.length; t++) { + var box = boxes_idx[to[t]]; + var line = [ + lines.vFrom[0], + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.style.left) - hOffset), + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + ]; + lines.hTo.push(line); + } + this.correctLines(lines.hTo, lines.vTo, Math.min); + lines.midpoints = [ + [lines.vFrom[0], lines.vFrom[1]], + [lines.vTo[0], lines.vTo[1]] + ]; + return lines; + }, + to: function(from, to, hOffset, vOffset) { + var lines = this.template(); + for (var t = 0; t < to.length; t++) { + var box = boxes_idx[to[t]]; + var line = [ + parseInt(box.style.left), + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.style.left) - hOffset), + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + ]; + lines.hTo.push(line); + } + this.correctLines(lines.hTo, lines.vTo, Math.min); + for (var f = 0; f < from.length; f++) { + var box = boxes_idx[from[f]]; + var line = [ + Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth)), + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), + lines.vTo[0], + Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + ]; + lines.hFrom.push(line); + } + this.correctLines(lines.hFrom, lines.vFrom, Math.max); + lines.midpoints = [ + [lines.vFrom[0], lines.vFrom[1]], + [lines.vTo[0], lines.vTo[1]] + ]; + return lines; + }, midpoint: function(from, to, hOffset, vOffset) { var lines = this.template(); for (var f = 0; f < from.length; f++) { -- cgit v1.2.3 From 1e3d4e3233a9d01a81525255ed0f1479a96c1e5d Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 03:15:15 +0200 Subject: Fixing box offsets for line drawing --- playoff.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/playoff.js b/playoff.js index c118f58..301f86c 100644 --- a/playoff.js +++ b/playoff.js @@ -91,10 +91,10 @@ var playoff = { for (var f = 0; f < from.length; f++) { var box = boxes_idx[from[f]]; var line = [ - Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth)), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), - Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth) + hOffset), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + Math.floor(parseInt(box.offsetLeft) + parseInt(box.clientWidth)), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.offsetLeft) + parseInt(box.clientWidth) + hOffset), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset) ]; lines.hFrom.push(line); } @@ -102,10 +102,10 @@ var playoff = { for (var t = 0; t < to.length; t++) { var box = boxes_idx[to[t]]; var line = [ + Math.floor(parseInt(box.offsetLeft)), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset), lines.vFrom[0], - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), - Math.floor(parseInt(box.style.left) - hOffset), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset) ]; lines.hTo.push(line); } @@ -121,10 +121,10 @@ var playoff = { for (var t = 0; t < to.length; t++) { var box = boxes_idx[to[t]]; var line = [ - parseInt(box.style.left), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), - Math.floor(parseInt(box.style.left) - hOffset), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + parseInt(box.offsetLeft), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.offsetLeft) - hOffset), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset) ]; lines.hTo.push(line); } @@ -132,10 +132,10 @@ var playoff = { for (var f = 0; f < from.length; f++) { var box = boxes_idx[from[f]]; var line = [ - Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth)), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.offsetLeft) + parseInt(box.clientWidth)), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset), lines.vTo[0], - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset) ]; lines.hFrom.push(line); } @@ -151,10 +151,10 @@ var playoff = { for (var f = 0; f < from.length; f++) { var box = boxes_idx[from[f]]; var line = [ - Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth)), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), - Math.floor(parseInt(box.style.left) + parseInt(box.clientWidth) + hOffset), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + Math.floor(parseInt(box.offsetLeft) + parseInt(box.clientWidth)), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.offsetLeft) + parseInt(box.clientWidth) + hOffset), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset) ]; lines.hFrom.push(line); } @@ -162,10 +162,10 @@ var playoff = { for (var t = 0; t < to.length; t++) { var box = boxes_idx[to[t]]; var line = [ - parseInt(box.style.left), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset), - Math.floor(parseInt(box.style.left) - hOffset), - Math.floor(parseInt(box.style.top) + 0.5 * parseInt(box.clientHeight) + vOffset) + parseInt(box.offsetLeft), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset), + Math.floor(parseInt(box.offsetLeft) - hOffset), + Math.floor(parseInt(box.offsetTop) + 0.5 * parseInt(box.clientHeight) + vOffset) ]; lines.hTo.push(line); } -- cgit v1.2.3 From ac0733c36b6200aecb2c738a549d00d7c2e6be98 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 03:20:13 +0200 Subject: Storing finishing positions in DTO --- jfr_playoff/dto.py | 2 ++ jfr_playoff/matchinfo.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/jfr_playoff/dto.py b/jfr_playoff/dto.py index fa22265..1bc153c 100644 --- a/jfr_playoff/dto.py +++ b/jfr_playoff/dto.py @@ -31,6 +31,8 @@ class Match(object): loser = None winner_matches = None loser_matches = None + winner_place = None + loser_place = None def __repr__(self): return (u'#%d (%s) %s [%s]' % ( diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index 5a31577..a7c4064 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -32,6 +32,8 @@ class MatchInfo: self.info.loser_matches += self.config['teams'][i]['loser'] self.info.winner_matches = list(set(self.info.winner_matches)) self.info.loser_matches = list(set(self.info.loser_matches)) + self.info.winner_place = self.config['winner'] if 'winner' in self.config else [] + self.info.loser_place = self.config['loser'] if 'loser' in self.config else [] self.info.teams = [] def __fetch_match_link(self): -- cgit v1.2.3 From f883784164de0a72ce61e8b225435de337ead2ed Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 03:22:38 +0200 Subject: Rendering position box independent from starting/finishing role --- jfr_playoff/generator.py | 3 ++- jfr_playoff/template.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 6a184fb..b72c34d 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -145,7 +145,8 @@ class PlayoffGenerator(object): 'STARTING_POSITION_BOX', 0, int(float(order) / float(len(positions)) * dimensions[1]), - place, place) + place, + self.p_temp.get('POSITION_BOX', place)) order += 1 return boxes diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py index 7b91b3b..881e1b5 100644 --- a/jfr_playoff/template.py +++ b/jfr_playoff/template.py @@ -80,15 +80,16 @@ class PlayoffTemplateStrings(object): STARTING_POSITION_BOX = '''
+ %s +
+ ''' + + POSITION_BOX = ''' - - -
 
%d
-
''' MATCH_BOX = ''' -- cgit v1.2.3 From 7ed51a63ac7aea8da6de888b04164b945ef745b5 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 03:23:47 +0200 Subject: Adding vertical margin to starting position boxes --- jfr_playoff/generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index b72c34d..0680aba 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -144,7 +144,7 @@ class PlayoffGenerator(object): boxes += self.p_temp.get( 'STARTING_POSITION_BOX', 0, - int(float(order) / float(len(positions)) * dimensions[1]), + self.page['margin'] / 2 + int(float(order) / float(len(positions)) * dimensions[1]), place, self.p_temp.get('POSITION_BOX', place)) order += 1 -- cgit v1.2.3 From 780c61d23789d80351476977f25699b2b5ec4c5d Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 03:24:41 +0200 Subject: Expanding canvas if finishing positions are rendered --- jfr_playoff/generator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 0680aba..b5c5e83 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -155,13 +155,16 @@ class PlayoffGenerator(object): canvas_size = [ dimensions[0] * ( self.page['width'] + self.page['margin'] - ), + ) + self.page['margin'], dimensions[1] * ( self.page['height'] + self.page['margin'] ) - self.page['margin']] if 'starting_position_indicators' not in self.page \ or not self.page['starting_position_indicators']: canvas_size[0] -= self.page['margin'] + if 'finishing_position_indicators' not in self.page \ + or not self.page['finishing_position_indicators']: + canvas_size[0] -= self.page['margin'] PlayoffLogger.get('generator').info( 'canvas size: %s', canvas_size) grid_boxes = '' -- cgit v1.2.3 From 31fb6dfb977fca26cf4eeb539b9f4d83f42b6a40 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 03:26:26 +0200 Subject: Rendering finishing boxes with connector data --- jfr_playoff/generator.py | 38 ++++++++++++++++++++++++++++++++++---- jfr_playoff/template.py | 7 +++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index b5c5e83..ef83a73 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -150,6 +150,22 @@ class PlayoffGenerator(object): order += 1 return boxes + def get_finishing_position_box(self, positions, position_info, dimensions, margin): + if 'finishing_position_indicators' not in self.page \ + or not self.page['finishing_position_indicators']: + return '' + boxes = '' + order = 0 + for place in sorted(positions): + boxes += self.p_temp.get( + 'FINISHING_POSITION_BOX', + self.page['margin'] / 2 + int(float(order) / float(len(positions)) * dimensions[1]), + place, + ' '.join([str(p) for p in position_info[place]['winner']]), + ' '.join([str(p) for p in position_info[place]['loser']]), + self.p_temp.get('POSITION_BOX', place)) + order += 1 + return boxes def get_match_grid(self, dimensions, grid, matches): canvas_size = [ @@ -170,6 +186,8 @@ class PlayoffGenerator(object): grid_boxes = '' col_no = 0 starting_positions = set() + finishing_positions = {} + finishing_places = set() for phase in grid: grid_x = col_no * self.page['width'] + (col_no + 1) * self.page['margin'] \ if self.page['starting_position_indicators'] \ @@ -190,10 +208,19 @@ class PlayoffGenerator(object): if match is not None: for team in matches[match].teams: starting_positions.update(team.place) + for place in matches[match].loser_place + matches[match].winner_place: + if place not in finishing_positions: + finishing_positions[place] = { + 'winner': [], + 'loser': [] + } + finishing_places.add(place) + for place in matches[match].winner_place: + finishing_positions[place]['winner'].append(match) + for place in matches[match].loser_place: + finishing_positions[place]['loser'].append(match) row_no += 1 col_no += 1 - starting_positions_boxes = self.get_starting_position_box( - starting_positions, canvas_size) return self.p_temp.get( 'MATCH_GRID', canvas_size[0], canvas_size[1], @@ -201,8 +228,11 @@ class PlayoffGenerator(object): ' '.join(['data-%s="%s"' % ( setting.replace('_', '-'), str(value) ) for setting, value in self.canvas.iteritems()]), - starting_positions_boxes, - grid_boxes + self.get_starting_position_box(starting_positions, canvas_size), + grid_boxes, + self.get_finishing_position_box( + finishing_places, finishing_positions, canvas_size, self.page['margin'] + ) ) def get_leaderboard_row_class(self, position): diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py index 881e1b5..267c5f7 100644 --- a/jfr_playoff/template.py +++ b/jfr_playoff/template.py @@ -52,6 +52,7 @@ class PlayoffTemplateStrings(object): %s %s + %s
''' @@ -84,6 +85,12 @@ class PlayoffTemplateStrings(object): ''' + FINISHING_POSITION_BOX = ''' +
+ %s +
+ ''' + POSITION_BOX = ''' -- cgit v1.2.3 From acfc6044e25c7ff7d56a62dc1f62c21a7546f560 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 03:28:29 +0200 Subject: Rendering connectors for finishing positions --- playoff.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/playoff.js b/playoff.js index 301f86c..a648b4b 100644 --- a/playoff.js +++ b/playoff.js @@ -3,8 +3,12 @@ var playoff = { settings: { 'winner_h_offset': 5, 'loser_h_offset': 20, + 'finish_winner_h_offset': 5, + 'finish_loser_h_offset': 20, 'winner_v_offset': -10, 'loser_v_offset': 10, + 'finish_winner_v_offset': -4, + 'finish_loser_v_offset': 4, 'loser_colour': '#ff0000', 'winner_colour': '#00ff00', 'place_winner_h_offset': 10, @@ -12,7 +16,9 @@ var playoff = { 'place_winner_v_offset': 8, 'place_loser_v_offset': 14, 'place_loser_colour': '#dddd00', - 'place_winner_colour': '#00dddd' + 'place_winner_colour': '#00dddd', + 'finish_loser_colour': '#ff0000', + 'finish_winner_colour': '#00ff00' }, drawLine: function(ctx, line) { @@ -39,7 +45,9 @@ var playoff = { 'winner': {}, 'loser': {}, 'place-winner': {}, - 'place-loser': {} + 'place-loser': {}, + 'finish-winner': {}, + 'finish-loser': {} }; var boxes_idx = {}; for (var b = 0; b < boxes.length; b++) { @@ -60,6 +68,8 @@ var playoff = { var lineMethods = { 'place-winner': 'to', 'place-loser': 'to', + 'finish-winner': 'midpoint', + 'finish-loser': 'midpoint', 'winner': 'midpoint', 'loser': 'midpoint' }; -- cgit v1.2.3 From 3b49b542ca32d602722a3f4ba5c185242d7e5dc1 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 03:28:53 +0200 Subject: Adjusting connector parameters --- playoff.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playoff.js b/playoff.js index a648b4b..3b57cdf 100644 --- a/playoff.js +++ b/playoff.js @@ -3,18 +3,18 @@ var playoff = { settings: { 'winner_h_offset': 5, 'loser_h_offset': 20, + 'place_winner_h_offset': 10, + 'place_loser_h_offset': 15, 'finish_winner_h_offset': 5, 'finish_loser_h_offset': 20, 'winner_v_offset': -10, 'loser_v_offset': 10, + 'place_winner_v_offset': 2, + 'place_loser_v_offset': 9, 'finish_winner_v_offset': -4, 'finish_loser_v_offset': 4, 'loser_colour': '#ff0000', 'winner_colour': '#00ff00', - 'place_winner_h_offset': 10, - 'place_loser_h_offset': 15, - 'place_winner_v_offset': 8, - 'place_loser_v_offset': 14, 'place_loser_colour': '#dddd00', 'place_winner_colour': '#00dddd', 'finish_loser_colour': '#ff0000', -- cgit v1.2.3 From 216d9673887196a0b8c2475081b115944bbff233 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 13:58:02 +0200 Subject: Position boxes documentation --- CONFIG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CONFIG.md b/CONFIG.md index 906081f..391e2b2 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -25,10 +25,14 @@ Konfiguracja składa się, po kolei, z: + `"refresh"` - parametr odświeżania strony drabinki: `0` = wyłączone, liczba naturalna = interwał odświeżania, w sekundach + `"width"` i `"height"` - wymiary (w pikselach) miejsca rezerwowanego dla każdego meczu w widoku drabinki (`"width"` bezpośrednio wpływa na rozmieszczanie kolumn, wewnątrz każdej z kolumn mecze rozmieszczane są równomiernie, w zależnie od ich liczby) + `"margin"` - odstęp między w/w miejscem (minimalny - jak widać, w przypadku mniejszej liczby meczów w fazie, odstępy się dopasują) + + `"starting_position_indicators"`, `"finishing_position_indicators"` - włączają znaczniki miejsc początkowych/końcowych, wynikających ze zdefiniowanego schematu - sekcji `"canvas"`: ustawień rysowania linii + + `"winner_colour"`, `"loser_colour"` - kolory linii zwycięzców i przegranych + + `"place_winner_colour"`, `"place_loser_colour"` - kolory linii łączących początkowe miejsca drużyn z pierwszymi meczami (`loser` - drużyny mogące zagrać w więcej niż jednym meczu, czyli wybierane) + + `"finish_winner_colour"`, `"finish_loser_colour"` - kolory linii łączących końcowe miejsca drużyn z ich ostatnimi meczami + `"winner_h_offset"`, `"winner_v_offset"` - marginesy (poziomy i pionowy) rysowania linii zwycięzców (odpowiednio: pionowych i poziomych, względem środka obszaru) + `"loser_h_offset"`, `"loser_v_offset"` - analogiczne marginesy rysowania linii przegranych - + `"winner_colour"`, `"loser_colour"` - kolory linii zwycięzców i przegranych + + `"place_winner_h_offset"`, `"place_winner_v_offset"`, `"place_loser_h_offset"`, `"place_loser_v_offset"`, `"finish_winner_h_offset"`, `"finish_winner_v_offset"`, `"finish_loser_h_offset"`, `"finish_loser_v_offset"` - marginesy rysowania linii łączących mecze z miejscami początkowymi/końcowymi - sekcji `"database"`, zawierającej ustawienia połączenia bazy danych - sekcji `"goniec"`, zawierającej ustawienia Gońca (`"enabled"` przyjmuje wartości `0`/`1`) -- cgit v1.2.3 From 6bc2303307a24ac1ad53eedde461dedb25ec157c Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 14:20:49 +0200 Subject: Allowing for custom positioning of match boxes --- jfr_playoff/generator.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index ef83a73..12a4365 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -200,8 +200,17 @@ class PlayoffGenerator(object): int(row_no * match_height + 0.5 * (match_height - self.page['height'])) PlayoffLogger.get('generator').info( - 'grid box (%d, %d) position: (%d, %d)', + 'calculated grid box (%d, %d) position: (%d, %d)', col_no, row_no, grid_x, grid_y) + if 'box_positioning' in self.canvas \ + and str(match) in self.canvas['box_positioning']: + if isinstance(self.canvas['box_positioning'][str(match)], list): + grid_x, grid_y = self.canvas['box_positioning'][str(match)][0:2] + else: + grid_y = float(self.canvas['box_positioning'][str(match)]) + PlayoffLogger.get('generator').info( + 'overridden box #%d position: (%d, %d)', + match, grid_x, grid_y) grid_boxes += self.get_match_box( matches[match] if match is not None else None, (grid_x, grid_y)) @@ -227,7 +236,7 @@ class PlayoffGenerator(object): canvas_size[0], canvas_size[1], ' '.join(['data-%s="%s"' % ( setting.replace('_', '-'), str(value) - ) for setting, value in self.canvas.iteritems()]), + ) for setting, value in self.canvas.iteritems() if not isinstance(value, dict)]), self.get_starting_position_box(starting_positions, canvas_size), grid_boxes, self.get_finishing_position_box( -- cgit v1.2.3 From 34ca26ef666e69d2a5123d4ca37dde7845305a9e Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 Jul 2018 14:23:10 +0200 Subject: Docuemntation for custom box positioning --- CONFIG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONFIG.md b/CONFIG.md index 391e2b2..eac0d71 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -33,6 +33,7 @@ Konfiguracja składa się, po kolei, z: + `"winner_h_offset"`, `"winner_v_offset"` - marginesy (poziomy i pionowy) rysowania linii zwycięzców (odpowiednio: pionowych i poziomych, względem środka obszaru) + `"loser_h_offset"`, `"loser_v_offset"` - analogiczne marginesy rysowania linii przegranych + `"place_winner_h_offset"`, `"place_winner_v_offset"`, `"place_loser_h_offset"`, `"place_loser_v_offset"`, `"finish_winner_h_offset"`, `"finish_winner_v_offset"`, `"finish_loser_h_offset"`, `"finish_loser_v_offset"` - marginesy rysowania linii łączących mecze z miejscami początkowymi/końcowymi + + `"box_positioning"`: możliwość ręcznego ustawienia pozycji każdego meczu - słownik indeksowany tekstowymi identyfikatorami meczów, z wartościami liczbowymi: pojedyncza wartość = pozycja w pionie w pikselach, w ramach fazy meczu, tablica dwóch wartości: dowolna pozycja w pikselach - sekcji `"database"`, zawierającej ustawienia połączenia bazy danych - sekcji `"goniec"`, zawierającej ustawienia Gońca (`"enabled"` przyjmuje wartości `0`/`1`) -- cgit v1.2.3 From 5cf43985f96daa156d1b201ce4f5b8e925c7c711 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 10 Jul 2018 16:34:14 +0200 Subject: Sanitizing config options --- jfr_playoff/generator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index ef83a73..a90cf77 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -190,7 +190,8 @@ class PlayoffGenerator(object): finishing_places = set() for phase in grid: grid_x = col_no * self.page['width'] + (col_no + 1) * self.page['margin'] \ - if self.page['starting_position_indicators'] \ + if 'starting_position_indicators' in self.page \ + and self.page['starting_position_indicators'] \ else col_no * (self.page['width'] + self.page['margin']) grid_boxes += self.get_phase_header(phase, grid_x) match_height = canvas_size[1] / len(phase.matches) -- cgit v1.2.3 From 17b67eec50d428383406d4309bc7506fd22015db Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 17:45:52 +0200 Subject: Refactoring fetching default values for config dictionaries --- jfr_playoff/generator.py | 9 +++------ jfr_playoff/matchinfo.py | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 19b8c1d..c2fba28 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -117,8 +117,7 @@ class PlayoffGenerator(object): ] if match.loser_matches is not None else [] place_loser_link = [] place_winner_link = [] - if 'starting_position_indicators' in self.page \ - and self.page['starting_position_indicators']: + if self.page.get('starting_position_indicators', None): for team in match.teams: if len(team.place) > 0: place_link = ['place-' + str(pl) for pl in team.place] @@ -193,8 +192,7 @@ class PlayoffGenerator(object): finishing_places = set() for phase in grid: grid_x = col_no * self.page['width'] + (col_no + 1) * self.page['margin'] \ - if 'starting_position_indicators' in self.page \ - and self.page['starting_position_indicators'] \ + if self.page.get('starting_position_indicators', None) \ else col_no * (self.page['width'] + self.page['margin']) grid_boxes += self.get_phase_header(phase, grid_x) match_height = canvas_size[1] / len(phase.matches) @@ -206,8 +204,7 @@ class PlayoffGenerator(object): PlayoffLogger.get('generator').info( 'calculated grid box (%d, %d) position: (%d, %d)', col_no, row_no, grid_x, grid_y) - if 'box_positioning' in self.canvas \ - and str(match) in self.canvas['box_positioning']: + if str(match) in self.canvas.get('box_positioning', {}): if isinstance(self.canvas['box_positioning'][str(match)], list): grid_x, grid_y = self.canvas['box_positioning'][str(match)][0:2] else: diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index 4089a76..3e4d913 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -32,8 +32,8 @@ class MatchInfo: self.info.loser_matches += self.config['teams'][i]['loser'] self.info.winner_matches = list(set(self.info.winner_matches)) self.info.loser_matches = list(set(self.info.loser_matches)) - self.info.winner_place = self.config['winner'] if 'winner' in self.config else [] - self.info.loser_place = self.config['loser'] if 'loser' in self.config else [] + self.info.winner_place = self.config.get('winner', []) + self.info.loser_place = self.config.get('loser', []) self.info.teams = [] def __fetch_match_link(self): @@ -215,8 +215,8 @@ class MatchInfo: self.info.id, type(e).__name__, str(e)) self.info.teams = self.__get_config_teams(self.info.teams) for team in range(0, len(self.info.teams)): - if 'place' in self.config['teams'][team]: - self.info.teams[team].place = self.config['teams'][team]['place'] + self.info.teams[team].place = self.config['teams'][team].get( + 'place', self.info.teams[team].place) def __get_db_board_count(self): -- cgit v1.2.3