emmergency fix

This commit is contained in:
root 2018-02-05 13:02:36 +01:00
parent 3e57610040
commit 4208941d3c
4 changed files with 19 additions and 12 deletions

View file

@ -1,2 +1,3 @@
Luc Absil Luc Absil
Benjamin Criton Benjamin Criton
Clara Husson

View file

@ -1,7 +1,7 @@
# -*- coding: utf8 -* # -*- coding: utf8 -*
from flask import Flask, request, g, redirect, url_for, \ from flask import Flask, request, g, redirect, url_for, \
abort, render_template, flash abort, render_template, flash, read
from functools import wraps from functools import wraps
from contextlib import closing from contextlib import closing
@ -23,7 +23,8 @@ ASSHOLES = []
SQLITE_FILENAME = '/var/roulette/players.db' SQLITE_FILENAME = '/var/roulette/players.db'
SQLITE_SCHEMA = 'schema.sql' SQLITE_SCHEMA = 'schema.sql'
BAN_DURATION = 30. * 60. BAN_DURATION_VICTIM = 30. * 60.
BAN_DURATION_BULLY = 10. * 60.
IMMUNITY_FILE = '/var/roulette/immunity' IMMUNITY_FILE = '/var/roulette/immunity'
ASSHOLES_FILE = '/var/roulette/assholes' ASSHOLES_FILE = '/var/roulette/assholes'
@ -203,7 +204,7 @@ def cheat(player_id, target_id):
return success return success
def ban(player_id, target_id, success): def ban(player_id, target_id, success, victim=False):
player = get_player(player_id) player = get_player(player_id)
target = get_player(target_id) target = get_player(target_id)
@ -216,7 +217,10 @@ def ban(player_id, target_id, success):
where id=%i"""% banned_player['id']) where id=%i"""% banned_player['id'])
ban_end = cur.fetchone()[0] ban_end = cur.fetchone()[0]
ban_end = time() + BAN_DURATION if victim:
ban_end = time() + BAN_DURATION_VICTIM
else:
ban_end = time() + BAN_DURATION_BULLY
cur.execute("""update players set ban_end=%f cur.execute("""update players set ban_end=%f
where id=%i"""% (ban_end, banned_player['id'])) where id=%i"""% (ban_end, banned_player['id']))
@ -233,7 +237,7 @@ def unban(player_id):
cur = con.cursor() cur = con.cursor()
cur.execute("""update players set ban_end=%f cur.execute("""update players set ban_end=%f
where id=%i"""% (time() - BAN_DURATION, player_id)) where id=%i"""% (0, player_id))
con.commit() con.commit()
con.close() con.close()
@ -414,11 +418,11 @@ def play():
success = cheat(player['id'], target_id) success = cheat(player['id'], target_id)
if success: if success:
target = get_player(target_id) target = get_player(target_id)
ban(player['id'], target_id, True) ban(player['id'], target_id, True, victim=True)
flash(u'Trop cool, %s a été tranché pour un bon moment.' \ flash(u'Trop cool, %s a été tranché pour un bon moment.' \
% target['firstname']) % target['firstname'])
else: else:
ban(player['id'], target_id, False) ban(player['id'], target_id, False, victim=False)
return banned() return banned()
# Liste des joueurs non bannis, triée dans l'ordre croissant ou décroissant # Liste des joueurs non bannis, triée dans l'ordre croissant ou décroissant
@ -447,11 +451,13 @@ def complete():
return json.dumps(rows) return json.dumps(rows)
def ban_guimoz(): def ban_guimoz():
print("Bannissement de guimoz")
ban(23891,23503,True) ban(23891,23503,True)
def ban_aleatoire(): def ban_aleatoire():
players = get_players_not_banned() players = get_players_not_banned()
player_1, player_2 = random.sample(players, 2) player_1, player_2 = random.sample(players, 2)
print("Bannissement aléatoire de " + player_2['id'] + " par " + player_1['id'])
ban(player_1['id'],player_2['id'],True) ban(player_1['id'],player_2['id'],True)

View file

@ -3,14 +3,14 @@
<div class="title">Trancher un joueur</div> <div class="title">Trancher un joueur</div>
<div class="desc"> <div class="desc">
Ta cible sera notifiée quelle que soit l'issue de ta tentative. Question Tu peux bannir quelqu'un pour une durée de 30 minutes. Si tu échoues, tu est bannis 10 minutes.
chance, c'est 50-50. Ta cible sera notifiée quelle que soit l'issue de ta tentative. Question chance, c'est 50-50.
</div> </div>
<div class="sep"></div> <div class="sep"></div>
<form action="" method="post"> <form action="" method="post">
<div class="desc">Écris le nom de ta victime :</div> <div class="desc">Écris le nom de ta victime :</div>
<input type="text" name="search" id="word"> <input type="text" name="search" id="word">
<br> <br>
@ -23,7 +23,7 @@
</select> </select>
<br> <br>
<input type="submit" value="TCHAK!" id="tchak" class="button" /> <input type="submit" value="TCHAK!" id="tchak" class="button" />
</form> </form>
<div class="sep"></div> <div class="sep"></div>

View file

@ -1 +1 @@
This is only a test. ah