lib/codebreaker/codebreaker.rb in codebreaker-engine-0.1.5 vs lib/codebreaker/codebreaker.rb in codebreaker-engine-0.1.6

- old
+ new

@@ -1,10 +1,10 @@ class CodeBreaker extend CodebreakerApi include Validation - attr_reader :attempts, :name, :difficulty, :hints + attr_reader :attempts LEVEL = { easy: { attempts: 15, hints: 2, difficulty: :easy }, middle: { attempts: 10, @@ -13,11 +13,11 @@ hell: { attempts: 5, hints: 1, difficulty: :hell } }.freeze def self.stats - CodeBreaker.load || [] + CodeBreaker.stats_base || [] end def initialize(name, chose_level) @codemaker = CodeMaker.new @attempts = LEVEL.dig(chose_level, :attempts) @@ -31,26 +31,20 @@ raise CustomErrors::NameInvalidError unless validate_name(name) @name = name.capitalize end - - def check_code(code) @codemaker.verify(code) dicrement_attemts unless win? save_stats if game_end? - result_code - end - - def result_code @codemaker.verified_code end def hint return unless hint? - res = @hint_cache.each_with_object(@codemaker.code.dup) do |index, object| + res = @hint_cache.each_with_object(@codemaker.code) do |index, object| object.delete_at(index) end index = rand(0..3) @hint_cache << index @hints -= 1