1
Fork 0
mirror of https://github.com/RYGhub/royal-mifia.git synced 2024-11-22 05:44:19 +00:00

Creato metodo game.newphase e game.nextday

This commit is contained in:
Steffo 2017-07-19 13:10:57 +02:00
parent bfaadf28c3
commit f039243388

21
main.py
View file

@ -268,9 +268,7 @@ class Game:
def startpreset(self): def startpreset(self):
"""Inizio della fase di preset""" """Inizio della fase di preset"""
self.phase = 'Preset' self.newphase("Preset")
# Aggiorna il nome del gruppo
self.updategroupname()
# Crea la tastiera # Crea la tastiera
kbmarkup = InlineKeyboardMarkup([ kbmarkup = InlineKeyboardMarkup([
[ [
@ -362,12 +360,10 @@ class Game:
# Se non ce ne sono abbastanza, torna alla fase di join # Se non ce ne sono abbastanza, torna alla fase di join
if requiredplayers > len(self.players): if requiredplayers > len(self.players):
self.message(s.error_not_enough_players) self.message(s.error_not_enough_players)
self.phase = "Join" self.newphase("Join")
self.updategroupname()
else: else:
self.phase = 'Voting' self.newphase("Voting", silent=True)
self.day += 1 self.nextday()
self.updategroupname()
self.players.sort(key=lambda p: p.tusername) self.players.sort(key=lambda p: p.tusername)
self.assignroles() self.assignroles()
self.message(s.roles_assigned_successfully) self.message(s.roles_assigned_successfully)
@ -494,6 +490,15 @@ class Game:
availableroles.append(existingrole) availableroles.append(existingrole)
return globals()[random.sample(availableroles, 1)[0]] # EWWW return globals()[random.sample(availableroles, 1)[0]] # EWWW
def newphase(self, phase: str, silent: bool=False):
self.phase = phase
if not silent:
self.updategroupname()
def nextday(self, silent: bool=False):
self.day += 1
if not silent:
self.updategroupname()
# Partite in corso # Partite in corso