def check_winner(self): if self.dealer.full_points > 21: # all win print('Dealer are fall! All players in game are win!') for winner in self.players: winner.money += winner.bet * 2 else: for player in self.players: if player.full_points == self.dealer.full_points: player.money += player.bet print( MESSAGES.get('eq').format(player=player, points=player.full_points)) elif player.full_points > self.dealer.full_points: player.money += player.bet * 2 if isinstance(player, Player.Bot): print(MESSAGES.get('win').format(player)) elif isinstance(player, Player.Player): print('You are win!') elif player.full_points < self.dealer.full_points: if isinstance(player, Player.Bot): print(MESSAGES.get('lose').format(player)) elif isinstance(player, Player.Player): print('You are lose!')
def start_game(self): message = MESSAGES.get('ask_start') # todo: max players count? if not self._ask_starting(message=message): exit(1) # generating data for starting self._launching() while True: # ask about bet self.ask_bet() # give first cards to the players self.first_descr() # print player cards after first deal self.player.print_cards() # ask players about cards self.ask_cards() self.play_with_dealer() self.check_winner() if not self._ask_starting(MESSAGES.get('rerun')): break
def start_game(self): message = MESSAGES.get('ask_start') if not self._ask_starting(message=message): exit(1) # return 0 #подготовка данных для начала self._launching() #спросить ставку self.ask_bet() #выдача первых карт для игроков self.first_descr() #печать карт игрока после раздачи self.player.print_cards() #спросить игрока, нужны ли карты self.ask_cards() self.play_with_dealer() self.check_winner()
def ask_card(self): if self.full_points == 21: return False choice = input(MESSAGES.get('ask_card')) if choice == 'д': return True else: return False
def check_winner(self): #все игроки выиграли if self.dealer.full_points > 21: print('Дилер проиграл! Все игроки выиграли!') for winner in self.players: winner.money += winner.bet * 2 else: for player in self.players: if player.full_points == self.dealer.full_points: player.money += player.bet print(MESSAGES.get('eq').format(player=player, points=player.full_points)) elif player.full_points > self.dealer.full_points: player.money += player.bet * 2 if isinstance(player, Player.Bot): print(MESSAGES.get('win').format(player)) elif isinstance(player, Player.Player): print('Поздравляем, вы победили!') elif player.full_points < self.dealer.full_points: if isinstance(player, Player.Bot): print(MESSAGES.get('lose').format(player)) elif isinstance(player, Player.Player): print('Вы проиграли!')
def ask_card(self): choice = input(MESSAGES.get('ask_card')) if choice == 'y': return True else: return False