''' DS2000 Fall 2024 Driver for card game (afternoon section) (Goal to beat morning section in creativity, fun-ness, etc.) You win by having more cards, like Reverse Uno Felix vs. Laney Rules of the game: - each player gets three cards - player 1 asks player 2 for a card by value - if player 2 has such a card, they hand it over to player 1 - if they don't, player 2 draws acard from the deck - repeat the process with players reversed - whoever has the most cards wins! (unless it's Felix, they must've cheated) ''' from deck import Deck NUM_CARDS = 3 def main(): # start by making a deck and shuffling it game_deck = Deck() game_deck.shuffle() # Did we make and shuffle the deck correctly? Just a sanity check for card in game_deck.cards: print(card) # Now, start the game! Deal cards to each player laney_cards = [] felix_cards = [] for i in range(NUM_CARDS): laney_cards.append(game_deck.deal()) felix_cards.append(game_deck.deal()) # Print out what each player has so far... print("Laney has...") for i in range(3): print(laney_cards[i]) print("\nFelix has...") for i in range(3): print(felix_cards[i]) # Prompt first player for a value, and if second player # has this card, move from p2's hand to p1 # otherwise, p2 gets to draw from the deck guess_val = int(input("\nLaney, what card do you think Felix has?\n")) found = -1 for i in range(len(felix_cards)): if felix_cards[i].val == guess_val: found = i if found > -1: laney_cards.append(felix_cards.pop(found)) else: felix_cards.append(game_deck.deal()) guess_val = int(input("\nFelix, what card do you think Laney has?\n")) found = -1 for i in range(len(laney_cards)): if laney_cards[i].val == guess_val: found = i if found > -1: felix_cards.append(laney_cards.pop(i)) else: laney_cards.append(game_deck.deal()) # Print out the winner, whoever has more cards if len(laney_cards) > len(felix_cards): print("Laney wins with", len(laney_cards), "cards!") elif len(laney_cards) < len(felix_cards): print("Felix wins by cheating :(") else: print("Tie!!!") main()