Correction de bugs
This commit is contained in:
parent
8bd93b22d5
commit
815d7abe21
1 changed files with 43 additions and 45 deletions
62
roulette.py
62
roulette.py
|
@ -352,11 +352,31 @@ def banned_ip():
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@playable_required
|
@playable_required
|
||||||
def home():
|
def home():
|
||||||
|
#Calcul des statistiques
|
||||||
|
con = connect_sqlite()
|
||||||
|
cur = con.cursor()
|
||||||
|
|
||||||
|
cur.execute("""select firstname,name,ban_end from players""")
|
||||||
|
|
||||||
|
rows = cur.fetchall()
|
||||||
|
con.close()
|
||||||
|
tranchés = 0
|
||||||
|
n_tranchés = 0
|
||||||
|
with open(IMMUNITY_FILE, 'r') as f:
|
||||||
|
immunity = f.read()
|
||||||
|
for row in rows:
|
||||||
|
if row[0]+' '+row[1] not in immunity:
|
||||||
|
if row[2] > time():
|
||||||
|
tranchés += 1
|
||||||
|
else:
|
||||||
|
n_tranchés += 1
|
||||||
|
|
||||||
|
stats = (tranchés,n_tranchés)
|
||||||
player = get_player_from_ip(get_ip())
|
player = get_player_from_ip(get_ip())
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(STATE)
|
print(STATE)
|
||||||
if "down" in STATE:
|
if "down" in STATE:
|
||||||
return render_template('down.html', user=player)
|
return render_template('down.html', user=player,stats=stats)
|
||||||
elif "up" in STATE:
|
elif "up" in STATE:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(player, 'arrived')
|
print(player, 'arrived')
|
||||||
|
@ -387,7 +407,15 @@ def home():
|
||||||
% (date, target['firstname'], target['name']))
|
% (date, target['firstname'], target['name']))
|
||||||
|
|
||||||
bans_hist.append(entry)
|
bans_hist.append(entry)
|
||||||
|
return render_template('home.html', bans_hist=bans_hist, stats=stats)
|
||||||
|
else:
|
||||||
|
return render_template('precampagne.html', user=player,stats=stats)
|
||||||
|
|
||||||
|
@app.route('/jouer', methods=['GET', 'POST'])
|
||||||
|
@playable_required
|
||||||
|
def play():
|
||||||
|
ip = get_ip()
|
||||||
|
player = get_player_from_ip(ip)
|
||||||
#Calcul des statistiques
|
#Calcul des statistiques
|
||||||
con = connect_sqlite()
|
con = connect_sqlite()
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
@ -408,15 +436,6 @@ def home():
|
||||||
n_tranchés += 1
|
n_tranchés += 1
|
||||||
|
|
||||||
stats = (tranchés,n_tranchés)
|
stats = (tranchés,n_tranchés)
|
||||||
return render_template('home.html', bans_hist=bans_hist, stats=stats)
|
|
||||||
else:
|
|
||||||
return render_template('precampagne.html', user=player)
|
|
||||||
|
|
||||||
@app.route('/jouer', methods=['GET', 'POST'])
|
|
||||||
@playable_required
|
|
||||||
def play():
|
|
||||||
ip = get_ip()
|
|
||||||
player = get_player_from_ip(ip)
|
|
||||||
if "down" in STATE:
|
if "down" in STATE:
|
||||||
return render_template('down.html', user=player)
|
return render_template('down.html', user=player)
|
||||||
elif "up" in STATE:
|
elif "up" in STATE:
|
||||||
|
@ -445,30 +464,9 @@ def play():
|
||||||
# sans le joueur actuel
|
# sans le joueur actuel
|
||||||
players = filter(lambda p: p['id'] != player['id'], players)
|
players = filter(lambda p: p['id'] != player['id'], players)
|
||||||
|
|
||||||
#Calcul des statistiques
|
|
||||||
con = connect_sqlite()
|
|
||||||
cur = con.cursor()
|
|
||||||
|
|
||||||
cur.execute("""select firstname,name,ban_end from players""")
|
|
||||||
|
|
||||||
rows = cur.fetchall()
|
|
||||||
con.close()
|
|
||||||
tranchés = 0
|
|
||||||
n_tranchés = 0
|
|
||||||
with open(IMMUNITY_FILE, 'r') as f:
|
|
||||||
immunity = f.read()
|
|
||||||
for row in rows:
|
|
||||||
if row[0]+' '+row[1] not in immunity:
|
|
||||||
if row[2] > time():
|
|
||||||
tranchés += 1
|
|
||||||
else:
|
|
||||||
n_tranchés += 1
|
|
||||||
|
|
||||||
stats = (tranchés,n_tranchés)
|
|
||||||
|
|
||||||
return render_template('play.html', players=players, stats=stats)
|
return render_template('play.html', players=players, stats=stats)
|
||||||
else:
|
else:
|
||||||
return render_template('precampagne.html', user=player)
|
return render_template('precampagne.html', user=player,stats=stats)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run()
|
||||||
|
|
Loading…
Reference in a new issue