1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00

Credo di non aver mai scritto codice più brutto

This commit is contained in:
Steffo 2016-04-11 23:12:27 +02:00
parent b843186495
commit 5d731c764c

View file

@ -118,7 +118,10 @@ class Game:
if votelist[player] > mostvotes: if votelist[player] > mostvotes:
mostvoted = player mostvoted = player
mostvotes = votelist[player] mostvotes = votelist[player]
return self.findusername(mostvoted) if mostvoted is not None:
return self.findusername(mostvoted)
else:
return None
def endday(self): def endday(self):
votedout = self.mostvoted() votedout = self.mostvoted()
@ -135,6 +138,7 @@ class Game:
player.votedfor = str() player.votedfor = str()
if player.role != 0: if player.role != 0:
player.special = True player.special = True
self.msg(self.displaycount())
# Controlla se la Royal Games ha vinto # Controlla se la Royal Games ha vinto
zero = 0 zero = 0
uno = 0 uno = 0
@ -152,6 +156,19 @@ class Game:
"I Mifiosi rimasti sono più dei Royal.") "I Mifiosi rimasti sono più dei Royal.")
self.tokill = list() 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): def save(self):
status = configparser.ConfigParser() status = configparser.ConfigParser()
status['General'] = { status['General'] = {
@ -295,9 +312,11 @@ while True:
g.message(p.username + " si è unito alla partita!") g.message(p.username + " si è unito alla partita!")
elif t['text'].startswith("/status"): elif t['text'].startswith("/status"):
g.message(g.status()) g.message(g.status())
g.message(g.displaycount())
elif t['text'].startswith("/fullstatus"): elif t['text'].startswith("/fullstatus"):
if t['from']['id'] == g.adminid: if t['from']['id'] == g.adminid:
g.adminmessage(g.fullstatus()) g.adminmessage(g.fullstatus())
g.message(g.displaycount())
elif t['text'].startswith("/save"): elif t['text'].startswith("/save"):
if t['from']['id'] == g.adminid: if t['from']['id'] == g.adminid:
g.save() g.save()