Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak ending to solitaire example #55

Closed
tommeagher opened this issue Mar 9, 2018 · 3 comments
Closed

Tweak ending to solitaire example #55

tommeagher opened this issue Mar 9, 2018 · 3 comments
Labels

Comments

@tommeagher
Copy link
Collaborator

Everything went great until we got to the last command

for column in columns:
    if card_to_play == column["last_card"]["value"] - 1
        break

There's a big leap there, including a for loop for a list (columns) that we haven't created yet.
We called an audible and instead added a conditional to check if the card is one less than the previous, and if the suit is the same.

 if play_card["value"] == first_column_card["value"] - 1:
        if play_card["suit"] != first_column_card["suit"]:
            if play_card["color"] != first_column_card["color"]: # or create another dict with suits and colors to lookup
                #run a function moving cards
                pass
            else:
                print("You can't play on the same color")
        else:
            print("you can't play on the same suit")
else:
    print("You can't play this card here")
@tommeagher
Copy link
Collaborator Author

@meli-lewis & @elainewong you should take a look at this issue in reference to https://github.com/ireapps/pycar/blob/master/completed/basics_complete_notebook.ipynb to see how you want to address it on Thursday, if you haven't already.

@elainewong
Copy link
Collaborator

For 2020,

When we create dictionaries for play_card and first_card, we also create second_card, third_card and fourth_card. We can add that to a list called columns = [first_card, second_card, third_card, fourth_card] where we can do a for loop for comparison at the end.

Let's make sure that the solitaire example would move the card off the top deck and when we create a dictionary, we have a color key. i.e.

         "value": 5,
         "suit": "spade",
         "color": "black"
}

So the example at the top can be done:

        if play_card["suit"] != first_column_card["suit"]:
            if play_card["color"] != first_column_card["color"]: # or create another dict with suits and colors to lookup
                #run a function moving cards
                pass
            else:
                print("You can't play on the same color")
        else:
            print("you can't play on the same suit")
else:
    print("You can't play this card here")```
 

tommeagher added a commit that referenced this issue Mar 8, 2019
an attempt to fix finish of solitaire exercise, closing #55
@tommeagher
Copy link
Collaborator Author

closed by 4432e38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants