lib/alex_codebreaker/session.rb in alex_codebreaker-0.1.4 vs lib/alex_codebreaker/session.rb in alex_codebreaker-0.1.5

- old
+ new

@@ -1,19 +1,22 @@ class Session + INITIAL_ATTEMPTS_USED = 0 + INITIAL_HINTS_USED = 0 + attr_reader :difficulty_name, :difficulty_level, :attempts_total, :hints_total attr_accessor :player_name, :attempts_used, :hints_used def initialize - @attempts_used = 0 - @hints_used = 0 + @attempts_used = INITIAL_ATTEMPTS_USED + @hints_used = INITIAL_HINTS_USED end def difficulty_manager(difficulty) if DifficultyLevels::DIFFICULTY_LEVELS.include?(difficulty) add_difficulty(DifficultyLevels::DIFFICULTY_LEVELS[difficulty]) end - raise WrongDifficulty unless DifficultyLevels::DIFFICULTY_LEVELS.include?(difficulty) + return false unless DifficultyLevels::DIFFICULTY_LEVELS.include?(difficulty) end def save_session_statistic File.open(Files::STATS_FILE, 'a') do |file| file.write(to_yaml)