module Display
Module to display all in game text.
Public Class Methods
beginning_of_guess_round(guess_logic)
click to toggle source
# File lib/display.rb, line 61 def self.beginning_of_guess_round(guess_logic) puts <<~MSG #{gallows(guess_logic)} #{word_to_guess(guess_logic)} Wrong letters: #{guess_logic.incorrect_letters.join(', ')} Incorrect guesses: #{guess_logic.incorrect_guesses}\n\n Make your guess: MSG end
defeat(word_to_guess)
click to toggle source
# File lib/display.rb, line 80 def self.defeat(word_to_guess) puts Gallows.finish puts "\n Sorry, you lose!" puts "\n The word was #{word_to_guess.word.upcase}\n\n" end
end_of_guess_round(guess_logic)
click to toggle source
# File lib/display.rb, line 71 def self.end_of_guess_round(guess_logic) puts guess_logic.messages.pop.to_s end
enter_name()
click to toggle source
# File lib/display.rb, line 33 def self.enter_name puts 'Enter your name: ' end
gallows(guess_logic)
click to toggle source
# File lib/display.rb, line 57 def self.gallows(guess_logic) puts Gallows::GALLOWS[guess_logic.incorrect_guesses] end
instruction_intro()
click to toggle source
# File lib/display.rb, line 11 def self.instruction_intro puts "If you'd like instructions enter 'i'." puts 'Otherwise press return to continue.' end
instructions()
click to toggle source
# File lib/display.rb, line 16 def self.instructions puts <<-MSG Reveal the hidden word before your man is hung. You may guess a single letter at a time. A correct guess will result in that letter being filled in. Incorrect guesses will result in a part of the stick man being drawn. You have 6 incorrect guesses to play with to save your man. You may also guess the whole word at any time. But be careful; an incorrect guess is game over. The game is auto saved after each round. Use the load function at game start to load a previously saved game. Enter 'quit game' at any time to end session. MSG end
leave()
click to toggle source
# File lib/display.rb, line 41 def self.leave puts 'Okay, bye.' end
load_game()
click to toggle source
# File lib/display.rb, line 86 def self.load_game puts "Enter 'load' to load previously saved game." puts 'Or press return to start a new game.' end
play_again()
click to toggle source
# File lib/display.rb, line 37 def self.play_again puts "Would you like to play again? Enter 'yes' or 'no': " end
thank_player(player)
click to toggle source
# File lib/display.rb, line 49 def self.thank_player(player) puts "Thanks #{player.name}" end
validation_errors(errors)
click to toggle source
# File lib/display.rb, line 45 def self.validation_errors(errors) puts errors.join(', ') unless errors.empty? end
victory(word_to_guess)
click to toggle source
# File lib/display.rb, line 75 def self.victory(word_to_guess) puts "\n Yes! The word was #{word_to_guess.word.upcase}." puts "\n You win!\n\n" end
welcome_message()
click to toggle source
# File lib/display.rb, line 7 def self.welcome_message puts "Welcome to Hangman.\n\n" end
word_to_guess(guess_logic)
click to toggle source
# File lib/display.rb, line 53 def self.word_to_guess(guess_logic) puts " Word to guess: #{guess_logic.guessed_word}" end