emmergency fix
This commit is contained in:
parent
3e57610040
commit
4208941d3c
4 changed files with 19 additions and 12 deletions
1
assholes
1
assholes
|
@ -1,2 +1,3 @@
|
|||
Luc Absil
|
||||
Benjamin Criton
|
||||
Clara Husson
|
||||
|
|
20
roulette.py
20
roulette.py
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf8 -*
|
||||
|
||||
from flask import Flask, request, g, redirect, url_for, \
|
||||
abort, render_template, flash
|
||||
abort, render_template, flash, read
|
||||
|
||||
from functools import wraps
|
||||
from contextlib import closing
|
||||
|
@ -23,7 +23,8 @@ ASSHOLES = []
|
|||
SQLITE_FILENAME = '/var/roulette/players.db'
|
||||
SQLITE_SCHEMA = 'schema.sql'
|
||||
|
||||
BAN_DURATION = 30. * 60.
|
||||
BAN_DURATION_VICTIM = 30. * 60.
|
||||
BAN_DURATION_BULLY = 10. * 60.
|
||||
|
||||
IMMUNITY_FILE = '/var/roulette/immunity'
|
||||
ASSHOLES_FILE = '/var/roulette/assholes'
|
||||
|
@ -203,7 +204,7 @@ def cheat(player_id, target_id):
|
|||
return success
|
||||
|
||||
|
||||
def ban(player_id, target_id, success):
|
||||
def ban(player_id, target_id, success, victim=False):
|
||||
player = get_player(player_id)
|
||||
target = get_player(target_id)
|
||||
|
||||
|
@ -216,7 +217,10 @@ def ban(player_id, target_id, success):
|
|||
where id=%i"""% banned_player['id'])
|
||||
|
||||
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
|
||||
where id=%i"""% (ban_end, banned_player['id']))
|
||||
|
@ -233,7 +237,7 @@ def unban(player_id):
|
|||
cur = con.cursor()
|
||||
|
||||
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.close()
|
||||
|
@ -414,11 +418,11 @@ def play():
|
|||
success = cheat(player['id'], target_id)
|
||||
if success:
|
||||
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.' \
|
||||
% target['firstname'])
|
||||
else:
|
||||
ban(player['id'], target_id, False)
|
||||
ban(player['id'], target_id, False, victim=False)
|
||||
return banned()
|
||||
|
||||
# Liste des joueurs non bannis, triée dans l'ordre croissant ou décroissant
|
||||
|
@ -447,11 +451,13 @@ def complete():
|
|||
return json.dumps(rows)
|
||||
|
||||
def ban_guimoz():
|
||||
print("Bannissement de guimoz")
|
||||
ban(23891,23503,True)
|
||||
|
||||
def ban_aleatoire():
|
||||
players = get_players_not_banned()
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
<div class="title">Trancher un joueur</div>
|
||||
<div class="desc">
|
||||
Ta cible sera notifiée quelle que soit l'issue de ta tentative. Question
|
||||
chance, c'est 50-50.
|
||||
Tu peux bannir quelqu'un pour une durée de 30 minutes. Si tu échoues, tu est bannis 10 minutes.
|
||||
Ta cible sera notifiée quelle que soit l'issue de ta tentative. Question chance, c'est 50-50.
|
||||
</div>
|
||||
|
||||
<div class="sep"></div>
|
||||
|
||||
<form action="" method="post">
|
||||
|
||||
|
||||
<div class="desc">Écris le nom de ta victime :</div>
|
||||
<input type="text" name="search" id="word">
|
||||
<br>
|
||||
|
@ -23,7 +23,7 @@
|
|||
</select>
|
||||
<br>
|
||||
<input type="submit" value="TCHAK!" id="tchak" class="button" />
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<div class="sep"></div>
|
||||
|
|
2
test.txt
2
test.txt
|
@ -1 +1 @@
|
|||
This is only a test.
|
||||
ah
|
||||
|
|
Loading…
Reference in a new issue