示例#1
0
 def __init__(self):
     self.letter = ''
     self.keep_playing = True
     self.play_again = True
     self.jumper = Jumper()
     self.word_processor = Word_Processor()
     self.console = Console()
示例#2
0
    def __init__(self):
        """States the variables we will use"""

        self.lives = 4
        self.console = Console()
        self.jumper = Jumper()
        self.word = Word()
示例#3
0
    def __init__(self):
        """The class constructor.
        
        Args:
            self (Director): an instance of Director.
        """

        self.console = Console()
        self.word = Word() #generate the word here. correctWord is generated on Word init
        self.jumper = Jumper(self.word.correctWord) #needs the correct word to generate length of underscore array
        self.keep_playing = True
示例#4
0
 def __init__(self):
     """The class constructor.
     
     Args:
         self (Director): an instance of Director.
     """
     self.console = Console()
     self.jumper = Jumper()
     self.keep_playing = True
     self.word = Word()
     self.current_guess = ""
示例#5
0
 def __init__(self):
     self.keep_playing = True
     self.random_word = ""
     self.parachuter = [
         "  ___  ", " /___\ ", " \   / ", "  \ /  ", "   0   ", "  /|\  ",
         "  / \  ", "       ", "^^^^^^^"
     ]
     self.cut_parachute = False
     self.guess = ""
     self.console = Console()
     self.jumper = Jumper()
     self.cutter = Cutter()
示例#6
0
 def __init__(self):
     """The class constructor.
     
     Args:
         self (Director): an instance of Director.
     """
     self.console = Console()
     self.jumper = Jumper()
     self.guesser = Guesser()
     self.keep_playing = True
     self.word_guessed = False
     self.parachute = self.jumper.return_parachute()
     self.current_guess = self.guesser.return_guess()
     self.letter = ''
示例#7
0
 def __init__(self):
     """Attributesof of the class"""
     """Objects of the class"""
     self.strikes = 0  # Strikes start at 0
     self.jumper = Jumper()  # Call the Jumper Class
     self.word = Word()  # Call the Word Class
     self.output = Output()  # Call the Output Class
     self.keep_playing = True  # Keep playing while true
     self.guess = ""  # Empty string to hold user letter input
示例#8
0
class Director:
    def __init__(self):
        self.jumper = Jumper()
        self.console = Console()
        self.puzzle = Puzzle()
        self.keepPlaying = True

    def start_game(self):
        while (self.keepPlaying):
            self.console.displayMessage(self.puzzle.getDisplayWord())
            self.console.displayParachute(self.jumper.getNumParachutePieces())

            userGuess = str(self.console.getGuess())
            if (not self.puzzle.isCorrect(userGuess)):
                self.jumper.cutParachute()

            if (self.puzzle.hasWon()):
                self.console.displayMessage("The word is: " +
                                            self.puzzle.getWord())
                self.console.displayParachute(
                    self.jumper.getNumParachutePieces())
                self.console.displayMessage("Congratulations! You have won!")
                self.keepPlaying = False

            if (self.jumper.getNumParachutePieces() == 0):
                self.console.displayMessage("The word is: " +
                                            self.puzzle.getWord())
                self.console.displayParachute(
                    self.jumper.getNumParachutePieces())
                self.console.displayMessage(
                    "YOU'RE DEAD X_X BETTER LUCK NEXT TIME!")
                self.keepPlaying = False
示例#9
0
class Director:
    """Director class engine of the program"""

    def __init__(self):
        """States the variables we will use"""

        self.lives = 4
        self.console = Console()
        self.jumper = Jumper()
        self.word = Word()

    def start_game(self):
        """Starts the game"""

        self.console.write("Hello welcome to Jumper")
        # Get a word
        self.word.get_word()

        while self.lives >= 0:
            # Display word
            result = self.word.print_word()
            if result:
                self.console.write(
                    "Congratulations you guessed the word correctly")
                break

            # Display the Jumper
            self.console.write(self.jumper.get_parachute(self.lives))

            # Check if you lose
            if not self.lives:
                self.console.write("You killed him")
                break

            # Ask for a Guess
            guess = self.console.read("Guess a letter [a-z]: ")

            # Filters input
            result = self.word.check_guess(guess)
            if not result:
                continue

            # Saves guess and updates life
            result = self.word.save_guess(guess)
            if not result:
                self.lives -= 1
