class Session INITIAL_ATTEMPTS_USED = 0 INITIAL_HINTS_USED = 0 attr_accessor :player_name, :attempts_used, :hints_used, :hints_total, :difficulty_name, :attempts_total, :difficulty_level def initialize @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 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) end end private def add_difficulty(difficulty) @difficulty_name = difficulty[:name] @difficulty_level = difficulty[:level] @attempts_total = difficulty[:attempts_total] @hints_total = difficulty[:hints_total] end end