Class: GamePrompts

Inherits:
Object
  • Object
show all
Defined in:
lib/game_prompts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#intro_messageObject (readonly)

> nil



4
5
6
# File 'lib/game_prompts.rb', line 4

def intro_message
  @intro_message
end

Instance Method Details

#after_guess(guess, number_correct, position_right) ⇒ Object



72
73
74
# File 'lib/game_prompts.rb', line 72

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_startObject



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.\n\n"
end

#guess_againObject



60
61
62
# File 'lib/game_prompts.rb', line 60

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



64
65
66
67
68
69
70
# File 'lib/game_prompts.rb', line 64

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_promptObject



56
57
58
# File 'lib/game_prompts.rb', line 56

def guess_prompt
  'Take your guess: '.yellow
end

#instructionsObject



44
45
46
# File 'lib/game_prompts.rb', line 44

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

#invalidObject



52
53
54
# File 'lib/game_prompts.rb', line 52

def invalid
  'Your argument is invalid. Try again.'.red
end

#loseObject



12
13
14
# File 'lib/game_prompts.rb', line 12

def lose
  'Nice try you ' + 'DUMMY. '.blue.bold + play_again
end

#mastermind_logoObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/game_prompts.rb', line 24

def 
  puts
  %q{
                        _                      _           _
                       | |                    (_)         | |
    _ __ ___   __ _ ___| |_ ___ _ __ _ __ ___  _ _ __   __| |
   | '_ ` _ \ / _` / __| __/ _ \ '__| '_ ` _ \| | '_ \ / _` |
   | | | | | | (_| \__ \ ||  __/ |  | | | | | | | | | | (_| |
   |_| |_| |_|\__,_|___/\__\___|_|  |_| |_| |_|_|_| |_|\__,_|
   }.cyan
end

#playObject



36
37
38
# File 'lib/game_prompts.rb', line 36

def play
  'begin the game.'
end

#play_againObject



76
77
78
# File 'lib/game_prompts.rb', line 76

def play_again
  '(p)lay again or (q)uit?'
end

#player_inputObject



40
41
42
# File 'lib/game_prompts.rb', line 40

def player_input
  'Enter Choice: '.yellow
end

#quitObject



48
49
50
# File 'lib/game_prompts.rb', line 48

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