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:
parent
7ece5356eb
commit
8cd272080d
1 changed files with 29 additions and 1 deletions
30
main.py
30
main.py
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue