diff --git a/bridzik.py b/bridzik.py index e629c19..cde1af3 100644 --- a/bridzik.py +++ b/bridzik.py @@ -83,7 +83,7 @@ cards = [Card(color, value) for value in Card_values for color in Card_colors] class Bridzik(): - def __init__(self, shuffler = shuffle): + def __init__(self, shuffler=shuffle): self.shuffler = shuffler self.series = [Series(0, 0, shuffler=self.shuffler)] @@ -98,14 +98,17 @@ class Bridzik(): if self.is_completed(): raise BridzikException('Hra je ukoncena.') self.series[-1].add_player_guess(player, guess) - - def get_status(self, player: int): + + def get_player_cards(self, player: int): + player_cards = self.series[-1].get_last_round().player_cards[player] + return {k: v for k, v in enumerate(player_cards)} + + def get_status(self): status = {} last_series = self.series[-1] if not self.is_completed(): status['active_player'] = last_series.get_last_round().get_active_player() status['active_round_guesses'] = last_series.get_last_round().guesses - status['player_cards'] = last_series.get_last_round().player_cards[player] if last_series.get_last_round().is_guessing_completed(): status['active_round_stashes'] = last_series.get_last_round().get_stashes_winner_summary() status['active_stash'] = { @@ -186,7 +189,7 @@ class Series(): class Round(): - def __init__(self, round_number: int, first_player: int, cards: []=cards, shuffler = shuffle): + def __init__(self, round_number: int, first_player: int, cards: []=cards, shuffler=shuffle): # vyrob kopku pre toto kolo a priprav prazdne objekty if round_number not in [i for i in range(8)]: raise BridzikException('Neplatne cislo kola.') @@ -285,7 +288,7 @@ class Round(): def get_last_stash(self): return self.stashes[-1] if self.stashes else None - def deal_starting_cards(self, cards: [], shuffler = shuffle): + def deal_starting_cards(self, cards: [], shuffler=shuffle): self.round_cards = cards.copy() shuffler(self.round_cards) self.round_cards = self.round_cards[(4*self.round_number):] @@ -308,7 +311,7 @@ class Round(): self.stashes.append(Stash(self.get_last_stash().get_winner())) -class Stash(): +class Stash: def __init__(self, first_player: int): if first_player not in [0, 1, 2, 3]: raise BridzikException('Cislo hraca musi byt 0, 1, 2 alebo 3.')