예제 #1
0
def start(parse):
    config = functions.get_config(db)

    round = Round(db, config)
    round.next()

    functions.set_interval(round.next, 10)
예제 #2
0
    def star_rounds(self):

        while not self.check_for_game_winner():
            self.__clear_for_new_round()
            new_round = Round(self.take_round_type(), self.current_round)
            new_round.add_round_members(self.teams)
            self.rounds.append(new_round)

            self.current_round += 1
예제 #3
0
def start_game():
    """ Starts the game """
    game_on = True
    player = player_setup()

    while game_on:
        if player.bankroll.balance == 0:
            new_deposit = input(
                'You are out of money. Wanna make a new deposit? (YES/no): ')
            if new_deposit.upper() == 'NO':
                break

            player.bankroll.make_deposit()
            clear()

        player_bet = player.bankroll.make_bet()

        game_round = Round(player_bet * 2, player)
        game_round.player_round()
        end_game = game_round.check_bust_blackjack()
        if not end_game:
            game_round.computer_round()
            game_round.showdown()

        game_on = input('Wanna play again? (YES/no): ').upper() != 'NO'
        clear()
예제 #4
0
    def test_game_jsonable(self):
        player1 = Player("Marto")
        player2 = Player("Pesho")
        player3 = Player("Nasko")
        player4 = Player("Petko")

        team1 = Team("Wolf")
        team2 = Team("Lion")
        team1.add_team_members([player1, player2])
        team2.add_team_members([player3, player4])

        round1 = Round("All trumps", 1)
        round1.add_round_members([team1, team2])

        game = Game([team1, team2], 1)
        game.rounds.append(round1)

        self.assertEqual(
            game.to_json(),
            json.dumps(
                {
                    "game 1": [{
                        "round 1": [{
                            "Wolf": [{
                                "Marto": {
                                    "points": 0,
                                    "announcements": [],
                                    "cards": []
                                }
                            }, {
                                "Pesho": {
                                    "points": 0,
                                    "announcements": [],
                                    "cards": []
                                }
                            }]
                        }, {
                            "Lion": [{
                                "Nasko": {
                                    "points": 0,
                                    "announcements": [],
                                    "cards": []
                                }
                            }, {
                                "Petko": {
                                    "points": 0,
                                    "announcements": [],
                                    "cards": []
                                }
                            }]
                        }]
                    }]
                },
                cls=OurEncoder))
예제 #5
0
def start(parse):
    if parse.slave:
        from classes.zond import Zond

        zond = Zond(db)

        zond.run()

    else:
        from classes.round import Round

        round = Round(db)
        round.next()

        functions.set_interval(round.next, CHECKER['ROUND_LENGTH'])
예제 #6
0
def start(parse):
    if parse.slave:
        from classes.zond import Zond

        zond = Zond(db)

        zond.run()

    else:
        from classes.round import Round

        round = Round(db)
        round.next()

        functions.set_interval(round.next, ROUND_LENGTH)
예제 #7
0
파일: game.py 프로젝트: mikebg95/BlackJack
    def __init__(self, gui):

        self.rounds = []

        # create deck
        deck = Deck()

        # popup window to ask for name, create player objects
        name = simpledialog.askstring(title="Name", prompt="What's your name?")
        while not name:
            name = simpledialog.askstring(title="Name", prompt="Please insert a name")
        players = []
        user = Player(name)
        dealer = Player("Dealer")
        players.append(user)
        players.append(dealer)

        # show player info
        gui.name_label["text"] = "Name: " + user.name
        gui.chips_label["text"] = "Total chips: " + str(user.chips)

        # start new round as long as user has enough chips
        while user.chips >= 1:
            user.cards.clear()
            dealer.cards.clear()

            current_round = Round(user, dealer, deck, gui)

            self.rounds.append(current_round)

            new_round = messagebox.askquestion("New game?")
            if new_round == "no":
                gui.root.destroy()

            # empty options
            for widget in gui.player_options_frame.winfo_children():
                widget.destroy()

            # empty user cards
            user.cards.clear()
            dealer.cards.clear()
        messagebox.showinfo("GAME OVER", "OUT OF CHIPS!")