From e919574d47a25a93af7d651af17e863990819a36 Mon Sep 17 00:00:00 2001 From: Rogier Neeleman Date: Mon, 3 Jul 2017 21:56:02 +0200 Subject: [PATCH] #11 user get an end-messages on his last tag. --- nfgame.py | 17 ++++++++++++++++- templates/tagfound.html | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/nfgame.py b/nfgame.py index 2f04db7..5a8d2fd 100644 --- a/nfgame.py +++ b/nfgame.py @@ -249,7 +249,22 @@ def tag_found(taghash): cur = db.execute('update score set tags = ?, lasttime = datetime(), duration = ? where id = ?', [cur_score, time, session['id']]) db.commit() - return render_template('tagfound.html', tagname=tags.get(taghash), color='#00FF00', time=timeremaining) + '''Check if this was the user his last item''' + tagquery = "" + for tag in app.config['TAGS']: + if tagquery == "": + tagquery = 'where tags like "%' + tag + '%"' + else: + tagquery = tagquery + ' and tags like "%' + tag + '%"' + + db = get_db() + cur = db.execute('select * from score ' + tagquery + ' and id = ?', [session['id']]) + entries = cur.fetchall() + + if entries: + return render_template('tagfound.html', tagname=tags.get(taghash), color='#00FF00', time=timeremaining, endgame='yes') + else: + return render_template('tagfound.html', tagname=tags.get(taghash), color='#00FF00', time=timeremaining, endgame='no') @app.route('/admin/') def admin_page(password): diff --git a/templates/tagfound.html b/templates/tagfound.html index ec3add0..120ce91 100644 --- a/templates/tagfound.html +++ b/templates/tagfound.html @@ -4,7 +4,12 @@

Found tag!

You found tag: {{ tagname }}!

+ {% if endgame == 'yes' %} + Good job! You got all the tags!
+ Return to the the registration desk. + {% else %} Time left to play: {{ time }} + {% endif %} {% endblock %}