Exemplo n.º 1
0
def main():
    # create window for uno
    root = tk.Tk()
    root.title("Uno++")

    # build a list of players for the game
    players = [
        HumanPlayer("Ravi"),
        HumanPlayer(generate_name()),
        ComputerPlayer(generate_name())
    ]

    # build a pickup pile
    pickup_pile = Deck(build_deck(FULL_DECK))
    pickup_pile.shuffle()

    # deal players cards from the pickup pile
    for player in players:
        cards = pickup_pile.pick(7)
        player.get_deck().add_cards(cards)

    # create and play the game
    game = UnoGame(pickup_pile, players)
    app = UnoApp(root, game)
    app.play()

    # update window dimensions
    root.update()
    root.minsize(root.winfo_width(), root.winfo_height())
    root.mainloop()
Exemplo n.º 2
0
def main():
    # create window for coders
    root = tk.Tk()
    root.title("Sleeping Coders")

    # build a list of players for the game
    players = [Player(generate_name()), Player(generate_name())]

    # build a pickup pile
    pickup_pile = Deck(build_deck(FULL_DECK))
    for i in range(5):
        pickup_pile.copy(pickup_pile)
    pickup_pile.shuffle()

    # deal players cards from the pickup pile
    for player in players:
        cards = pickup_pile.pick(5)
        player.get_hand().add_cards(cards)

    # build a list of sleeping coder cards
    coders = CODERS[:]

    # create and play the game
    game = CodersGame(pickup_pile, coders, players)
    app = CoderApp(root, game)
    app.play()

    # update window dimensions
    root.update()
    root.minsize(root.winfo_width(), root.winfo_height())
    root.mainloop()
Exemplo n.º 3
0
    def new_game(self):
        """Start a new game"""
        # clone the old players
        players = []
        for player in self.game.players:
            players.append(player.__class__(player.get_name()))

        # generate a new deck
        pickup_pile = Deck(build_deck(FULL_DECK))
        pickup_pile.shuffle()

        # make players pickup cards
        for player in players:
            cards = pickup_pile.pick(7)
            player.get_deck().add_cards(cards)

        self.game = UnoGame(pickup_pile, players)
        self.render_decks()
        self.update()