summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-07-06 03:26:26 +0200
committeremkael <emkael@tlen.pl>2018-07-06 03:26:26 +0200
commit31fb6dfb977fca26cf4eeb539b9f4d83f42b6a40 (patch)
tree3900304822088941f0eec76d5437cfd2152c8295 /jfr_playoff
parent780c61d23789d80351476977f25699b2b5ec4c5d (diff)
Rendering finishing boxes with connector data
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/generator.py38
-rw-r--r--jfr_playoff/template.py7
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):
<canvas width="%d" height="%d" id="playoff_canvas" %s></canvas>
%s
%s
+ %s
<script src="sklady/playoff.js" type="text/javascript"></script>
</div>
'''
@@ -84,6 +85,12 @@ class PlayoffTemplateStrings(object):
</div>
'''
+ FINISHING_POSITION_BOX = '''
+ <div style="position: absolute; right: 0px; top: %dpx" class="playoff_matchbox" data-id="finish-%d" data-finish-winner="%s" data-finish-loser="%s">
+ %s
+ </div>
+ '''
+
POSITION_BOX = '''
<table border="0" cellspacing="0">
<tr>