🔀 Merge pull request #75 from Flowiee/patch-1

Added a new mode
This commit is contained in:
Jannes Höke 2019-11-07 12:48:15 +01:00 committed by GitHub
commit c6c17ff7e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 7 deletions

3
bot.py
View file

@ -36,7 +36,7 @@ from errors import (NoGameInChatError, LobbyClosedError, AlreadyJoinedError,
from internationalization import _, __, user_locale, game_locales from internationalization import _, __, user_locale, game_locales
from results import (add_call_bluff, add_choose_color, add_draw, add_gameinfo, from results import (add_call_bluff, add_choose_color, add_draw, add_gameinfo,
add_no_game, add_not_started, add_other_cards, add_pass, add_no_game, add_not_started, add_other_cards, add_pass,
add_card, add_mode_classic, add_mode_fast, add_mode_wild) add_card, add_mode_classic, add_mode_fast, add_mode_wild, add_mode_text)
from shared_vars import gm, updater, dispatcher from shared_vars import gm, updater, dispatcher
from simple_commands import help_handler from simple_commands import help_handler
from start_bot import start_bot from start_bot import start_bot
@ -595,6 +595,7 @@ def reply_to_query(bot, update):
add_mode_classic(results) add_mode_classic(results)
add_mode_fast(results) add_mode_fast(results)
add_mode_wild(results) add_mode_wild(results)
add_mode_text(results)
else: else:
add_not_started(results) add_not_started(results)

View file

@ -130,6 +130,18 @@ def add_mode_wild(results):
) )
def add_mode_text(results):
"""Change mode to text"""
results.append(
InlineQueryResultArticle(
"mode_text",
title=_("✍️ Text mode"),
input_message_content=
InputTextMessageContent(_('Text ✍️'))
)
)
def add_draw(player, results): def add_draw(player, results):
"""Add option to draw""" """Add option to draw"""
n = player.game.draw_counter or 1 n = player.game.draw_counter or 1
@ -187,9 +199,14 @@ def add_card(game, card, results, can_play):
"""Add an option that represents a card""" """Add an option that represents a card"""
if can_play: if can_play:
if game.mode != "text":
results.append( results.append(
Sticker(str(card), sticker_file_id=c.STICKERS[str(card)]) Sticker(str(card), sticker_file_id=c.STICKERS[str(card)])
) )
if game.mode == "text":
results.append(
Sticker(str(card), sticker_file_id=c.STICKERS[str(card)], input_message_content=InputTextMessageContent("Card Played: {card}".format(card=repr(card).replace('Draw Four', '+4').replace('Draw', '+2').replace('Colorchooser', 'Color Chooser')))
))
else: else:
results.append( results.append(
Sticker(str(uuid4()), sticker_file_id=c.STICKERS_GREY[str(card)], Sticker(str(uuid4()), sticker_file_id=c.STICKERS_GREY[str(card)],

View file

@ -70,10 +70,11 @@ def help_handler(bot, update):
@user_locale @user_locale
def modes(bot, update): def modes(bot, update):
"""Handler for the /help command""" """Handler for the /help command"""
modes_explanation = _("This UNO bot has three game modes: Classic, Sanic and Wild.\n\n" modes_explanation = _("This UNO bot has four game modes: Classic, Sanic, Wild and Text.\n\n"
" 🎻 The Classic mode uses the conventional UNO deck and there is no auto skip.\n" " 🎻 The Classic mode uses the conventional UNO deck and there is no auto skip.\n"
" 🚀 The Sanic mode uses the conventional UNO deck and the bot automatically skips a player if he/she takes too long to play its turn\n" " 🚀 The Sanic mode uses the conventional UNO deck and the bot automatically skips a player if he/she takes too long to play its turn\n"
" 🐉 The Wild mode uses a deck with more special cards, less number variety and no auto skip.\n\n" " 🐉 The Wild mode uses a deck with more special cards, less number variety and no auto skip.\n"
" ✍️ The Text mode uses the conventional UNO deck but instead of stickers it uses the text.\n\n"
"To change the game mode, the GAME CREATOR has to type the bot nickname and a space, " "To change the game mode, the GAME CREATOR has to type the bot nickname and a space, "
"just like when playing a card, and all gamemode options should appear.") "just like when playing a card, and all gamemode options should appear.")
send_async(bot, update.message.chat_id, text=modes_explanation, send_async(bot, update.message.chat_id, text=modes_explanation,