1
Fork 0
mirror of https://github.com/RYGhub/royal-mifia.git synced 2025-02-16 13:24:06 +00:00

Assegnazione dei ruoli fatta

ma non va
This commit is contained in:
Steffo 2016-04-22 19:55:24 +02:00
parent 7ece5356eb
commit 8cd272080d

30
main.py
View file

@ -134,6 +134,33 @@ class Game:
else:
return None
def assignroles(self, mifia=2, investigatore=1):
import random
random.seed()
playersleft = self.players.copy()
random.shuffle(playersleft)
# Seleziona 2 mifiosi
while mifia > 0:
try:
selected = playersleft.pop()
except IndexError:
raise IndexError("Non ci sono abbastanza giocatori!")
else:
selected.role = Mifioso()
mifia -= 1
# Seleziona 1 detective
while investigatore > 0:
try:
selected = playersleft.pop()
except IndexError:
raise IndexError("Non ci sono abbastanza giocatori!")
else:
selected.role = Investigatore()
investigatore -= 1
# Assegna il ruolo di Royal a tutti gli altri
for player in playersleft:
player.role = Royal()
# Partite in corso
inprogress = list()
@ -191,7 +218,8 @@ def endjoin(bot, update):
if game is not None and game.phase is 'Join':
game.phase = 'Voting'
bot.sendMessage(update.message.chat['id'], "La fase di join è terminata.")
# TODO: Aggiungere assegnazione ruoli
game.assignroles()
bot.sendMessage(update.message.chat['id'], "I ruoli sono stati assegnati.")
def vote(bot, update):