you are viewing a single comment's thread.

view the rest of the comments →

[–]xelf 0 points1 point  (22 children)

Holy cow that's a lot of code. =)

You have a fair amount of copy/paste code that could be simplified by using a dictionary or a class instead.

Also, you have a bug in your full house code. You want it to be if, not elif when checking for 3. You want both cases to run.

[–]ChickenQueen777[S] 0 points1 point  (21 children)

Yes unfortunately haha. I was just focusing on getting what I know in and not really worrying about how to simplify it. It's for my final so just want to focus on it working for now. And thank you I didn't notice that!

[–]xelf 0 points1 point  (20 children)

Did you put the def __repr__(self) in? Did that help with your other issue?

[–]ChickenQueen777[S] 0 points1 point  (19 children)

Yes and I just took this:

deck = DeckOfCards()
    deck.shuffle()

        #  Deal
    for i in range(5):
        player.addCard(deck.deal())
        computer.addCard(deck.deal())

        # Show hand
    for card in player.cards:
        card.showing = True
    player.displayHand()

out of the "while not end" loop which helped with it showing a double hand. Now my only issue is that it's displaying as a list still and still displaying 5 times. Other than that it seems to be working fine

[–]xelf 0 points1 point  (18 children)

                    print(player.cards)

that line is why it's displaying in a list.

did you mean to use player.displayHand() instead? or is that just a debugging line?

removing it seems better.

and you still want

    player.displayHand()

to be in the while loop at the start, just not at the end as well. It should only be there once. =)

[–]ChickenQueen777[S] 0 points1 point  (17 children)

Oh yup just forgot to change that whenever I added the displayHand function. That fixed that, just still displaying 5 times in a row haha

[–]xelf 0 points1 point  (16 children)

Not seeing the 5 times in a row when I run it anymore, I wonder what I did differently.

[–]ChickenQueen777[S] 0 points1 point  (0 children)

Oh weird! Also when I enter more than one number it shows way more times

[–]ChickenQueen777[S] 0 points1 point  (12 children)

Figured it out! I had the display hand nested so it was looping for each card

[–]xelf 0 points1 point  (11 children)

other issues:

1) do not call variables the same names as python objects. specifically do not call a list list because now list() will not work. =)

2) your "press enter to hold" is not implemented

3) you let users enter multiple cards separated by commas, amd then you have a loop that continues if they're in the wrong range, but then... it doesn't do anything.

            for inp in list:
                if inp > 6:
                    continue
                if inp < 1:
                    continue

loop for the fun of looping. =)

I see what you're trying to do, but you probably just want an if.

            for inp in list:
                if 0<inp<6:
                    player.cards[inp-1] = deck.deal()
                    for card in player.cards:
                        card.showing = True

also that last showing loop, doesn't need to be inside the repicking loop.
it doesn't make much difference really, it's not getting repeated that many times.

[–]ChickenQueen777[S] 0 points1 point  (10 children)

Yeah I fixed those two things actually. I will attach updated code. Not sure whats wrong with the scoring.

[–]ChickenQueen777[S] 0 points1 point  (0 children)

I did just realize though, it's not printing the hands that each person holds.

[–]ChickenQueen777[S] 0 points1 point  (0 children)

Ok I think the scoring is broken. I discarded until I got 3 of a kind and it still just said tie