codebreaker_kirill 0.2.12 → 0.2.13

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: 0ec08f93cc594d4d2bba8f889b64239f032cc6a4c80fb9dab8b662937da56db0
4
- data.tar.gz: 937f0f2cbec8314935a1a08f856b9d965fb86b83541d7f2b183f2f3fa1c90247
3
+ metadata.gz: 29bb8deb5b88bc6d24768d6fd678027be29fe77dece02f153434b65aa8080aba
4
+ data.tar.gz: 6d3d7aed857fd189ff9d55c4e27f37a32feffb320f57701273b0ce574a2a5948
5
5
  SHA512:
6
- metadata.gz: 730e044734ce4b4308a00f426b0c17081a98e7b86d894257350863ca6c234ab191bf5723e8b3fcd49a6881f33571324d6063f81ab68c8ad55ea40c1d9563d6d4
7
- data.tar.gz: 92e0936a01317cfe7452e6c6c97c89c44ef53e2c56d82e8946e3e947ce57f0378fe8364a39940b00cc9dec0458479e77cfe63d47f58e299c7768f367577aee5b
6
+ metadata.gz: f8f92771e599a13813c0661d7886c71fc2f1f03085d56a29f120d73aec303c6a1acce651a50cc49162b0c2411c0a453018647c127bb503072d85fb834446ee06
7
+ data.tar.gz: 86f196bb9e4f8e002de8f529a9ba43fce93d490a18878ea5c22d77919ad9413b0f17d23c6769fc000485b6e18b1be426ba72652e48431e645ff5c74db4d6e0d6
@@ -24,14 +24,3 @@ class Game
24
24
  @secret_code[@hints[:used]]
25
25
  end
26
26
  end
27
-
28
- game = Game.new(User.new("kirill"), { attempts: 10, hints: 2 })
29
- print game.respond_to_guess(game, "2222", [1,2,3,4]) # +
30
- print game.respond_to_guess(game, "2222", [2,2,2,4]) # +++
31
- print game.respond_to_guess(game, "2211", [1,2,3,4]) # +-
32
- print game.respond_to_guess(game, "2221", [1,2,3,2]) # +--
33
- print game.respond_to_guess(game, "1212", [2,1,2,1]) # ----
34
- print game.respond_to_guess(game, "6666", [1,1,1,1]) # []
35
- print game.respond_to_guess(game, "6666", [6,6,6,6]) # win
36
- print game.respond_to_guess(game, "1234", [5,3,6,3]) # -
37
- print game.respond_to_guess(game, "5363", [1,2,3,4]) # -
@@ -8,17 +8,22 @@ module GuessHandler
8
8
  return 'win' if @numbers == code
9
9
 
10
10
  assess_guess(@code_clone, @numbers)
11
+
11
12
  game.attempts[:used] += 1
12
13
  game.attempts[:used] >= game.attempts[:all] ? 'loss' : @result.delete_if { |value| (1..6).include?(value) }.sort
13
14
  end
14
15
 
15
16
  def assess_guess(code, input)
16
- input.each_with_index { |element, index| @code_clone[index] = '+' if element == @code_clone[index] }
17
+ @numbers.each_with_index do |element, index|
18
+ if element == code[index]
19
+ code[index] = '+'
20
+ input[@numbers.index(element)] = '' end
21
+ end
22
+
17
23
  @result = code.each_with_index do |el, index|
18
- if input.include?(el)
19
- @code_clone[index] = '-'
20
- input.slice!(@numbers.index(el))
21
- end
24
+ if @numbers.include?(el)
25
+ code[index] = '-'
26
+ input.slice!(@numbers.index(el)) end
22
27
  end
23
28
  end
24
29
  end
@@ -3,5 +3,5 @@
3
3
  require_relative 'game'
4
4
 
5
5
  module CodebreakerKirill
6
- VERSION = '0.2.12'
6
+ VERSION = '0.2.13'
7
7
  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: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Dudchenko