top class init
This commit is contained in:
@@ -89,8 +89,39 @@ cards = [Card(color, value) for value in Card_values for color in Card_colors]
|
||||
# hraci[vyherca].pridaj_ziskanu_kopku()
|
||||
|
||||
class Bridzik():
|
||||
# self.series = []
|
||||
pass
|
||||
def __init__(self):
|
||||
self.series = [Series(0, 0)]
|
||||
|
||||
def play_card(self, player: int, card: Card):
|
||||
if self.is_completed():
|
||||
raise BridzikException('Hra je ukoncena.')
|
||||
self.series[-1].play_card(player, card)
|
||||
if self.series[-1].is_completed() and not self.is_completed():
|
||||
self.series.append(Series(len(self.series)))
|
||||
|
||||
def add_player_guess(self, player: int, guess):
|
||||
if self.is_completed():
|
||||
raise BridzikException('Hra je ukoncena.')
|
||||
self.series[-1].add_player_guess(player, guess)
|
||||
|
||||
def get_status(self, player: int):
|
||||
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
|
||||
status['active_stash'] = {
|
||||
'first_player': last_series.get_last_round().get_last_stash().first_player,
|
||||
'cards': last_series.get_last_round().get_last_stash().get_cards()
|
||||
}
|
||||
status['standings'] = [s.get_standings() for s in self.series]
|
||||
return status
|
||||
|
||||
def is_completed(self):
|
||||
return len(self.series) == 4 and self.series[-1].is_completed()
|
||||
|
||||
class Series():
|
||||
def __init__(self, series_number: int, first_player: int = None):
|
||||
|
||||
Reference in New Issue
Block a user