Browse Source

Shortview for bigger games

pull/14/head
Rogier Neeleman 8 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'
# Refresh time for the scoreboard and highscore pages # Refresh time for the scoreboard and highscore pages
REFRESH_TIME = '10' 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: # HTML text for the registration page:
REGISTRATION_DESK = 'You can find the registration desk in the center.' REGISTRATION_DESK = 'You can find the registration desk in the center.'

9
nfgame.py

@ -22,6 +22,7 @@ app.config.update(dict(
MAX_TIME = '3600', MAX_TIME = '3600',
SHOW_TIME = '120', SHOW_TIME = '120',
REFRESH_TIME = '10', REFRESH_TIME = '10',
SHORT_VIEW = 'false',
SECRET_KEY = 'Very secret key!', SECRET_KEY = 'Very secret key!',
ADMIN_PASSWORD = 'changeme!' ADMIN_PASSWORD = 'changeme!'
)) ))
@ -73,6 +74,8 @@ def index():
user = {} user = {}
tags = app.config['TAGS'] tags = app.config['TAGS']
timeremaining = {} timeremaining = {}
tagcount = {}
tagcount['total'] = len(tags)
for entry in entries: for entry in entries:
if entry['tags'] == None: if entry['tags'] == None:
@ -81,12 +84,16 @@ def index():
found_tags = entry['tags'].split(',') found_tags = entry['tags'].split(',')
user[entry['id']] = {} user[entry['id']] = {}
counter = 0
for tag in tags: for tag in tags:
user[entry['id']][tag] = 'Not' user[entry['id']][tag] = 'Not'
for found_tag in found_tags: for found_tag in found_tags:
if found_tag == tag: if found_tag == tag:
user[entry['id']][tag] = 'Found' user[entry['id']][tag] = 'Found'
counter = counter + 1
tagcount[entry['id']] = counter
'''Calculate time remaining''' '''Calculate time remaining'''
starttime = datetime.strptime(entry['starttime'], "%Y-%m-%d %H:%M:%S") starttime = datetime.strptime(entry['starttime'], "%Y-%m-%d %H:%M:%S")
@ -104,7 +111,7 @@ def index():
seconds = '0' + str(seconds) seconds = '0' + str(seconds)
timeremaining[entry['id']] = str(hours) + ":" + str(minutes) + ":" + 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') @app.route('/highscores')
def highscores(): def highscores():

8
templates/overview.html

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

Loading…
Cancel
Save