mirror of
https://github.com/RYGhub/royal-mifia.git
synced 2024-11-25 23:24:18 +00:00
Potrei aver sistemato un sacco di cose. O aver rotto tutto.
This commit is contained in:
parent
652ee21dbb
commit
d36e75e998
1 changed files with 18 additions and 15 deletions
33
main.py
33
main.py
|
@ -445,8 +445,8 @@ class Player:
|
||||||
if not self.dummy:
|
if not self.dummy:
|
||||||
try:
|
try:
|
||||||
bot.sendMessage(self.tid, text, parse_mode=ParseMode.MARKDOWN)
|
bot.sendMessage(self.tid, text, parse_mode=ParseMode.MARKDOWN)
|
||||||
except TelegramError:
|
except Unauthorized:
|
||||||
pass
|
print("Unauthorized to message {}".format(self))
|
||||||
|
|
||||||
|
|
||||||
def kill(self, bot, game):
|
def kill(self, bot, game):
|
||||||
|
@ -829,6 +829,15 @@ class Game:
|
||||||
for player in self.players:
|
for player in self.players:
|
||||||
player.role.onstartgame(bot, self)
|
player.role.onstartgame(bot, self)
|
||||||
|
|
||||||
|
def revealallroles(self, bot):
|
||||||
|
text = s.status_header.format(name=self.groupid, admin=self.admin.tid, phase=self.phase)
|
||||||
|
self.updatevotes()
|
||||||
|
# Aggiungi l'elenco dei giocatori
|
||||||
|
for player in self.players:
|
||||||
|
text += s.status_basic_player.format(icon=player.role.icon,
|
||||||
|
name=player.tusername)
|
||||||
|
self.message(bot, text)
|
||||||
|
|
||||||
def endgame(self):
|
def endgame(self):
|
||||||
inprogress.remove(self)
|
inprogress.remove(self)
|
||||||
|
|
||||||
|
@ -876,6 +885,8 @@ class Game:
|
||||||
self.message(bot, s.end_game_wiped)
|
self.message(bot, s.end_game_wiped)
|
||||||
for player in self.players:
|
for player in self.players:
|
||||||
player.message(bot, s.end_game_wiped + s.tie)
|
player.message(bot, s.end_game_wiped + s.tie)
|
||||||
|
self.revealallroles(bot)
|
||||||
|
self.endgame()
|
||||||
# I mifiosi sono più del 50% dei vivi se la mifia è infallibile
|
# I mifiosi sono più del 50% dei vivi se la mifia è infallibile
|
||||||
# o non ci sono più personaggi buoni se la mifia può mancare i colpi
|
# o non ci sono più personaggi buoni se la mifia può mancare i colpi
|
||||||
elif (not self.missingmifia and evil >= (alive-evil)) or good == 0:
|
elif (not self.missingmifia and evil >= (alive-evil)) or good == 0:
|
||||||
|
@ -887,6 +898,7 @@ class Game:
|
||||||
player.message(bot, s.end_mifia_outnumber + s.victory)
|
player.message(bot, s.end_mifia_outnumber + s.victory)
|
||||||
elif player.role.team == 'Chaos':
|
elif player.role.team == 'Chaos':
|
||||||
player.message(bot, s.end_game_chaos + s.victory)
|
player.message(bot, s.end_game_chaos + s.victory)
|
||||||
|
self.revealallroles(bot)
|
||||||
self.endgame()
|
self.endgame()
|
||||||
# Male distrutto
|
# Male distrutto
|
||||||
elif evil == 0:
|
elif evil == 0:
|
||||||
|
@ -898,6 +910,7 @@ class Game:
|
||||||
player.message(bot, s.end_mifia_killed + s.defeat)
|
player.message(bot, s.end_mifia_killed + s.defeat)
|
||||||
elif player.role.team == 'Chaos':
|
elif player.role.team == 'Chaos':
|
||||||
player.message(bot, s.end_game_chaos + s.victory)
|
player.message(bot, s.end_game_chaos + s.victory)
|
||||||
|
self.revealallroles(bot)
|
||||||
self.endgame()
|
self.endgame()
|
||||||
|
|
||||||
def changerole(self, bot, player, newrole):
|
def changerole(self, bot, player, newrole):
|
||||||
|
@ -1322,17 +1335,7 @@ def debug(bot, update):
|
||||||
if __debug__:
|
if __debug__:
|
||||||
game = findgamebyid(update.message.chat['id'])
|
game = findgamebyid(update.message.chat['id'])
|
||||||
if game is not None:
|
if game is not None:
|
||||||
text = s.status_header.format(name=game.groupid, admin=game.admin.tid, phase=game.phase)
|
game.revealallroles(bot)
|
||||||
game.updatevotes()
|
|
||||||
# Aggiungi l'elenco dei giocatori
|
|
||||||
for player in game.players:
|
|
||||||
if not player.alive:
|
|
||||||
text += s.status_dead_player.format(name=player.tusername)
|
|
||||||
else:
|
|
||||||
text += s.status_alive_player.format(icon=player.role.icon,
|
|
||||||
name=player.tusername,
|
|
||||||
votes=str(player.votes))
|
|
||||||
game.message(bot, text)
|
|
||||||
else:
|
else:
|
||||||
bot.sendMessage(update.message.chat['id'], s.error_no_games_found, parse_mode=ParseMode.MARKDOWN)
|
bot.sendMessage(update.message.chat['id'], s.error_no_games_found, parse_mode=ParseMode.MARKDOWN)
|
||||||
|
|
||||||
|
@ -1395,8 +1398,8 @@ updater.dispatcher.add_handler(CallbackQueryHandler(inlinekeyboard))
|
||||||
updater.start_polling()
|
updater.start_polling()
|
||||||
print("Bot avviato!")
|
print("Bot avviato!")
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
while:
|
while True:
|
||||||
try:
|
try:
|
||||||
updater.idle()
|
updater.idle()
|
||||||
except TimedOut:
|
except TimedOut:
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
Loading…
Reference in a new issue