I’m doing a solitaire program, and it’s meant to run in the Python shell instead of a GUI. But I’m not quite so sure how to program the cards so that a Red Suit can be appended onto a Black Suit and vice versa. Also, the number of the card that is to be appended has to be lower than card before it.
I suppose the program used to add restrictions to the row stacks could be similar to the program used to add restrictions to the suit stacks. If it’s different, could you also give me some help on this? Because I’ve nearly finished the project, but I’ve just got to add rules.
I’ve tried to figure out how I could do it, but it seems quite complicated.
def check(card1,card2):
valid = True
cardSuit = Card1[1]
cardVal = card1[0]
if cardSuit2 == cardSuit[1]:
valid = False
elif value(CardVal1) > value(cardVal2):
valid = False
elif valid == False:
# print Error Message
return valid
# Function to call above function
def call():
ok = check(card1,card2)
if ok = True:
# proceed with code
def value(str):
if val is (2,3,4,5,6,7,8,9,10):
denon = int(val)
elif val = 'J':
denon = 11
elif val = 'Q':
denon = 12
elif val = 'K':
denon = 13
return denon
Thanks.
Here is one possiblity. It’s not perfectly clean data-wise, but might give you an idea. However I suppose you better understand the example really well, before you copy. As mentioned it is quite a difference to your initial idea 😉