1
Fork 0
mirror of https://github.com/RYGhub/royal-mifia.git synced 2024-11-22 05:44:19 +00:00
This commit is contained in:
Steffo 2016-04-22 20:43:23 +02:00
parent de66c516da
commit 729f095977

15
main.py
View file

@ -134,7 +134,7 @@ class Game:
else:
return None
def assignroles(self, mifia=2, investigatore=1):
def assignroles(self, mifia=2, investigatore=1, angelo=0):
import random
random.seed()
playersleft = self.players.copy()
@ -157,6 +157,15 @@ class Game:
else:
selected.role = Investigatore()
investigatore -= 1
# Seleziona 1 angelo
while investigatore > 0:
try:
selected = playersleft.pop()
except IndexError:
raise IndexError("Non ci sono abbastanza giocatori!")
else:
selected.role = Angelo()
investigatore -= 1
# Assegna il ruolo di Royal a tutti gli altri
for player in playersleft:
player.role = Royal()
@ -219,10 +228,10 @@ def status(bot, update):
def endjoin(bot, update):
game = findgamebyid(update.message.chat['id'])
if game is not None and game.phase is 'Join':
if game is not None and game.phase is 'Join' and update.message.from_user['id'] == game.adminid:
game.phase = 'Voting'
bot.sendMessage(update.message.chat['id'], "La fase di join è terminata.")
game.assignroles(1, 1)
game.assignroles(1, 1, 1)
bot.sendMessage(update.message.chat['id'], "I ruoli sono stati assegnati.")