This commit is contained in:
Flowiee 2019-10-18 13:47:58 +00:00 committed by GitHub
commit 5896d99cb2
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 results import (add_call_bluff, add_choose_color, add_draw, add_gameinfo,
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 simple_commands import help_handler
from start_bot import start_bot
@ -595,6 +595,7 @@ def reply_to_query(bot, update):
add_mode_classic(results)
add_mode_fast(results)
add_mode_wild(results)
add_mode_text(results)
else:
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):
"""Add option to draw"""
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"""
if can_play:
results.append(
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)])
)
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:
results.append(
Sticker(str(uuid4()), sticker_file_id=c.STICKERS_GREY[str(card)],
@ -209,4 +226,4 @@ def game_info(game):
"Players: {player_list}",
len(players))
.format(player_list=" -> ".join(players))
)
)

View file

@ -70,10 +70,11 @@ def help_handler(bot, update):
@user_locale
def modes(bot, update):
"""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 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, "
"just like when playing a card, and all gamemode options should appear.")
send_async(bot, update.message.chat_id, text=modes_explanation,

View file

@ -75,7 +75,7 @@ def display_color_group(color, game):
if color == "y":
return __("{emoji} Yellow", game.translate).format(
emoji='💛')
def error(bot, update, error):
"""Simple error handler"""