From 73365f49fcf55a4c2676b60551bed38fcd7c8ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Sat, 21 May 2016 18:55:53 +0200 Subject: [PATCH] draw method reset draw counter on empty deck --- player.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/player.py b/player.py index 904ce76..45954f1 100644 --- a/player.py +++ b/player.py @@ -112,11 +112,16 @@ class Player(object): """Draws 1+ cards from the deck, depending on the draw counter""" _amount = self.game.draw_counter or 1 - for i in range(_amount): - self.cards.append(self.game.deck.draw()) + try: + for i in range(_amount): + self.cards.append(self.game.deck.draw()) - self.game.draw_counter = 0 - self.drew = True + except DeckEmptyError: + raise + + finally: + self.game.draw_counter = 0 + self.drew = True def play(self, card): """Plays a card and removes it from hand"""