From 2220e5487673774256bed8e0c4ef38900e8962b2 Mon Sep 17 00:00:00 2001 From: Rogier Neeleman Date: Mon, 3 Jul 2017 22:24:42 +0200 Subject: [PATCH] Shortview for bigger games --- nfgame.cfg-example | 4 ++++ nfgame.py | 9 ++++++++- templates/overview.html | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/nfgame.cfg-example b/nfgame.cfg-example index c5c8294..9619027 100644 --- a/nfgame.cfg-example +++ b/nfgame.cfg-example @@ -20,6 +20,10 @@ SHOW_TIME = '120' # Refresh time for the scoreboard and highscore pages REFRESH_TIME = '10' +# Shortview. If you got to many tags on the score board, show only the amount +# of tags the player has scored. +SHORT_VIEW = 'false' + # HTML text for the registration page: REGISTRATION_DESK = 'You can find the registration desk in the center.' diff --git a/nfgame.py b/nfgame.py index 5a8d2fd..2afa116 100644 --- a/nfgame.py +++ b/nfgame.py @@ -22,6 +22,7 @@ app.config.update(dict( MAX_TIME = '3600', SHOW_TIME = '120', REFRESH_TIME = '10', + SHORT_VIEW = 'false', SECRET_KEY = 'Very secret key!', ADMIN_PASSWORD = 'changeme!' )) @@ -73,6 +74,8 @@ def index(): user = {} tags = app.config['TAGS'] timeremaining = {} + tagcount = {} + tagcount['total'] = len(tags) for entry in entries: if entry['tags'] == None: @@ -81,12 +84,16 @@ def index(): found_tags = entry['tags'].split(',') user[entry['id']] = {} + counter = 0 for tag in tags: user[entry['id']][tag] = 'Not' for found_tag in found_tags: if found_tag == tag: user[entry['id']][tag] = 'Found' + counter = counter + 1 + + tagcount[entry['id']] = counter '''Calculate time remaining''' starttime = datetime.strptime(entry['starttime'], "%Y-%m-%d %H:%M:%S") @@ -104,7 +111,7 @@ def index(): seconds = '0' + str(seconds) timeremaining[entry['id']] = str(hours) + ":" + str(minutes) + ":" + str(seconds) - return render_template('overview.html', entries=entries, tags=app.config['TAGS'], user=user, type='Current players', refresh=app.config['REFRESH_TIME'], timeremaining=timeremaining) + return render_template('overview.html', entries=entries, tags=app.config['TAGS'], user=user, type='Current players', refresh=app.config['REFRESH_TIME'], timeremaining=timeremaining, shortview=app.config['SHORT_VIEW'], tagcount=tagcount) @app.route('/highscores') def highscores(): diff --git a/templates/overview.html b/templates/overview.html index 8613f6f..a33bec2 100644 --- a/templates/overview.html +++ b/templates/overview.html @@ -10,9 +10,13 @@ Name + {% if shortview == 'true' %} + Found + {% else %} {% for tag in tags %} {{ tags.get(tag) }} {% endfor %} + {% endif %} Duration Time remaining @@ -21,6 +25,9 @@ {% for entry in entries %} {{ entry.username }} + {% if shortview == 'true' %} + {{ tagcount[entry.id] }} + {% else %} {% for tag in tags %} {% if user[entry.id][tag] == 'Found' %} @@ -30,6 +37,7 @@ {% endif %} {% endfor %} + {% endif %} {% if entry.duration == '99:99:99' %} No time yet