1
Fork 0
mirror of https://github.com/RYGhub/royal-mifia.git synced 2024-11-25 07:04:18 +00:00

Aggiunta la possibilità di annullare il voto

This commit is contained in:
Steffo 2017-07-18 00:46:57 +02:00
parent 69f9ea0a15
commit fec4e6bd9a
2 changed files with 25 additions and 7 deletions

21
main.py
View file

@ -715,8 +715,11 @@ def vote(bot, update):
if not player.alive:
continue
row = list()
row.append(InlineKeyboardButton(s.vote_keyboard_line.format(name=player.tusername, votes=player.votes), callback_data=player.tusername))
row.append(InlineKeyboardButton(s.vote_keyboard_line.format(player=player, votes=player.votes), callback_data=player.tusername))
table.append(row)
row = list()
row.append(InlineKeyboardButton(s.vote_keyboard_nobody, callback_data="-"))
table.append(row)
keyboard = InlineKeyboardMarkup(table)
# Manda la tastiera
bot.sendMessage(game.groupid, s.vote_keyboard, parse_mode=ParseMode.MARKDOWN, reply_markup=keyboard)
@ -892,11 +895,17 @@ def inlinekeyboard(bot, update):
if not player.alive:
bot.answerCallbackQuery(callback_query_id=update.callback_query.id, text=s.error_dead, show_alert=True)
return
# Trova il bersaglio
target = game.findplayerbyusername(update.callback_query.data)
player.votingfor = target
game.message(bot, s.vote.format(voting=player.tusername, voted=target.tusername))
bot.answerCallbackQuery(callback_query_id=update.callback_query.id, text=s.vote_fp.format(voted=target.tusername))
if update.callback_query.data == "-":
# Annulla il voto
player.votingfor = None
game.message(bot, s.vote_none.format(player=player))
bot.answerCallbackQuery(callback_query_id=update.callback_query.id, text=s.vote_none_fp)
else:
# Cambia il voto
target = game.findplayerbyusername(update.callback_query.data)
player.votingfor = target
game.message(bot, s.vote.format(voting=player.tusername, voted=target.tusername))
bot.answerCallbackQuery(callback_query_id=update.callback_query.id, text=s.vote_fp.format(voted=target.tusername))
updater.dispatcher.add_handler(CommandHandler('ping', ping))

View file

@ -237,9 +237,15 @@ mifia_team_player = "{icon} @{name}\n"
# Generale: votazione completata
vote = "@{voting} ha votato per uccidere @{voted}."
# Generale: votazione annullata
vote_none = "{player} ha annullato il suo voto."
# Generale: votazione completata in prima persona
vote_fp = "Hai votato per uccidere @{voted}."
# Generale: votazione annullata in prima persona
vote_none_fp = "Hai annullato il tuo voto."
# Generale: un admin ha ucciso un giocatore con /kill
admin_killed = "{name} è morto _di infarto_.\n" \
"Era un *{icon} {role}*."
@ -274,7 +280,10 @@ end_game_chaos = "Sei un Signore del Caos."
vote_keyboard = "Chi vuoi votare...?"
# Generale: riga della tastiera del voto
vote_keyboard_line = "@{name} - {votes}"
vote_keyboard_line = "{player} - {votes}"
# Generale: riga della tastiera per annullare il voto
vote_keyboard_nobody = "Nessuno"
# Generale: inizia un nuovo giorno
new_day = "Sorge l'alba del giorno *{day}*!"