From ffa850c32e5282991594f76b795888d5ea9b1f20 Mon Sep 17 00:00:00 2001 From: guimoz Date: Sat, 28 Jan 2017 17:12:13 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20du=20fichier=20d'immunit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roulette.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/roulette.py b/roulette.py index c5c155e..d4c1b80 100644 --- a/roulette.py +++ b/roulette.py @@ -207,13 +207,23 @@ def get_players_not_banned(): rows = cur.fetchall() con.close() - return [{'id': row[0], 'firstname': row[1], 'name': row[2]} for row in rows] + not_banned = [{'id': row[0], 'firstname': row[1], 'name': row[2]} for row in rows] + + # Ensuite on applique les règles d'immunité + with open(IMMUNITY_FILE, 'r') as f: + immunity = f.read() + result = [] + for user in not_banned: + if user.['firstname']+' '+usr.['name'] not in immunity: + result.append(user) + + return result def cheat(player_id, target_id): success = random.choice([True, False]) try: - ok = [line.strip().partition(' ') for line in IMMUNITY] - ok = [get_player_from_full_name(names[0], names[2])['id'] for names in ok] + # ok = [line.strip().partition(' ') for line in IMMUNITY] + # ok = [get_player_from_full_name(names[0], names[2])['id'] for names in ok] ko = [line.strip().partition(' ') for line in ASSHOLES] ko = [get_player_from_full_name(names[0], names[2])['id'] for names in ko] @@ -222,8 +232,8 @@ def cheat(player_id, target_id): success = True elif player_id in ko: success = False - elif target_id in ok: - success = False + # elif target_id in ok: + # success = False except TypeError: pass