示例#10
0
class Director:   
    """The responsibility of the director is to control how the game is played.
    
    Stereotype:
        Controller

    Attributes:
        console (Console): An instance of the class of objects known as Console.
        keep_playing (boolean): Whether or not the game can continue.
        word_guessed (boolean): Whether or not the word has been guessed.
        parachute (array): The status of the parachute.
        current_guess (string): The current amount of letters guessed.
        letter (char): The letter from the user. 
        jumper (Jumper): An instance of the class of objects known as Jumper.
        guesser (Guesser): An instance of the class of objects known as Guesser.
    """
    def __init__(self):
        """The class constructor.
        
        Args:
            self (Director): an instance of Director.
        """
        self.console = Console()
        self.jumper = Jumper()
        self.guesser = Guesser()
        self.keep_playing = True
        self.word_guessed = False
        self.parachute = self.jumper.return_parachute()
        self.current_guess = self.guesser.return_guess()
        self.letter = ''
        
    def start_game(self):
        """Starts the game loop to control how the game is played.
        
        Args:
            self (Director): an instance of Director.
        """
        self.guesser.generate_word()
        self.do_outputs()
        while self.keep_playing:
            self.get_inputs()
            self.do_updates()
            self.do_outputs()

    def get_inputs(self):
        """Gets the inputs at the beginning of each round of play. In this instance it means
        getting a letter from the user.

        Args:
            self (Director): An instance of Director.
        """
        self.letter = self.console.get_letter()

    def do_updates(self):
        """Updates the important game information for each round of play. In this case
        that means checking the parachute and cutting off part if user guess is wrong.
        As well as keeping track of correct guesses and updating the current word.

        Args:
            self (Director): An instance of Director.
        """
        good_parachute = self.jumper.check_parachute()
        if good_parachute == True and self.word_guessed == False:
            letter = self.letter
            valid_guess = self.guesser.check_guess(letter)
            self.current_guess = self.guesser.return_guess()
            self.jumper.cut_parachute(valid_guess)
            self.parachute = self.jumper.return_parachute()
            self.word_guessed = self.guesser.check_word()
        elif good_parachute == False:
            self.keep_playing = False
        if self.word_guessed == True:
            self.keep_playing = False
        
    def do_outputs(self):
        """Outputs the important game information for each round of play. Such as the current word
        and the status of the jumper.

        Args:
            self (Director): An instance of Director.
        """
        self.console.display_guess(self.current_guess)
        self.console.display_parachute(self.jumper.parachute)
示例#11
0
 def __init__(self):
     self.correct = True
     self.keep_playing = True
     self.console = Console()
     self.jumper = Jumper()
     self.word_bank = Word_Bank()
示例#12
0
class Director:
    def __init__(self):
        self.correct = True
        self.keep_playing = True
        self.console = Console()
        self.jumper = Jumper()
        self.word_bank = Word_Bank()

    def start_game(self):
        self.word_bank.load_list("wordlist.txt")
        self.word_bank.choose_word()
        self.word_bank.get_blank()
        self.jumper.create_parachute()
        self.jumper.print_parachute()

        while self.keep_playing:
            blank = self.word_bank.get_blank()
            self.console.write(blank)
            self.get_inputs()
            self.do_updates()
            self.do_outputs()

    def get_inputs(self):
        guess = (self.console.read("Guess a letter [a-z]: ")).lower()
        self.correct = self.word_bank.check_guess(guess)

    def do_updates(self):
        if self.correct == True:
            self.jumper.print_parachute()
        elif self.correct == False:
            self.jumper.remove_parachute()
            self.jumper.print_parachute()
        else:
            self.console.write("You already guessed that letter")
            self.get_inputs()

    def do_outputs(self):
        if self.jumper.is_alive() == False:
            self.keep_playing = False
            self.console.write(
                f"Oh no he died! the word was {self.word_bank.word}")

        elif self.word_bank.check_win() == True:
            self.keep_playing = False
            self.console.write(f"You did it!")
        else:
            self.keep_playing == True
示例#13
0
 def __init__(self):
     self.jumper = Jumper()
     self.console = Console()
     self.puzzle = Puzzle()
     self.keepPlaying = True
