Class: Codebreaker::Console

Inherits:
Object
  • Object
show all
Includes:
InputHelper, Phrases, Storage, Validator
Defined in:
lib/entities/console.rb

Constant Summary

Constants included from Validator

Validator::CB_ARRAY_SIZE, Validator::COMMANDS, Validator::GAME_NUMBER_RANGE, Validator::LEVELS, Validator::NAME_SIZE

Constants included from Storage

Storage::FILE_PATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InputHelper

#user_input

Methods included from Validator

#valid_input?

Methods included from Storage

#restore_storage, #save

Methods included from Phrases

#about_complexities, #about_name, #empty_statistic, #error_massage, #goodbye, #greeting, #phrase_before_guess, #phrase_lose, #phrase_win, #puts_hint, #rules, #show, #zero_hint

Constructor Details

#initialize(name, complexity) ⇒ Console

Returns a new instance of Console.



10
11
12
# File 'lib/entities/console.rb', line 10

def initialize(name, complexity)
  @game = Game.new(name, complexity)
end

Instance Attribute Details

#gameObject (readonly)

Returns the value of attribute game.



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

def game
  @game
end

Instance Method Details

#playObject



14
15
16
17
18
19
20
21
22
# File 'lib/entities/console.rb', line 14

def play
  phrase_before_guess
  user_guess = user_input('guess')
  if user_guess == COMMANDS[:hint]
    show_hint
  else
    check_game_answer @game.guess user_guess
  end
end