class CodebreakerGem::Console
Constants
- COMMANDS
- KEYWORDS
Public Instance Methods
select_option()
click to toggle source
# File lib/app/entities/console.rb, line 27 def select_option case user_input when COMMANDS[:start] then navigation when COMMANDS[:rules] then output.rules when COMMANDS[:stats] then output.display(statistic.rating_table) else failing.unexpected_option end end
Private Instance Methods
game_process()
click to toggle source
# File lib/app/entities/console.rb, line 44 def game_process output.game_start_heading @game = Game.new(@difficulty.level) make_guess end
guess_result()
click to toggle source
# File lib/app/entities/console.rb, line 61 def guess_result @game.increment_used_attempts return win if @game.win?(@guess.guess_code) return loss if @game.loss? marked_guess = @game.mark_guess(@guess.guess_code) output.display(marked_guess) end
loss()
click to toggle source
# File lib/app/entities/console.rb, line 76 def loss output.display(failing.attempts_limit) start_new_game end
make_guess()
click to toggle source
# File lib/app/entities/console.rb, line 50 def make_guess loop do @guess = create_entity(Guess) @guess.hint? ? output_hint : guess_result end end
output_hint()
click to toggle source
# File lib/app/entities/console.rb, line 57 def output_hint @game.hints_available? ? output.display(failing.hints_limit) : output.display(@game.use_hint) end
save_result()
click to toggle source
# File lib/app/entities/console.rb, line 81 def save_result output.save_result loop do case user_input when KEYWORDS[:yes] then return statistic.save(@player, @game) when KEYWORDS[:no] then return else failing.unexpected_command end end end
start_new_game()
click to toggle source
# File lib/app/entities/console.rb, line 92 def start_new_game output.start_new_game loop do case user_input when KEYWORDS[:yes] then menu when KEYWORDS[:no] then exit_from_console else failing.unexpected_command end end end
win()
click to toggle source
# File lib/app/entities/console.rb, line 70 def win output.win save_result start_new_game end