codebreaker_kirill 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd8e9ef96c5584a34b2ac7986f2405468d91be72b4e7575bfbab1723a2252fc1
4
- data.tar.gz: 8d011efcb4905860d969d48929922997a2298953ee66b0a249b17ca99168d7ab
3
+ metadata.gz: 0d381ca0ecc5440b2063aa692e02192368f741f27b44fd678c5eb0729eb935df
4
+ data.tar.gz: 3c36ca48dc8046969f0139aa0f238d40e38f77f73195239ada18823316c41d2b
5
5
  SHA512:
6
- metadata.gz: 52e0e98384554272f56815c482e2779b0e1a0c33b436b9f47113460cf7826129fdb5d43840ec424c2ee1f54feeb497256a9b7699bd063acb74b8a5bdd3877162
7
- data.tar.gz: 851384f6e97f45855d6db4ae58a6fa730bbfc3622d96b8b9d4d0393efcdcba5949966a4bedbb12ce5fa110d6e74c47cfd0aab359fb48c714100a195d2612c015
6
+ metadata.gz: 56a8099ed5080f44437ab21d10522f77deb91a3f9c3d6b085565b8214ffb027b7e0f859843621f02811daba693a10df97b739656ad71c1adc7be25fe630e2aa6
7
+ data.tar.gz: a5e9aa99ceb5cba104b179023f5b4907efb950c8887ee17a3b99f9ecb3f75728b24a9203adf6922cc271964d6cae23bc2fdd2b3c670ce2a3ad890313c068ec09
@@ -3,7 +3,7 @@
3
3
  module CodebreakerKirill
4
4
  module CodeGenerator
5
5
  def self.call
6
- Array.new(CodebreakerKirill::Settings::CODE_LENGTH) { rand(CodebreakerKirill::Settings::RANDOM_RANGE) }
6
+ Array.new(Settings::CODE_LENGTH) { rand(Settings::RANDOM_RANGE) }
7
7
  end
8
8
  end
9
9
  end
@@ -9,7 +9,7 @@ module CodebreakerKirill
9
9
  attr_reader :user
10
10
 
11
11
  def initialize(user)
12
- @secret_code = CodebreakerKirill::CodeGenerator.call
12
+ @secret_code = CodeGenerator.call
13
13
  @user = user
14
14
  end
15
15
 
@@ -23,7 +23,7 @@ module CodebreakerKirill
23
23
  def respond_to_guess(input)
24
24
  @user.attempts_used += 1
25
25
  status = status(input, @secret_code)
26
- resolved_code = CodebreakerKirill::GuessHandler.new(input, @secret_code).call
26
+ resolved_code = GuessHandler.new(input, @secret_code).call
27
27
  return { status: status, secret_code: @secret_code } if status == 'loss'
28
28
 
29
29
  { status: status, response: resolved_code, secret_code: @secret_code }
@@ -7,7 +7,7 @@ module CodebreakerKirill
7
7
  include Settings
8
8
 
9
9
  def initialize(input, code)
10
- CodebreakerKirill::Validations.validate_guess(input)
10
+ Validations.validate_guess(input)
11
11
  @input = input.each_char.map(&:to_i)
12
12
  @code = code.clone
13
13
  @result = []
@@ -23,7 +23,7 @@ module CodebreakerKirill
23
23
  @input.each_index do |index|
24
24
  next unless @input[index] == @code[index]
25
25
 
26
- @result << CodebreakerKirill::Settings::POSITIVE_RESPONSE
26
+ @result << Settings::POSITIVE_RESPONSE
27
27
  @input[index], @code[index] = nil
28
28
  end
29
29
  end
@@ -32,7 +32,7 @@ module CodebreakerKirill
32
32
  @input.each_with_index do |value, _index|
33
33
  next unless !value.nil? && @code.include?(value)
34
34
 
35
- @result << CodebreakerKirill::Settings::NEGATIVE_RESPONSE
35
+ @result << Settings::NEGATIVE_RESPONSE
36
36
  @input[@input.find_index(value)], @code[@code.find_index(value)] = nil
37
37
  end
38
38
  end
@@ -13,14 +13,14 @@ module CodebreakerKirill
13
13
  validation(name, difficulty)
14
14
  @difficulty = difficulty
15
15
  @name = name
16
- @level = CodebreakerKirill::Settings::DIFFICULTY[@difficulty]
16
+ @level = Settings::DIFFICULTY[@difficulty]
17
17
  @attempts_used = 0
18
18
  @hints_used = 0
19
19
  end
20
20
 
21
21
  def validation(name, difficulty)
22
- CodebreakerKirill::Validations.validate_name(name)
23
- CodebreakerKirill::Validations.validate_difficulty(difficulty)
22
+ Validations.validate_name(name)
23
+ Validations.validate_difficulty(difficulty)
24
24
  end
25
25
  end
26
26
  end
@@ -9,21 +9,21 @@ module CodebreakerKirill
9
9
  def self.validate_name(name)
10
10
  raise "Name shouldn't be empty" if name.empty?
11
11
  raise 'Name should be string' if name.class != String
12
- raise 'Name should be at least 3 characters long' if name.length < CodebreakerKirill::Settings::NAME_MIN_LENGTH
12
+ raise 'Name should be at least 3 characters long' if name.length < Settings::NAME_MIN_LENGTH
13
13
  raise "Name shouldn't be more than 20 characters long" if name.length > Settings::NAME_MAX_LENGTH
14
14
  end
15
15
 
16
16
  def self.validate_guess(guess)
17
17
  raise "Guess shouldn't be empty" if guess.empty?
18
- raise 'Guess should be 4 characters' if guess.length < CodebreakerKirill::Settings::GUESS_LENGTH
19
- raise 'Guess shouldnt be more than 4 characters long' if guess.length > CodebreakerKirill::Settings::GUESS_LENGTH
18
+ raise 'Guess should be 4 characters' if guess.length < Settings::GUESS_LENGTH
19
+ raise 'Guess shouldnt be more than 4 characters long' if guess.length > Settings::GUESS_LENGTH
20
20
  end
21
21
 
22
22
  def self.validate_difficulty(difficulty)
23
23
  raise "Input shouldn't be empty" if difficulty.empty?
24
- return if CodebreakerKirill::Settings::DIFFICULTY.keys.include?(difficulty)
24
+ return if Settings::DIFFICULTY.keys.include?(difficulty)
25
25
 
26
- raise "You should enter one of the following options: #{CodebreakerKirill::Settings::DIFFICULTY.keys.join(', ')}"
26
+ raise "You should enter one of the following options: #{Settings::DIFFICULTY.keys.join(', ')}"
27
27
  end
28
28
  end
29
29
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'game'
4
-
5
3
  module CodebreakerKirill
6
- VERSION = '1.3.3'
4
+ VERSION = '1.3.4'
7
5
  end
@@ -6,6 +6,3 @@ require_relative 'codebreaker_kirill/guess_handler'
6
6
  require_relative 'codebreaker_kirill/user'
7
7
  require_relative 'codebreaker_kirill/game'
8
8
  require_relative 'codebreaker_kirill/stats'
9
-
10
- module CodebreakerKirill
11
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebreaker_kirill
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Dudchenko