ichabod801 / t_games

A collection of command-line interface games written in Python.
GNU General Public License v3.0
20 stars 4 forks source link

Crazy Eights draw-one/empty-deck=pass problem #556

Closed ichabod801 closed 4 years ago

ichabod801 commented 4 years ago

I was playing Crazy Eights with the options draw=2 draw-one empty-deck=pass multi-score one-alert. This happened:

Otis played the JC.

The card to you is JC.
Your hand is KD, 6H, 2S.
What is your play? d
You drew the 9H.
The deck is empty.

The card to you is JC.
Your hand is KD, 6H, 9H, 2S.
What is your play?

It seems to me that with draw-one the turn should pass whether or not the deck is empty. It was passing the turn otherwise.

ichabod801 commented 4 years ago

I think the relevant bit of code is in the draw method:


        # Check for empty deck.
        if not self.deck.cards:
            self.human.tell('The deck is empty.')
            if self.empty_deck == 'score':
                self.score()
            if self.empty_deck != 'pass':
                if max(self.scores.values()) < self.goal:
                    self.deal(self.empty_deck == 'reshuffle')
            return self.empty_deck != 'score'
        else:
            return not self.draw_one

So if the deck is empty, draw_one is ignored. In that case the return value (which is the go value returned by player_action) is True if empty_deck is pass or reshuffle, to allow you to pass or continue drawing.

ichabod801 commented 4 years ago

So the empty deck return needs to be anded with the not draw_one return.