Merge branch 'dev' into main

This commit is contained in:
Alberto 2020-12-13 21:40:28 +01:00
commit da997cc8ab
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2

View File

@ -34,6 +34,8 @@ class Deck:
def pick_and_scrap(self) -> cs.Card: def pick_and_scrap(self) -> cs.Card:
card = self.cards.pop(0) card = self.cards.pop(0)
self.scrap_pile.append(card) self.scrap_pile.append(card)
if len(self.cards) == 0:
self.reshuffle()
self.game.notify_scrap_pile() self.game.notify_scrap_pile()
return card return card
@ -43,11 +45,14 @@ class Deck:
def draw(self) -> cs.Card: def draw(self) -> cs.Card:
card = self.cards.pop(0) card = self.cards.pop(0)
if len(self.cards) == 0: if len(self.cards) == 0:
self.cards = self.scrap_pile[:-1].copy() self.reshuffle()
random.shuffle(self.cards)
self.scrap_pile = self.scrap_pile[-1:]
return card return card
def reshuffle(self):
self.cards = self.scrap_pile[:-1].copy()
random.shuffle(self.cards)
self.scrap_pile = self.scrap_pile[-1:]
def draw_from_scrap_pile(self) -> cs.Card: def draw_from_scrap_pile(self) -> cs.Card:
if len(self.scrap_pile) > 0: if len(self.scrap_pile) > 0:
card = self.scrap_pile.pop(-1) card = self.scrap_pile.pop(-1)