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
|
Luc Absil
|
||||||
Benjamin Criton
|
Benjamin Criton
|
||||||
|
Clara Husson
|
||||||
|
|
20
roulette.py
20
roulette.py
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
<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>
|
||||||
|
|
2
test.txt
2
test.txt
|
@ -1 +1 @@
|
||||||
This is only a test.
|
ah
|
||||||
|
|
Loading…
Reference in a new issue