From 79191a406eb7dc3fdba136ceb747023b1251217e Mon Sep 17 00:00:00 2001 From: Klafyvel Date: Sat, 13 Jan 2018 13:27:27 +0100 Subject: [PATCH] On ne tranche pas les Metzthernets. --- roulette.py | 32 ++++++++++++++++++-------------- state | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/roulette.py b/roulette.py index 97f6ea9..2157824 100644 --- a/roulette.py +++ b/roulette.py @@ -176,22 +176,26 @@ def cheat(player_id, target_id): success = random.choice([True, False]) with open(IMMUNITY_FILE, 'r') as f: immunity = f.read() - try: - ok = [line.strip().partition(' ') for line in immunity] - ok = [get_player_from_full_name(names[0], names[2])['id'] for names in ok] + with open(ASSHOLES_FILE, 'r') as f: + assholes = f.read() + ok = [line.split(' ') for line in immunity.split('\n') if line] + ok = [get_player_from_full_name(names[0], names[1])['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] + ko_names = [line.split(' ') for line in assholes.split('\n') if line] + ko = [] + for names in ko_names: + p = get_player_from_full_name(names[0], names[1]) + if p: + ko.append(p['id']) + if target_id in ko: + success = True + elif player_id in ko: + success = False + elif target_id in ok: + success = False + elif player_id in ok: + success = True - if target_id in ko: - success = True - elif player_id in ko: - success = False - elif target_id in ok: - success = False - - except TypeError: - pass return success diff --git a/state b/state index e31ee94..187efb2 100644 --- a/state +++ b/state @@ -1 +1 @@ -up +up precampagne !!