Sha256: 455a2ef936bee734530cf51ed0f50f4ece28961eda6cfa9d8fdb0c549b5a1917
Contents?: true
Size: 932 Bytes
Versions: 1
Compression:
Stored size: 932 Bytes
Contents
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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alex_codebreaker-0.1.6 | lib/alex_codebreaker/session.rb |