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('/')
|
||||
@playable_required
|
||||
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())
|
||||
if DEBUG:
|
||||
print(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:
|
||||
if DEBUG:
|
||||
print(player, 'arrived')
|
||||
|
@ -387,7 +407,15 @@ def home():
|
|||
% (date, target['firstname'], target['name']))
|
||||
|
||||
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
|
||||
con = connect_sqlite()
|
||||
cur = con.cursor()
|
||||
|
@ -408,15 +436,6 @@ def home():
|
|||
n_tranchés += 1
|
||||
|
||||
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:
|
||||
return render_template('down.html', user=player)
|
||||
elif "up" in STATE:
|
||||
|
@ -445,30 +464,9 @@ def play():
|
|||
# sans le joueur actuel
|
||||
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)
|
||||
else:
|
||||
return render_template('precampagne.html', user=player)
|
||||
return render_template('precampagne.html', user=player,stats=stats)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
|
Loading…
Reference in a new issue