|
|
|
@ -357,12 +357,47 @@ def home(): |
|
|
|
player = get_player_from_ip(get_ip()) |
|
|
|
if DEBUG: |
|
|
|
print(STATE) |
|
|
|
if DEBUG: |
|
|
|
print(player, 'arrived') |
|
|
|
bans = sorted(get_bans(player['id']), \ |
|
|
|
key=lambda ban: ban['time'], \ |
|
|
|
reverse=True) |
|
|
|
|
|
|
|
bans_hist = [] |
|
|
|
for ban in bans: |
|
|
|
date = strftime('%Hh%M (%A)', localtime(ban['time'])) |
|
|
|
source = get_player(ban['player_id']) |
|
|
|
target = get_player(ban['target_id']) |
|
|
|
|
|
|
|
if target['id'] == player['id']: |
|
|
|
if ban['success']: |
|
|
|
entry = ('ban', u'%s : %s %s a réussi à t\'avoir.' \ |
|
|
|
% (date, source['firstname'], source['name'])) |
|
|
|
else: |
|
|
|
entry = ('warn', u'%s : %s %s a essayé de te trancher, en vain.' \ |
|
|
|
% (date, source['firstname'], source['name'])) |
|
|
|
else: |
|
|
|
if ban['success']: |
|
|
|
entry = ('ok', u'%s : Tu as tranché %s %s avec succès.' \ |
|
|
|
% (date, target['firstname'], target['name'])) |
|
|
|
else: |
|
|
|
entry = ('ban', u'%s : Tu as échoué en voulant trancher %s %s.' \ |
|
|
|
% (date, target['firstname'], target['name'])) |
|
|
|
bans_hist.append(entry) |
|
|
|
|
|
|
|
if "down" in STATE: |
|
|
|
return render_template('down.html', user=player,stats=statistiques()) |
|
|
|
return render_template('down.html', user=player, stats=statistiques(), bans_hist=bans_hist) |
|
|
|
elif "up" in STATE: |
|
|
|
if DEBUG: |
|
|
|
print(player, 'arrived') |
|
|
|
return render_template('home.html', bans_hist=bans_hist, stats=statistiques()) |
|
|
|
else: |
|
|
|
return render_template('precampagne.html', user=player,stats=statistiques()) |
|
|
|
|
|
|
|
@app.route('/jouer', methods=['GET', 'POST']) |
|
|
|
@playable_required |
|
|
|
def play(): |
|
|
|
ip = get_ip() |
|
|
|
player = get_player_from_ip(ip) |
|
|
|
if "down" in STATE: |
|
|
|
bans = sorted(get_bans(player['id']), \ |
|
|
|
key=lambda ban: ban['time'], \ |
|
|
|
reverse=True) |
|
|
|
@ -387,19 +422,9 @@ def home(): |
|
|
|
else: |
|
|
|
entry = ('ban', u'%s : Tu as échoué en voulant trancher %s %s.' \ |
|
|
|
% (date, target['firstname'], target['name'])) |
|
|
|
|
|
|
|
bans_hist.append(entry) |
|
|
|
return render_template('home.html', bans_hist=bans_hist, stats=statistiques()) |
|
|
|
else: |
|
|
|
return render_template('precampagne.html', user=player,stats=statistiques()) |
|
|
|
|
|
|
|
@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,stats=statistiques()) |
|
|
|
|
|
|
|
elif "up" in STATE: |
|
|
|
# Traitement de la requête de bannissement |
|
|
|
if request.method == 'POST': |
|
|
|
|