diff --git a/actions.py b/actions.py index 5a78582..cc98dd7 100644 --- a/actions.py +++ b/actions.py @@ -155,11 +155,15 @@ def do_call_bluff(bot, player): chat = game.chat if player.prev.bluffing: + draw_prev = 4 + draw_next = game.draw_counter - draw_prev + draw_next_text = ". " + __("Giving {count} cards to {name}").format(count=draw_next, name=player.user.first_name) if draw_next > 0 else "" send_async(bot, chat.id, - text=__("Bluff called! Giving 4 cards to {name}", + text=__("Bluff called! Giving {count} cards to {name}" + draw_next_text, multi=game.translate) - .format(name=player.prev.user.first_name)) + .format(name=player.prev.user.first_name, count=draw_prev)) + game.draw_counter = draw_prev try: player.prev.draw() except DeckEmptyError: @@ -167,12 +171,21 @@ def do_call_bluff(bot, player): text=__("There are no more cards in the deck.", multi=game.translate)) + game.draw_counter = draw_next + try: + player.draw() + except DeckEmptyError: + send_async(bot, player.game.chat.id, + text=__("There are no more cards in the deck.", + multi=game.translate)) + else: game.draw_counter += 2 send_async(bot, chat.id, - text=__("{name1} didn't bluff! Giving 6 cards to {name2}", + text=__("{name1} didn't bluff! Giving {count} cards to {name2}", multi=game.translate) .format(name1=player.prev.user.first_name, + count=game.draw_counter, name2=player.user.first_name)) try: player.draw() diff --git a/bot.py b/bot.py index 89a3272..b60bc28 100644 --- a/bot.py +++ b/bot.py @@ -701,6 +701,14 @@ def process_result(update: Update, context: CallbackContext): game.choose_color(result_id) else: reset_waiting_time(context.bot, player) + if game.mode == "text": + sticker_id = c.STICKERS.get(result_id) + if sticker_id: + context.bot.sendSticker(chat.id, + sticker=sticker_id, + timeout=TIMEOUT) + else: + logger.warning(f"no sticker found for {result_id=}") do_play_card(context.bot, player, result_id) if game_is_running(game): diff --git a/player.py b/player.py index cc1858e..93eae03 100644 --- a/player.py +++ b/player.py @@ -149,7 +149,7 @@ class Player(object): self.logger.debug("Matching!") playable.append(card) - self.bluffing = (self.bluffing or card.color == last.color) + self.bluffing = (self.bluffing or (not card.special and (card.color == last.color or card.value == last.value))) # You may not play a chooser or +4 as your last card if len(self.cards) == 1 and self.cards[0].special: @@ -168,6 +168,8 @@ class Player(object): not card.special): self.logger.debug("Card's color or value doesn't match") is_playable = False + elif (last.value == c.DRAW_TWO or last.special == c.DRAW_FOUR) and card.special == c.DRAW_FOUR: + self.logger.debug("Allow draw_four over draw_two or draw_four") elif last.value == c.DRAW_TWO and not \ card.value == c.DRAW_TWO and self.game.draw_counter: self.logger.debug("Player has to draw and can't counter")