Exemplo n.º 1
0
class Director:

    def __init__(self):
        self.keep_playing = True
        self.score = 300
        self.dealer = Dealer()
        self.current_card = 0

    def start_game(self):
        while self.keep_playing:
            #self.get_inputs()
            #self.do_updates()
            self.do_outputs()

    def get_inputs(self):
        self.dealer.deal_card()

    def do_updates(self):
        points = self.dealer.get_points()
        self.score += points

    def do_outputs(self):
        if len(self.dealer.cards) == 13:
            self.current_card = self.dealer.deal_card()
        print(f"The card is: {self.current_card}")
        if self.dealer.can_deal() and self.score != 0:
            choice = input("Higher or lower? [h/l] ")
            new_card = self.dealer.deal_card()
            if (choice == "h" and new_card > self.current_card) or (choice == "l" and new_card < self.current_card):
                self.score += 100
            elif (choice == "h" and new_card < self.current_card) or (choice == "l" and new_card > self.current_card):
                self.score -= 75
            else:
                print("That wasn't an option. You lose 200 points.")
                self.score -= 200
            print(f"Next card was: {new_card}")
            print(f"Your score is: {self.score}")
            self.current_card = new_card
            play_more = input("Draw again? [y/n] ")
            self.keep_playing = (play_more == "y")
        else:
            self.keep_playing = False
Exemplo n.º 2
0
class Director:

    # ********************** Will inizialite the game
    def __init__(self):
        """"Class Constructor: will inizialite a dictionary and the num_throws to count
         the amount of times he is going to throw it"""

        self.keep_playing = True
        self.guess = True
        self.dealer = Dealer()
        self.score = 300

    # ********************** Start Game
    def start_game(self):
        """Starts the game loop to control the sequence of play.
        
        Args:
            self (Director): an instance of Director.
        """
        while self.keep_playing:
            self.get_inputs()
            self.do_outputs()
            self.do_updates()

    # ********************** Get imputs
    def get_inputs(self):
        """Gets the inputs at the beginning of each round of play. In this case,
        that means throwing the cards.
        """

        self.dealer.deal_cards()

    # ********************** do outputs
    def do_outputs(self):
        """Outputs the important game information for each round of play. In 
        this case, that means the dealer will get a card and do the score 

        """
        print(f"\nThe Card is : {self.dealer.cards[0]}")
        self.dealer.guess()

        # ********************** Do updates

    def do_updates(self):
        """Updates the important game information for each round of play. In 
        this case, that means updating the score.
        """

        print(f"Next Card was : {self.dealer.cards[1]}")

        self.score = self.dealer.get_points()

        print(f"Your score is {self.score}")

        if self.dealer.can_deal():
            choice = input("Keep playing? [y/n] ")
            if choice == "n":
                print("Thanks for playing have a nice day")
            self.keep_playing = (choice == "y")
        else:

            self.keep_playing = False
            print("You Lost but Thanks for Playing!!")