def __init__(self): """States the variables we will use""" self.lives = 4 self.console = Console() self.jumper = Jumper() self.word = Word()
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 __init__(self): self._passcode = '' self._player_guess = '' self._keep_playing = True self._console = Console() self._roster = Roster() self._logic = Logic()
def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self.__stop_round = False self._board = Board() self._console = Console()
def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self.console = Console() self.seeker = Seeker() self.keep_playing = True self.hider = Hider()
def __init__(self): self.puzzle = Puzzle() self.player = Player() self.console = Console() self.word = self.puzzle.generate_word() self.guesses = self.puzzle.create_blank_array() self.is_correct_guess = False self.lives = 5 self.guess = '' self.game_keep_playing = True
def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self.console = Console() self.parachuter = Parachuter() self.keep_playing = True self.word = Word()
def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self.console = Console() self.hunter = Hunter() self.keep_playing = True self.rabbit = Rabbit()
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 __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self.console = Console() self.killer = Killer() self.keep_playing = True self.guesser = Guesser() self.fails = 0
def __init__(self): """"Class Constructor: will inizialite a list and get the word to be guess""" self.keep_playing = True self.guess = Guess() self.console = Console() self.word = Word() # This will draw the parachuse just one time self.tries = 0 self.user_letter = ""
def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self._console = Console() self._keep_playing = True self._move = Move() self._roster = Roster() self._logic = Logic()
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 __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self._board = Board() self._console = Console() self._keep_playing = True self._move = None self._roster = Roster()
def start_game(name, plaintext): console = Console(plaintext) if not name: console.print_block([ 'Hello, future zombie!', 'Please enter your name.' ]) name = console.get_input(None) dictionary = Dictionary() ctx = Context(name, console, dictionary) _intro(ctx) _repl(Parser(dictionary), ctx)
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 __init__(self): """Class constructor. Declares and Initializes instance attributes. self(Director): instance of Director. """ self.guesser = Guesser() self.console = Console() self.breakdown = Breakdown() self.wordlist = ['apple', 'bazaar', 'crayon', 'query', 'ears'] self.word = '' self.keep_playing = True self.check = []
def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self.console = Console() self.jumper = jumper() self.keep_playing = True self.puzzle = Puzzle() self.wrong_guess = 0 self.masked_word = []
def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self._console = Console() self._display = Display() self._keep_playing = True self._roster = Roster() self._board = Board() self._check = Check() self.guessCounter = 1
def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self._board = Board() self._console = Console() self.keep_playing = True self.code = self._board.numbers_to_guess self._moves = [Move(self.code, '----'), Move(self.code, '----')] self._roster = Roster()
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 __init__(self): """ Class constructor itself. Args: self(Director): creates an instance of Director. """ self._console = Console() self._keep_playing = True self._roster = Roster() self._move = None self._secret_code = Secret_Code() def start_game(self): """ Initiates the game through a loop (hopefully) controlling the sequence of play as well. """ pass def _prepare_game(self): """ Responsible in preparing the game prior to it being initiated (excluding prior to be opened). This will be getting the names of those players and placing them in a roster type format. This is through the use of the Roster.py class. """ for p in range(2): name - self.console.read(f'Enter a name for player {n + 1}: ') player = Player(name) self._roster.add_player(player) def _#TODO: pass
def test_started_after_stopped(self): game = Game(name="TestGame", console=Console(), player=Player("TestPlayer")) with self.assertRaises(GameStoppedException): game.stop() game.start(running_mode='test')
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
def test_game_attributes(self): console = Console() player = Player("TestPlayer") game = Game(name="TestGame", console=console, player=player) self.assertEqual(game.name, "TestGame") self.assertEqual(game.console, console) self.assertEqual(game.player, player) self.assertEqual(game.exceptions, []) self.assertEqual(game.actions, []) self.assertEqual(game.running, False) self.assertEqual(game.stopped, False)
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
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: board (Hunter): An instance of the class of objects known as Board. console (Console): An instance of the class of objects known as Console. keep_playing (boolean): Whether or not the game can continue. move (Rabbit): An instance of the class of objects known as Move. roster (Roster): An instance of the class of objects known as Roster. """ def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self._board = Board() self._console = Console() self._keep_playing = True self._move = None self._roster = Roster() def start_game(self): """Starts the game loop to control the sequence of play. Args: self (Director): an instance of Director. """ self._prepare_game() while self._keep_playing: self._get_inputs() self._do_updates() self._do_outputs() def _prepare_game(self): """Prepares the game before it begins. In this case, that means getting the player names and adding them to the roster. Args: self (Director): An instance of Director. """ for n in range(2): name = self._console.read(f"Enter a name for player {n + 1}: ") player = Player(name) self._roster.add_player(player) def _get_inputs(self): """Gets the inputs at the beginning of each round of play. In this case, that means getting the move from the current player. Args: self (Director): An instance of Director. """ # display the game board board = self._board.to_string() self._console.write(board) # get next player's move player = self._roster.get_current() self._console.write(f"{player.get_name()}'s turn:") pile = self._console.read_number("What pile to remove from? ") stones = self._console.read_number("How many stones to remove? ") move = Move(stones, pile) player.set_move(move) def _do_updates(self): """Updates the important game information for each round of play. In this case, that means updating the board with the current move. Args: self (Director): An instance of Director. """ player = self._roster.get_current() move = player.get_move() self._board.apply(move) def _do_outputs(self): """Outputs the important game information for each round of play. In this case, that means checking if there are stones left and declaring the winner. Args: self (Director): An instance of Director. """ if self._board.is_empty(): winner = self._roster.get_current() name = winner.get_name() print(f"\n{name} won!") self._keep_playing = False self._roster.next_player()
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: _board (Board): An instance of the class of objects known as Board. _console (Console): An instance of the class of objects known as Console. keep_playing (boolean): Whether or not the game can continue. code: the code for the game _moves (Move): Instances of the class of objects known as Move. _roster (Roster): An instance of the class of objects known as Roster. """ def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self._board = Board() self._console = Console() self.keep_playing = True self.code = self._board.numbers_to_guess self._moves = [Move(self.code, '----'), Move(self.code, '----')] self._roster = Roster() def start_game(self): """Starts the game loop to control the sequence of play. Args: self (Director): an instance of Director. """ self._prepare_game() while self.keep_playing: self.print_board() self.turn() def _prepare_game(self): """Prepares the game before it begins. In this case, that means getting the player names and adding them to the roster. Args: self (Director): An instance of Director. """ player = [None, None] for n in range(2): name = self._console.get_name() player[n] = Player(name) self._roster.add_player(player[0], player[1]) def print_board(self): """Outputs the important game information for each round of play. Args: self (Director): An instance of Director. """ # display the game board board = self._board.to_string(self._roster, self._moves[0], self._moves[1]) self._console.write(board) def turn(self): """Gets input from player, applies input, checks to see if player won, selects next player Args: self (Director): An instance of Director. """ # get player's move player = self._roster.get_current() self._console.write(f"{player.get_name()}'s turn:") guess = self._console.read_number("What is your guess? ") self._moves[self._roster.current].update_guess(guess) player.set_move(self._moves[self._roster.current]) # check for victory if str(guess) == str(self.code): self._console.write(f'\n{player.get_name()} won!') self.keep_playing = False # next player self._roster.next_player()
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. hunter (Hunter): An instance of the class of objects known as Hunter. rabbit (Rabbit): An instance of the class of objects known as Rabbit. """ def __init__(self): """The class constructor. Args: self (Director): an instance of Director. """ self.console = Console() self.jumper = jumper() self.keep_playing = True self.puzzle = Puzzle() self.wrong_guess = 0 self.masked_word = [] 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 at the beginning of each round of play. In this case, that means moving the hunter to a new location. Args: self (Director): An instance of Director. """ record_guess = self.console.read_number("Guess a letter [a-z]: ") self.puzzle.record_guess(record_guess) def do_updates(self): """Updates the important game information for each round of play. In this case, that means the rabbit watches the hunter. Args: self (Director): An instance of Director. """ self.masked_word = self.puzzle.mask_word if self.puzzle.in_word() == False: self.wrong_guess = +1 def do_outputs(self): """Outputs the important game information for each round of play. In this case, that means the rabbit provides a hint. Args: self (Director): An instance of Director. """ parachute_1 = self.jumper.midgame_avatar() self.console.write(parachute_1) self.console.write(self.masked_word) self.keep_playing = (self.jumper.distance[-1] != 0)
def __init__(self): self.correct = True self.keep_playing = True self.console = Console() self.jumper = Jumper() self.word_bank = Word_Bank()