Add Bridzik.get_player_cards and make get_status player-agnostic
Engine support for the per-connection Socket.IO API: hands are fetched explicitly via get_player_cards(player) and the shared status no longer embeds a single player's cards.
This commit is contained in:
+6
-3
@@ -99,13 +99,16 @@ class Bridzik():
|
||||
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'] = {
|
||||
@@ -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.')
|
||||
|
||||
Reference in New Issue
Block a user