Class: Ui

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/codebreaker/ui.rb

Instance Method Summary collapse

Methods included from Helper

#to_array, #verify

Constructor Details

#initializeUi

Returns a new instance of Ui.



5
6
7
# File 'lib/codebreaker/ui.rb', line 5

def initialize
  puts 'Welcome to the game!'
end

Instance Method Details

#ask_position(params) ⇒ Object



23
24
25
26
# File 'lib/codebreaker/ui.rb', line 23

def ask_position(params)
  puts 'What posotion would you like to open? (1,2,3,4)'
  verify(params).to_i - 1
end

#congratulationsObject



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

def congratulations
  puts 'Congratulations, you breake the code!'
end

#greetingObject



9
10
11
# File 'lib/codebreaker/ui.rb', line 9

def greeting
  puts 'Welcome to the Codebreaker'
end

#no_hintObject



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

def no_hint
  puts '(!)There are no hints any more'
end

#play_again(params) ⇒ Object



52
53
54
55
# File 'lib/codebreaker/ui.rb', line 52

def play_again(params)
  puts 'Play again? (y/n)'
  verify(params)
end

#save?Boolean

Returns:

  • (Boolean)


62
63
64
65
# File 'lib/codebreaker/ui.rb', line 62

def save?
  puts 'Would you like to save the result? (y/n)'
  return true if gets.strip.chomp == 'y'
end

#set_attempts(params) ⇒ Object



13
14
15
16
# File 'lib/codebreaker/ui.rb', line 13

def set_attempts(params)
  puts 'How many attempts do you need, to break the code?'
  verify(params).to_i
end

#set_nameObject



57
58
59
60
# File 'lib/codebreaker/ui.rb', line 57

def set_name
  puts 'Enter your name:'
  gets.strip.capitalize
end

#show_hint(hint) ⇒ Object



32
33
34
# File 'lib/codebreaker/ui.rb', line 32

def show_hint(hint)
  puts hint
end

#show_plus_minus(plus_minus) ⇒ Object



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

def show_plus_minus(plus_minus)
  puts plus_minus
end

#sympathy(code) ⇒ Object



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

def sympathy(code)
  puts "Unfortunately, you lose. Secret code was : #{code}"
end

#user_input(params) ⇒ Object



18
19
20
21
# File 'lib/codebreaker/ui.rb', line 18

def user_input(params)
  puts "Please, enter 4 numbers in range from 1 to 6 or type 'hint'"
  verify(params)
end

#user_try(params) ⇒ Object



28
29
30
# File 'lib/codebreaker/ui.rb', line 28

def user_try(params)
  verify(params)
end