From fb6da7cfa7e2405649558751a400df5999514a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Tue, 1 Mar 2016 01:38:23 +0100 Subject: [PATCH] hopefully all rules are now implemented --- bot.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/bot.py b/bot.py index 5b92b6f..e4dcb32 100644 --- a/bot.py +++ b/bot.py @@ -68,15 +68,7 @@ def reply_to_query(bot, update): playable = list() if game.choosing_color: - for color in c.COLORS: - results.append( - InlineQueryResultArticle( - id=color, - title="Choose Color", - message_text=color, - description=color.upper() - ) - ) + choose_color(results) else: playable = list(sorted(player.playable_cards())) @@ -85,8 +77,9 @@ def reply_to_query(bot, update): elif playable: for card in playable: play_card(card, results) - elif not game.choosing_color: - draw(player, results) + + if playable is not False and not game.choosing_color and not player.drew: + draw(player, results, could_play_card=bool(len(playable))) if player.drew: pass_(results) @@ -99,6 +92,18 @@ def reply_to_query(bot, update): bot.answerInlineQuery(update.inline_query.id, results, cache_time=0) +def choose_color(results): + for color in c.COLORS: + results.append( + InlineQueryResultArticle( + id=color, + title="Choose Color", + message_text=color, + description=color.upper() + ) + ) + + def other_cards(playable, player, results): results.append( InlineQueryResultArticle( @@ -111,11 +116,12 @@ def other_cards(playable, player, results): ) -def draw(player, results): +def draw(player, results, could_play_card): results.append( InlineQueryResultArticle( "draw", - title="No suitable cards...", + title=("No suitable cards..." if not could_play_card else + "I don't want to play a card..."), description="Draw!", message_text='Drawing %d card(s)' % (player.game.draw_counter or 1)