lib/alex_codebreaker/session.rb in alex_codebreaker-0.1.7 vs lib/alex_codebreaker/session.rb in alex_codebreaker-0.1.8
- old
+ new
@@ -16,13 +16,17 @@
def add_name(given_name)
@player_name = given_name if name_validation(given_name)
end
def add_difficulty(difficulty)
- return unless AlexCodebreaker::Modules::DifficultyLevels::DIFFICULTY_LEVELS.include?(difficulty.downcase.to_sym)
+ difficulty_level = AlexCodebreaker::Modules::DifficultyLevels::DIFFICULTY_LEVELS[difficulty.downcase.to_sym]
+ return unless difficulty_level
- difficulty(AlexCodebreaker::Modules::DifficultyLevels::DIFFICULTY_LEVELS[difficulty.downcase.to_sym])
+ @difficulty_name = difficulty_level[:name]
+ @difficulty_level = difficulty_level[:level]
+ @attempts_total = difficulty_level[:attempts_total]
+ @hints_total = difficulty_level[:hints_total]
end
def check_hints
@hints_used += 1 if @hints_used < @hints_total
end
@@ -31,17 +35,8 @@
@attempts_used += 1 if @attempts_used < @attempts_total - 1
end
def save_statistic
File.open(AlexCodebreaker::Modules::Files::STATS_FILE, 'a') { |file| file.write(to_yaml) }
- end
-
- private
-
- def difficulty(difficulty)
- @difficulty_name = difficulty[:name]
- @difficulty_level = difficulty[:level]
- @attempts_total = difficulty[:attempts_total]
- @hints_total = difficulty[:hints_total]
end
end
end