lib/game.rb in codebreaker_al-0.1.1 vs lib/game.rb in codebreaker_al-0.1.2
- old
+ new
@@ -9,11 +9,11 @@
attr_reader :secret_code
public
attr_reader :user, :attempts, :total_attempts, :hints, :total_hints, :level
- attr_accessor :status
+ attr_accessor :status, :taken_hints
GAME_DIFFICULTIES = { simple: { attempts: 15, hints: 2 }, medium: { attempts: 10, hints: 1 },
hell: { attempts: 5, hints: 1 } }.freeze
WIN = :win
LOSS = :loss
@@ -24,10 +24,11 @@
def initialize(user_name)
@user = User.new(user_name)
@secret_code = SecretCode.new(generate_secret_code).value
@status = nil
+ @taken_hints = []
end
def add_hints_attempts(level)
@level = level.to_sym
@total_attempts = Game::GAME_DIFFICULTIES[@level][:attempts]
@@ -39,10 +40,11 @@
def take_hint
raise I18n.t(:out_of_hints) if @hints.zero?
@hints -= 1
- @secret_code.digits.shuffle.pop
+ @taken_hints << @secret_code.digits.shuffle.pop
+ @taken_hints.last
end
def guess(user_variant)
return @status = Game::LOSS if @attempts.zero?