import random
import rich

game = {"draw_pile": [],
        "hand0": [],
        "hand1": [],
        "hand2": [],
        "hand3": [],
        "name0": "You",
        "name1": "Jakayla",
        "name2": "Habiba",
        "name3": "Abby",
        "current_player": 0,
        "direction": "clockwise",
        "wild_color": None}

# a color is either
# "red", "blue", "green", or "yellow"

# a card will be either
# - a pair like ("green", 8)
# - "wild", or
# - "draw4"

# Let's build a deck of numbered cards.

def new_deck():
    deck = []
    for color in ["red","green","blue","yellow"]:
        for i in range(10):
            if i==0:
                deck.append((color,i))
            else:
                deck.append((color, i))
                deck.append((color, i))
    return deck

def print_card(card):
    (color, rank) = card
    rich.print("["+color+"]["+str(rank)+"][/]",end="")

def deal():
    for i in range(7):
        game["hand0"].append(game["draw_pile"].pop())
    for i in range(7):
        game["hand1"].append(game["draw_pile"].pop())
    for i in range(7):
        game["hand2"].append(game["draw_pile"].pop())
    for i in range(7):
        game["hand3"].append(game["draw_pile"].pop())

deck = new_deck()
random.shuffle(deck)
#for card in deck:
#    print_card(card)
game["draw_pile"] = deck

deal()

def show_table():
    print(game["name0"])
    for card in game["hand0"]:
        print_card(card)
    print()
    print(game["name1"])
    for card in game["hand1"]:
        print_card(card)
    print()
    print(game["name2"])
    for card in game["hand2"]:
        print_card(card)
    print()
    print(game["name3"])
    for card in game["hand3"]:
        print_card(card)
    print()
    print("top card")
    print_card(game["draw_pile"][0])
    print()
    print("current player", game["current_player"])
    print("direction", game["direction"])
    print("wild color", game["wild_color"])

show_table()

