From 5d731c764cdb42c2ff34b22ba3d1058b7cad4a04 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 11 Apr 2016 23:12:27 +0200 Subject: [PATCH] =?UTF-8?q?Credo=20di=20non=20aver=20mai=20scritto=20codic?= =?UTF-8?q?e=20pi=C3=B9=20brutto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mifia.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/mifia.py b/mifia.py index dd1cbd06..48bec5f9 100644 --- a/mifia.py +++ b/mifia.py @@ -118,7 +118,10 @@ class Game: if votelist[player] > mostvotes: mostvoted = player mostvotes = votelist[player] - return self.findusername(mostvoted) + if mostvoted is not None: + return self.findusername(mostvoted) + else: + return None def endday(self): votedout = self.mostvoted() @@ -135,6 +138,7 @@ class Game: player.votedfor = str() if player.role != 0: player.special = True + self.msg(self.displaycount()) # Controlla se la Royal Games ha vinto zero = 0 uno = 0 @@ -152,6 +156,19 @@ class Game: "I Mifiosi rimasti sono più dei Royal.") self.tokill = list() + def displaycount(self) -> str: + zero = 0 + uno = 0 + for player in self.players: + if player.alive: + if player.role == 0 or player.role == 2: + zero += 1 + elif player.role == 1: + uno += 1 + msg = "*Royal*: {0} persone rimaste" \ + "*Mifia*: {1} persone rimaste".format(str(zero), str(uno)) + return msg + def save(self): status = configparser.ConfigParser() status['General'] = { @@ -295,9 +312,11 @@ while True: g.message(p.username + " si è unito alla partita!") elif t['text'].startswith("/status"): g.message(g.status()) + g.message(g.displaycount()) elif t['text'].startswith("/fullstatus"): if t['from']['id'] == g.adminid: g.adminmessage(g.fullstatus()) + g.message(g.displaycount()) elif t['text'].startswith("/save"): if t['from']['id'] == g.adminid: g.save()