Class: GamePrompts
- Inherits:
-
Object
- Object
- GamePrompts
- Defined in:
- lib/game_prompts.rb
Instance Attribute Summary collapse
-
#intro_message ⇒ Object
readonly
> nil.
Instance Method Summary collapse
- #after_guess(guess, number_correct, position_right) ⇒ Object
- #game_start ⇒ Object
- #guess_again ⇒ Object
- #guess_count(guess_count) ⇒ Object
- #guess_prompt ⇒ Object
- #instructions ⇒ Object
- #invalid ⇒ Object
- #lose ⇒ Object
- #mastermind_logo ⇒ Object
- #play ⇒ Object
- #play_again ⇒ Object
- #player_input ⇒ Object
- #quit ⇒ Object
- #winner(answer, guess_count, minutes, seconds) ⇒ Object
Instance Attribute Details
#intro_message ⇒ Object (readonly)
> nil
4 5 6 |
# File 'lib/game_prompts.rb', line 4 def end |
Instance Method Details
#after_guess(guess, number_correct, position_right) ⇒ Object
73 74 75 |
# File 'lib/game_prompts.rb', line 73 def after_guess(guess,number_correct, position_right) "Your guess " + "'#{guess.upcase}'".magenta + " has " + "#{number_correct}".magenta + " correct colors with " + "#{position_right}".magenta + " in the correct position." end |
#game_start ⇒ Object
20 21 22 |
# File 'lib/game_prompts.rb', line 20 def game_start "I have generated a beginner sequence with four elements made up of:\n" + "(r)".red + "ed, " + "(g)".green + "reen, " + "(b)".light_blue + "lue, " + "and " +"(y)".yellow + "ellow.\n Use (q)uit at any time to end the game." end |
#guess_again ⇒ Object
61 62 63 |
# File 'lib/game_prompts.rb', line 61 def guess_again "The guess must only be 4 colors and either" +" r, ".red + "g, ".green + "b, ".light_blue + "or y.".yellow end |
#guess_count(guess_count) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/game_prompts.rb', line 65 def guess_count(guess_count) if guess_count == 1 "You have taken" + " #{guess_count}".red + " guess." else "You have taken " + " #{guess_count}".red + " guesses." end end |
#guess_prompt ⇒ Object
57 58 59 |
# File 'lib/game_prompts.rb', line 57 def guess_prompt "Take your guess: ".yellow end |
#instructions ⇒ Object
45 46 47 |
# File 'lib/game_prompts.rb', line 45 def instructions "A secret combination of colors has been chosen at random.\n\nYour job is to guess the correct sequence in 10 tries or less.\n\nIf you manage to win, you'll join the elite as a mastermind.\n\nIf you lose, the shambolic state of your life will be confirmed.\n\nGood luck!...you'll need it.\n\nPress (p) to play." end |
#invalid ⇒ Object
53 54 55 |
# File 'lib/game_prompts.rb', line 53 def invalid "Your argument is invalid. Try again.".red end |
#lose ⇒ Object
12 13 14 |
# File 'lib/game_prompts.rb', line 12 def lose "Nice try you " + "DUMMY. ".blue.bold + play_again end |
#mastermind_logo ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/game_prompts.rb', line 24 def mastermind_logo puts %q{ _ _ _ | | (_) | | _ __ ___ __ _ ___| |_ ___ _ __ _ __ ___ _ _ __ __| | | '_ ` _ \ / _` / __| __/ _ \ '__| '_ ` _ \| | '_ \ / _` | | | | | | | (_| \__ \ || __/ | | | | | | | | | | | (_| | |_| |_| |_|\__,_|___/\__\___|_| |_| |_| |_|_|_| |_|\__,_| }.cyan end |
#play ⇒ Object
37 38 39 |
# File 'lib/game_prompts.rb', line 37 def play "begin the game." end |
#play_again ⇒ Object
77 78 79 |
# File 'lib/game_prompts.rb', line 77 def play_again "(p)lay again or (q)uit?" end |
#player_input ⇒ Object
41 42 43 |
# File 'lib/game_prompts.rb', line 41 def player_input "Enter Choice: ".yellow end |
#quit ⇒ Object
49 50 51 |
# File 'lib/game_prompts.rb', line 49 def quit "Your father was right about you, you are a quitter.".red end |
#winner(answer, guess_count, minutes, seconds) ⇒ Object
16 17 18 |
# File 'lib/game_prompts.rb', line 16 def winner(answer, guess_count, minutes, seconds) "WINNER! You guessed the sequence '#{answer.join('').upcase}' with #{guess_count} guesses in #{minutes} minutes and #{seconds} seconds.\n(p)lay again or (q)uit?" end |