0% found this document useful (0 votes)
17 views3 pages

لعبة الباصرة

Uploaded by

wahibbayrq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

لعبة الباصرة

Uploaded by

wahibbayrq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

import random

[ = deck

As','( ,)King', 13'( ,)Queen', 12'( ,)Jack', 11'( ,)ten', 10'( ,)nine', 9'( ,)eight', 8'( ,)seven', 7'(
,)1

As','( ,)King', 13'( ,)Queen', 12'( ,)Jack', 11'( ,)ten', 10'( ,)nine', 9'( ,)eight', 8'( ,)seven', 7'(
,)1

As','( ,)King', 13'( ,)Queen', 12'( ,)Jack', 11'( ,)ten', 10'( ,)nine', 9'( ,)eight', 8'( ,)seven', 7'(
,)1

As','( ,)King', 13'( ,)Queen', 12'( ,)Jack', 11'( ,)ten', 10'( ,)nine', 9'( ,)eight', 8'( ,)seven', 7'(
)1

random.shuffle(deck)

player_hand = deck[:4]

computer_hand = deck[4:8]

table_cards = deck[8:12]

deck = deck[12:]

:def print_hand(hand, player_name="player")

print(f"Cards {player_name}:")

:for i, card in enumerate(hand)

print(f"{i + 1}: {card[0]} ({card[1]})")

:def check_bassra(card, table_cards)

:for t_cards in table_cards

:if t_cards[1] == card[1]

return True
return False

:def play_round(player_hand, computer_hand, table_cards)

print_hand(player_hand)

player_choice = int(input("Choose the card you want to play (1-4): ")) - 1

:if player_choice < 0 or player_choice >= len(player_hand)

print("Invalid choice! Please choose again.")

return play_round(player_hand, computer_hand, table_cards)

player_card = player_hand.pop(player_choice)

:if check_bassra(player_card, table_cards)

print("Basra!")

)(table_cards.clear

:else

table_cards.append(player_card)

print(f"The cards on the table: {[card[0] for card in table_cards]}")

:if computer_hand

computer_card = computer_hand.pop(0)

print(f"Computer plays: {computer_card[0]} ({computer_card[1]})")

:if check_bassra(computer_card, table_cards)

print("The Computer takes the basra!")

)(table_cards.clear
:else

table_cards.append(computer_card)

print(f"The cards on the table: {[card[0] for card in table_cards]}")

:while player_hand and computer_hand

play_round(player_hand, computer_hand, table_cards)

:if len(player_hand) > len(computer_hand)

print("The player wins!")

:elif len(player_hand) < len(computer_hand)

print("The Computer wins!")

:else

print("It's a tie!")

print("The game ended")

You might also like