コード例 #1
0
ファイル: gui.py プロジェクト: neilleiser97/UNO-Game
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()
コード例 #2
0
def init():
    anna = ComputerPlayer("Anna Truffet")

    players = [
        anna,
        HumanPlayer("Henry O'Brien"),
        ComputerPlayer("Josh Arnold")
    ]

    deck = Deck(
        [Card(1, "red"),
         Card(2, "blue"),
         Card(3, "red"),
         Card(4, "green")])

    game = UnoGame(deck, players)

    return anna, players, deck, game
コード例 #3
0
from a2 import Card, Player, Pickup2Card, Pickup4Card, HumanPlayer, ComputerPlayer, Deck, ReverseCard, SkipCard
import a2_support

# Set Up Uno Game
anna = ComputerPlayer("Anna Truffet")
players = [anna, HumanPlayer("Henry O'Brien"), ComputerPlayer("Josh Arnold")]

deck = Deck(
    [Card(1, "red"),
     Card(2, "blue"),
     Card(3, "red"),
     Card(4, "green")])

game = a2_support.UnoGame(deck, players)


def test_reverse_card():
    print("reverse", '*' * 10)
    card = ReverseCard(0, "red")
    print(game.current_player().get_name())
    # 'Anna Truffet'
    print(game.next_player().get_name())
    # "Henry O'Brien"
    print(game.next_player().get_name())
    # 'Josh Arnold'
    print(game.next_player().get_name())
    # 'Anna Truffet'
    print("Reverse", '-' * 10)
    card.play(anna, game)
    print(game.next_player().get_name())
    # 'Josh Arnold'
コード例 #4
0
print('-' * 5)
new_card = SkipCard(0, "green")
deck.add_card(new_card)
from os import system
system('pause')
deck.add_cards([card, special_card, blue_card])
print(deck.get_cards())
print(deck.get_amount())
print(deck.pick())
print(deck.get_amount())
print(deck.pick(amount=2))
deck.shuffle()
print(deck.get_cards())

print("*" * 40)

#Player
player = Player("Peter O'Shea")

print(player.get_name())
print(player.get_deck())
print(player.get_deck().get_cards())
# player.is_playable()
print(player.has_won())
player.get_deck().add_card(Card(32, "red"))
print(player.has_won())
print("-" * 5)
human = HumanPlayer("Peter Sutton")
print(human.is_playable())
print(human.pick_card(deck))
コード例 #5
0
from a2 import Deck
import a2_support

card = Card(42, "red")

special_card = Pickup2Card(0, "red")

blue_card = ReverseCard(0, "blue")

cards = [card, special_card, blue_card]

new_card = SkipCard(0, "green")

deck = Deck(cards)
anna = ComputerPlayer("Anna")
players = [anna, HumanPlayer("Henry"), ComputerPlayer("john")]

game = a2_support.UnoGame(deck, players)

for i in game.players:
    print(i.get_name())
    print(i.get_deck().get_cards())

special_card.play(anna, game)

for i in game.players:
    print(i)
    print(i.get_name())
    print(i.get_deck().get_cards())
    print(id(i.get_deck().get_cards()))