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

Merge remote-tracking branch 'origin/stagismo' into stagismo

This commit is contained in:
Steffo 2017-01-29 20:18:32 +01:00
commit ad3e68c53e
2 changed files with 33 additions and 20 deletions

44
main.py
View file

@ -1122,21 +1122,15 @@ def vote(bot, update):
elif game.day <= 1: elif game.day <= 1:
game.message(bot, s.error_no_votes_on_first_day) game.message(bot, s.error_no_votes_on_first_day)
return return
# Trova il giocatore # Genera la tastiera
player = game.findplayerbyid(update.message.from_user['id']) table = list()
if player is None: for player in game.players:
game.message(bot, s.error_not_in_game) row = list()
return row.append(InlineKeyboardButton(s.vote_keyboard_line.format(name=player.tusername), callback_data=player.tusername))
if not player.alive: table.append(row)
game.message(bot, s.error_dead) keyboard = InlineKeyboardMarkup(table)
return # Manda la tastiera
# Trova il bersaglio bot.sendMessage(game.groupid, s.vote_keyboard, parse_mode=ParseMode.MARKDOWN, reply_markup=keyboard)
target = game.findplayerbyusername(update.message.text.split(' ')[1])
if target is None:
game.message(bot, s.error_username)
return
player.votingfor = target
game.message(bot, s.vote.format(voting=player.tusername, voted=target.tusername))
def endday(bot, update): def endday(bot, update):
@ -1296,12 +1290,22 @@ def debuggameslist(bot, update):
bot.sendMessage(update.message.from_user['id'], repr(inprogress), parse_mode=ParseMode.MARKDOWN) bot.sendMessage(update.message.from_user['id'], repr(inprogress), parse_mode=ParseMode.MARKDOWN)
def selectpreset(bot, update): def inlinekeyboard(bot, update):
"""Seleziona un preset dalla tastiera.""" """Seleziona un preset dalla tastiera."""
game = findgamebyid(update.callback_query.message.chat['id']) game = findgamebyid(update.callback_query.message.chat['id'])
if game is not None and game.phase is 'Preset': if game is not None:
if update.callback_query.from_user['id'] == game.admin.tid: if game.phase is 'Preset':
game.loadpreset(bot, update.callback_query.data) if update.callback_query.from_user['id'] == game.admin.tid:
game.loadpreset(bot, update.callback_query.data)
elif game.phase is 'Voting':
# Trova il giocatore
player = game.findplayerbyid(update.callback_query.from_user['id'])
if player is not None:
# 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))
def handleerror(bot, update, error): def handleerror(bot, update, error):
@ -1332,7 +1336,7 @@ updater.dispatcher.add_handler(CommandHandler('save', save))
updater.dispatcher.add_handler(CommandHandler('load', load)) updater.dispatcher.add_handler(CommandHandler('load', load))
updater.dispatcher.add_handler(CommandHandler('delete', delete)) updater.dispatcher.add_handler(CommandHandler('delete', delete))
updater.dispatcher.add_handler(CommandHandler('debugchangerole', debugchangerole)) updater.dispatcher.add_handler(CommandHandler('debugchangerole', debugchangerole))
updater.dispatcher.add_handler(CallbackQueryHandler(selectpreset)) updater.dispatcher.add_handler(CallbackQueryHandler(inlinekeyboard))
updater.dispatcher.add_error_handler(handleerror) updater.dispatcher.add_error_handler(handleerror)
updater.start_polling() updater.start_polling()
print("Bot avviato!") print("Bot avviato!")

View file

@ -221,6 +221,9 @@ mifia_team_player = "{icon} {name}\n"
# Generale: votazione completata # Generale: votazione completata
vote = "@{voting} ha votato per uccidere @{voted}." vote = "@{voting} ha votato per uccidere @{voted}."
# Generale: votazione completata in prima persona
vote_fp = "Hai votato per uccidere @{voted}."
# Generale: un admin ha ucciso un giocatore con /kill # Generale: un admin ha ucciso un giocatore con /kill
admin_killed = "{name} è morto _di infarto_.\n" \ admin_killed = "{name} è morto _di infarto_.\n" \
"Era un *{icon} {role}*." "Era un *{icon} {role}*."
@ -251,6 +254,12 @@ end_game_wiped = "Nessuno è più vivo. La specie umana si è estinta.\n"
# Vittoria: Sei un Signore del Caos. # Vittoria: Sei un Signore del Caos.
end_game_chaos = "Sei un Signore del Caos." end_game_chaos = "Sei un Signore del Caos."
# Generale: scegli per chi votare
vote_keyboard = "Chi vuoi votare...?"
# Generale: riga della tastiera del voto
vote_keyboard_line = "@{name}"
# Vittoria: team Royal # Vittoria: team Royal
victory_royal = "**La Royal Games vince!**" victory_royal = "**La Royal Games vince!**"