The code below starts the bidding process. It's possible now to add graphics, that might be next as well as continuing with picking up.
Can be tested at https://www.onlinegdb.com/online_python_compiler
#This is to evaluate dealt cards for all four players.
import random
player_num = random.randint(0,3) #Assigns players a number.
suits = ["clubs", "spades", "diamonds", "hearts"]
trump_order = []
cnums_dealt = []
cards = ["9♣", "10♣", "J♣", "Q♣", "K♣", "A♣", "9♠", "10♠", "J♠", "Q♠", "K♠", "A♠", "9♦", "10♦", "J♦", "Q♦", "K♦", "A♦", "9♥", "10♥", "J♥", "Q♥", "K♥", "A♥"]
cards2 = ["9♣", "10♣", "J♣", "Q♣", "K♣", "A♣", "9♠", "10♠", "J♠", "Q♠", "K♠", "A♠", "9♦", "10♦", "J♦", "Q♦", "K♦", "A♦", "9♥", "10♥", "J♥", "Q♥", "K♥", "A♥"]
cnums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
cnumscopy = cnums.copy() #This is for second round bidding.
cnums_value = []
cardsnum_dealt = 23
#Generating cards dealt out
for x in range (21):
cards_dealt = (random.randint(0,cardsnum_dealt))
if len (cnums) == 4:
cnums_number = cnums[cards_dealt]
trump_order.append(cards[cards_dealt])
cnums_dealt.append(cnums[cards_dealt])
cardsnum_dealt = cardsnum_dealt - 1
cards.pop(cards_dealt)
cnums.pop(cards_dealt)
#print ("trump order ", trump_order)
#print ("cnums_dealt ", cnums_dealt)
print ("\nThe card the dealer turned over was", trump_order[20])
#Assigning values to each card
if cnums_dealt[20] < 6:
cnums_dealtcopy = cnums_dealt.copy()
#print("cnums_dealtcopy:", cnums_dealtcopy)
#print("Trump could be clubs.")
for value in range (13):
for card_num in range (21):
if cnums_dealt[card_num] == 6 or cnums_dealt[card_num] == 12 or cnums_dealt[card_num] == 18:
cnums_dealtcopy[card_num] = 1
if cnums_dealt[card_num] == 7 or cnums_dealt[card_num] == 13 or cnums_dealt[card_num] == 19:
cnums_dealtcopy[card_num] = 2
if cnums_dealt[card_num] == 14 or cnums_dealt[card_num] == 20:
cnums_dealtcopy[card_num] = 3
if cnums_dealt[card_num] == 9 or cnums_dealt[card_num] == 15 or cnums_dealt[card_num] == 21:
cnums_dealtcopy[card_num] = 4
if cnums_dealt[card_num] == 10 or cnums_dealt[card_num] == 16 or cnums_dealt[card_num] == 22:
cnums_dealtcopy[card_num] = 5
if cnums_dealt[card_num] == 11 or cnums_dealt[card_num] == 17 or cnums_dealt[card_num] == 23:
cnums_dealtcopy[card_num] = 6
if cnums_dealt[card_num] == 0:
cnums_dealtcopy[card_num] = 7
if cnums_dealt[card_num] == 1:
cnums_dealtcopy[card_num] = 8
if cnums_dealt[card_num] == 2:
cnums_dealtcopy[card_num] = 13
if cnums_dealt[card_num] == 3:
cnums_dealtcopy[card_num] = 9
if cnums_dealt[card_num] == 4:
cnums_dealtcopy[card_num] = 10
if cnums_dealt[card_num] == 5:
cnums_dealtcopy[card_num] = 11
if cnums_dealt[card_num] == 8:
cnums_dealtcopy[card_num] = 12
suitbid = 5 #filter for clubs in second bid round
secondsuitbid = 0
#print ("New cnums_dealtcopy", cnums_dealtcopy)
if cnums_dealt[20] > 5 and cnums_dealt[20] < 12:
cnums_dealtcopy = cnums_dealt.copy()
#print("cnums_dealtcopy:", cnums_dealtcopy)
#print("Trump could be spades.")
for value in range (13):
for card_num in range (21):
if cnums_dealt[card_num] == 0 or cnums_dealt[card_num] == 12 or cnums_dealt[card_num] == 18:
cnums_dealtcopy[card_num] = 1
if cnums_dealt[card_num] == 1 or cnums_dealt[card_num] == 13 or cnums_dealt[card_num] == 19:
cnums_dealtcopy[card_num] = 2
if cnums_dealt[card_num] == 14 or cnums_dealt[card_num] == 20:
cnums_dealtcopy[card_num] = 3
if cnums_dealt[card_num] == 3 or cnums_dealt[card_num] == 15 or cnums_dealt[card_num] == 21:
cnums_dealtcopy[card_num] = 4
if cnums_dealt[card_num] == 4 or cnums_dealt[card_num] == 16 or cnums_dealt[card_num] == 22:
cnums_dealtcopy[card_num] = 5
if cnums_dealt[card_num] == 5 or cnums_dealt[card_num] == 17 or cnums_dealt[card_num] == 23:
cnums_dealtcopy[card_num] = 6
if cnums_dealt[card_num] == 6:
cnums_dealtcopy[card_num] = 7
if cnums_dealt[card_num] == 7:
cnums_dealtcopy[card_num] = 8
if cnums_dealt[card_num] == 8:
cnums_dealtcopy[card_num] = 13
if cnums_dealt[card_num] == 9:
cnums_dealtcopy[card_num] = 9
if cnums_dealt[card_num] == 10:
cnums_dealtcopy[card_num] = 10
if cnums_dealt[card_num] == 11:
cnums_dealtcopy[card_num] = 11
if cnums_dealt[card_num] == 2:
cnums_dealtcopy[card_num] = 12
suitbid = 11 #filter for spades in second bid round
secondsuitbid = 1
#print ("New cnums_dealtcopy", cnums_dealtcopy)
if cnums_dealt[20] > 11 and cnums_dealt[20] < 18:
cnums_dealtcopy = cnums_dealt.copy()
#print("cnums_dealtcopy:", cnums_dealtcopy)
#print("Trump could be diamonds.")
for value in range (13):
for card_num in range (21):
if cnums_dealt[card_num] == 0 or cnums_dealt[card_num] == 6 or cnums_dealt[card_num] == 18:
cnums_dealtcopy[card_num] = 1
if cnums_dealt[card_num] == 1 or cnums_dealt[card_num] == 7 or cnums_dealt[card_num] == 19:
cnums_dealtcopy[card_num] = 2
if cnums_dealt[card_num] == 2 or cnums_dealt[card_num] == 8:
cnums_dealtcopy[card_num] = 3
if cnums_dealt[card_num] == 3 or cnums_dealt[card_num] == 9 or cnums_dealt[card_num] == 21:
cnums_dealtcopy[card_num] = 4
if cnums_dealt[card_num] == 4 or cnums_dealt[card_num] == 10 or cnums_dealt[card_num] == 22:
cnums_dealtcopy[card_num] = 5
if cnums_dealt[card_num] == 5 or cnums_dealt[card_num] == 11 or cnums_dealt[card_num] == 23:
cnums_dealtcopy[card_num] = 6
if cnums_dealt[card_num] == 12:
cnums_dealtcopy[card_num] = 7
if cnums_dealt[card_num] == 13:
cnums_dealtcopy[card_num] = 8
if cnums_dealt[card_num] == 14:
cnums_dealtcopy[card_num] = 13
if cnums_dealt[card_num] == 15:
cnums_dealtcopy[card_num] = 9
if cnums_dealt[card_num] == 16:
cnums_dealtcopy[card_num] = 10
if cnums_dealt[card_num] == 17:
cnums_dealtcopy[card_num] = 11
if cnums_dealt[card_num] == 20:
cnums_dealtcopy[card_num] = 12
suitbid = 17 #filter for diamonds in second bid round
secondsuitbid = 2
#print ("New cnums_dealtcopy", cnums_dealtcopy)
if cnums_dealt[20] > 17 and cnums_dealt[20] < 24:
cnums_dealtcopy = cnums_dealt.copy()
#print("cnums_dealtcopy:", cnums_dealtcopy)
#print("Trump could be hearts.")
for value in range (13):
for card_num in range (21):
if cnums_dealt[card_num] == 0 or cnums_dealt[card_num] == 6 or cnums_dealt[card_num] == 12:
cnums_dealtcopy[card_num] = 1
if cnums_dealt[card_num] == 1 or cnums_dealt[card_num] == 7 or cnums_dealt[card_num] == 13:
cnums_dealtcopy[card_num] = 2
if cnums_dealt[card_num] == 2 or cnums_dealt[card_num] == 8:
cnums_dealtcopy[card_num] = 3
if cnums_dealt[card_num] == 3 or cnums_dealt[card_num] == 9 or cnums_dealt[card_num] == 15:
cnums_dealtcopy[card_num] = 4
if cnums_dealt[card_num] == 4 or cnums_dealt[card_num] == 10 or cnums_dealt[card_num] == 16:
cnums_dealtcopy[card_num] = 5
if cnums_dealt[card_num] == 5 or cnums_dealt[card_num] == 11 or cnums_dealt[card_num] == 17:
cnums_dealtcopy[card_num] = 6
if cnums_dealt[card_num] == 18:
cnums_dealtcopy[card_num] = 7
if cnums_dealt[card_num] == 19:
cnums_dealtcopy[card_num] = 8
if cnums_dealt[card_num] == 20:
cnums_dealtcopy[card_num] = 13
if cnums_dealt[card_num] == 21:
cnums_dealtcopy[card_num] = 9
if cnums_dealt[card_num] == 22:
cnums_dealtcopy[card_num] = 10
if cnums_dealt[card_num] == 23:
cnums_dealtcopy[card_num] = 11
if cnums_dealt[card_num] == 14:
cnums_dealtcopy[card_num] = 12
suitbid = 23 #filter for hearts in second bid round
secondsuitbid = 3
#print ("New cnums_dealtcopy", cnums_dealtcopy)
player1 = trump_order[0], trump_order[4], trump_order[8], trump_order[12], trump_order[16]
player2 = trump_order[1], trump_order[5], trump_order[9], trump_order[13], trump_order[17]
player3 = trump_order[2], trump_order[6], trump_order[10], trump_order[14], trump_order[18]
player4 = trump_order[3], trump_order[7], trump_order[11], trump_order[15], trump_order[19]
player1_bidding_points = cnums_dealtcopy[0]+cnums_dealtcopy[4]+cnums_dealtcopy[8]+cnums_dealtcopy[12]+cnums_dealtcopy[16]
player2_bidding_points = cnums_dealtcopy[1]+cnums_dealtcopy[5]+cnums_dealtcopy[9]+cnums_dealtcopy[13]+cnums_dealtcopy[17]
player3_bidding_points = cnums_dealtcopy[2]+cnums_dealtcopy[6]+cnums_dealtcopy[10]+cnums_dealtcopy[14]+cnums_dealtcopy[18]
player4_bidding_points = cnums_dealtcopy[3]+cnums_dealtcopy[7]+cnums_dealtcopy[11]+cnums_dealtcopy[15]+cnums_dealtcopy[19]
#print("\nPlayer 1: ",player1, "\nbidding points =", player1_bidding_points)
#print("\nPlayer 2: ",player2, "\nbidding points =", player2_bidding_points)
#print("\nPlayer 3: ",player3, "\nbidding points =", player3_bidding_points)
#print("\nPlayer 4: ",player4, "\nbidding points =", player4_bidding_points)
print("You are player", player_num+1, "\n")
#Is there another way to isolate a player's assignment? This makes them part of a list and can be referenced by position in the list.
playerlist = [player1, player2, player3, player4]
print("Your cards are:", playerlist[player_num])
#Passing or Picking up
for playerbid in range (4):
#print ("player bid = ", playerbid)
while playerbid+1 != player_num+1:
print ("Player ",playerbid+1," will pass.")
break
if playerbid+1 == player_num+1 and playerbid+1 !=4:
bidpickup = input("\nWill you pass or tell the dealer to pick up? Type \'skip' to pass or 'pick up'.\n\n")
if bidpickup == "pick up":
print("Will be programmed later, using skip for now.")
if player_num+1 == 4:
dealerbid = input("\nYou are the dealer. Do you want to pick up \nor pass and go to a second round of bidding?\nType \'skip' to pass or 'pick up'.\n\n")
#print ("suit bid# is ", suitbid)
#print ("cnums is", cnumscopy)
for passbidsuit in range (6):
cnumscopy.pop(cnumscopy[suitbid-passbidsuit])
#print ("cnums filtered is", cnumscopy)
suits.pop(secondsuitbid)
callsuit = "on"
while callsuit == "on":
bidpasscall = input("\nWill you pass again or call a suit? Type \'skip' or 'call'.\n")
if bidpasscall == ("call"):
print("\nThree suits left are:",suits)
callbid = input("Choose one of the suits. \n")
if callbid == suits[0] or callbid == suits[1] or callbid == suits[2]:
callsuit = "off"
elif bidpasscall == ("skip"): #Using else doesn't work here.
print ("\nMore to be programmed later, call a suit for now.")
print("\nTrump will be", callbid)