Browse Source

Shortview for bigger games

pull/14/head
Rogier Neeleman 7 years ago
parent
commit
2220e54876
  1. 4
      nfgame.cfg-example
  2. 9
      nfgame.py
  3. 8
      templates/overview.html

4
nfgame.cfg-example

@ -20,6 +20,10 @@ SHOW_TIME = '120' @@ -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.'

9
nfgame.py

@ -22,6 +22,7 @@ app.config.update(dict( @@ -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(): @@ -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(): @@ -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(): @@ -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():

8
templates/overview.html

@ -10,9 +10,13 @@ @@ -10,9 +10,13 @@
<thead>
<tr>
<td>Name</td>
{% if shortview == 'true' %}
<td>Found</td>
{% else %}
{% for tag in tags %}
<td>{{ tags.get(tag) }}</td>
{% endfor %}
{% endif %}
<td>Duration</td>
<td>Time remaining</td>
</tr>
@ -21,6 +25,9 @@ @@ -21,6 +25,9 @@
{% for entry in entries %}
<tr>
<td>{{ entry.username }}</td>
{% if shortview == 'true' %}
<td>{{ tagcount[entry.id] }}</td>
{% else %}
{% for tag in tags %}
<td>
{% if user[entry.id][tag] == 'Found' %}
@ -30,6 +37,7 @@ @@ -30,6 +37,7 @@
{% endif %}
</td>
{% endfor %}
{% endif %}
<td>
{% if entry.duration == '99:99:99' %}
No time yet

Loading…
Cancel
Save