示例#14
0
class Director:
    """A code template for a person who directs the game. The responsibility of 
    this class of objects is to control the sequence of play.
    
    Stereotype:
        Controller

    Attributes:
        console (Console): An instance of the class of objects known as Console.
        jumper (Jumper): An instance of the class of objects known as Jumper.
        keep_playing (boolean): Whether or not the game can continue.
        word (Word): An instance of the class of objects known as Word.
        current_guess (string): The last guess made by the player.
    """

    def __init__(self):
        """The class constructor.
        
        Args:
            self (Director): an instance of Director.
        """
        self.console = Console()
        self.jumper = Jumper()
        self.keep_playing = True
        self.word = Word()
        self.current_guess = ""
        
    def start_game(self):
        """Starts the game loop to control the sequence of play. When the game
        is over, it plays a corresponding sound and displays the correct word.
        
        Args:
            self (Director): an instance of Director.
        """

        self.do_outputs()

        while self.keep_playing:
            self.get_inputs()
            self.do_updates()
            self.do_outputs()

        self.console.write("The word was: " + self.word.cur_word)

        if self.word.is_win():
            playsound('./assets/win.wav')
        else:
            playsound('./assets/death.mp3')



    def get_inputs(self):
        """Gets the inputs at the beginning of each round of play. In this case,
        gets a letter from the player to match the word. Only allows players to
        input letters they haven't guessed yet.

        Args:
            self (Director): An instance of Director.
        """
        self.current_guess = self.console.read_letters("Guess a letter [a-z]: ")

        while self.current_guess in self.word.all_guesses:
            self.current_guess = self.console.read_letters("You already guessed that. Please guess a new letter [a-z]: ")
        
        
    def do_updates(self):
        """Updates the important game information for each round of play. In 
        this case, the jumper hangs the man some more, or the new correct letter
        gets displayed.

        Args:
            self (Director): An instance of Director.
        """
        if not self.word.check_letter(self.current_guess):
            self.jumper.deduct_life()
        
    def do_outputs(self):
        """Outputs the important game information for each round of play. In 
        this case, that means it displays if the guy is alive or not still 
        along with the word.

        Args:
            self (Director): An instance of Director.
        """
        self.keep_playing = self.jumper.is_alive()
        jumper_drawing = f"{self.word.hidden_word}\n\n" + self.jumper.get_output()
        self.console.write(jumper_drawing)

        if self.word.is_win():
            self.keep_playing = False
示例#15
0
class Director:
    """A code template for a person who directs the game. The responsibility of 
    this class of objects is to control the sequence of play.
    
    Stereotype:
        Controller

    Attributes:
        console (Console): An instance of the class of objects known as Console.
        keep_playing (boolean): Whether or not the game can continue.
        
    """

    def __init__(self):
        """The class constructor.
        
        Args:
            self (Director): an instance of Director.
        """

        self.console = Console()
        self.word = Word() #generate the word here. correctWord is generated on Word init
        self.jumper = Jumper(self.word.correctWord) #needs the correct word to generate length of underscore array
        self.keep_playing = True

        
    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_updates()
            self.do_outputs()

    def get_inputs(self):
        """Gets the inputs from user at the beginning of each round
        of play. Send update array to jumper

        Args:
            self (Director): An instance of Director.
        """
        message = ""
        for element in self.jumper.displayArray:    # Line added
            message = message + element + " "     # Line added
        self.console.write(message) # Original line
        message = self.jumper.picture()
        self.console.write(message)
        oneLetterResponse = False
        while not oneLetterResponse:
            self.guess = self.console.read("Guess a letter [a-z]: ")
            if len(self.guess) != 1:
                print("\nPlease enter one letter. No more, no less.\n")
            else:
                oneLetterResponse = True

        
    def do_updates(self):
        """Updates the important game information for each round of play.
        check the word (boolean value).

        Args:
            self (Director): An instance of Director.
        """
        self.positionsOfCorrect = self.word.checkLetter(self.guess)
        self.jumper.updateArray(self.positionsOfCorrect, self.guess)
        self.checkVictory = self.jumper.checkVictory()
        self.checkDefeat = self.jumper.checkDefeat()
        
    def do_outputs(self):
        """Outputs the important game information for each round of play. In 
            checkVictory
            checkDefeat

        Args:
            self (Director): An instance of Director.
        """
        if self.checkVictory == True: #Checks to see if you've won. Still needs lots of testing
            message = "Congratulations, you won! The word was: "
            self.console.write(message)
            message = "\n" + self.word.correctWord
            self.console.write(message)

            self.keep_playing = False #If you've won, game ends. 

        elif self.checkDefeat == True: #checks to see if you've lost, still needs lots of testing. 
            message = self.jumper.picture()
            self.console.write(message)

            message ="\nSorry! Try again! Your word was: "
            self.console.write(message)

            message ="\n" + self.word.correctWord
            self.console.write(message)

            self.keep_playing = False #if you've lost, game ends
            
示例#16
0
class Director:
    """
    A code template for a person who directs the game. The responsibility of 
    this class of objects is to keep track of the score and control the 
    sequence of play.
    
    Attributes:
        

    General Workflow:

    """
    def __init__(self):
        self.letter = ''
        self.keep_playing = True
        self.play_again = True
        self.jumper = Jumper()
        self.word_processor = Word_Processor()
        self.console = Console()

    def start_game(self):
        """
        Starts the game loop
        """
        self.word_processor.get_word()
        self.word_processor.set_hidden_word(self.word_processor.word_choice)
        while self.keep_playing:
            self.get_user_get_and_display()
            self.do_updates()

    def get_user_get_and_display(self):
        """
        Asks the user input
        """

        self.console.write('')
        self.console.write(self.word_processor.hidden_word)
        self.console.write('')

        self.console.write(self.jumper.displayed_chute)
        self.console.write('---------------')

        self.letter = self.console.read("Guess a letter [A-Z]: ")
        self.console.write('')

    def do_updates(self):
        """
        This will adjust data based off of user's choices

        """
        self.jumper.update_chute(self.word_processor.check_input(self.letter))
        if self.word_processor.check_complete():
            self.console.write(self.word_processor.hidden_word)
            self.console.write("You win!\nThanks for playing!")
            self.keep_playing == False
            exit()
        elif self.jumper.is_alive is False:
            self.console.write(
                f'Sorry the word was: {self.word_processor.word_choice}')
            self.console.google_word(self.word_processor.word_choice)
            self.console.write('Oh. He ded...')
            self.console.write(self.jumper.displayed_chute)
            self.keep_playing == False
            exit()
示例#17
0
class Director:
    """A code template for a person who directs the game. The responsibility of 
    this class of objects is to control the sequence of play.
    
    Stereotype:
        Controller

    Attributes:
        keep_playing (boolean): Whether or not the game can continue.
        random_word (string): Word for player to guess
        parachuter: list of strings for an ascii art
        cut_parachute (boolean): Wheter or not to cut the parachute
        guess (string): letter guessed by player
        console (Console): An instance of the class of objects known as Console.
        jumper (Jumper): An instance of the class of objects known as Jumper.
        cutter (Cutter): An instance of the class of objects known as Cutter.
    """
    def __init__(self):
        self.keep_playing = True
        self.random_word = ""
        self.parachuter = [
            "  ___  ", " /___\ ", " \   / ", "  \ /  ", "   0   ", "  /|\  ",
            "  / \  ", "       ", "^^^^^^^"
        ]
        self.cut_parachute = False
        self.guess = ""
        self.console = Console()
        self.jumper = Jumper()
        self.cutter = Cutter()

    def start_game(self):
        #Get words from list and randomly choose one for game
        self.get_text_file()
        self.random_word = self.cutter.get_word(self.word_list)
        while (self.keep_playing):
            self.do_outputs()
            self.get_inputs()
            self.do_updates()
        #If game is lost show that the parachuter is dead
        self.parachuter[0] = "   X   "
        self.console.display_parachuter(self.parachuter)
        self.console.display_answer(self.cutter.word)

    def do_outputs(self):
        #Display empty spaces and parachuter
        self.console.display_wordspace(self.cutter.empty_word)
        self.console.display_parachuter(self.parachuter)

    def do_updates(self):
        #Update parachuter and end if no parachute
        self.cutter.update_blanks(self.guess)
        self.cutter.cut_parachute(self.guess, self.parachuter)
        #need to update the blankword array with correct letter
        self.keep_playing = self.cutter.end_of_line()

    def get_inputs(self):
        #Get inputs
        self.guess = self.jumper.get_guess()

    def get_text_file(self):
        #Read file with words
        self.my_file = open("jumper\Randomwords.txt")
        self.word_list = self.my_file.readlines()
        self.my_file.close()