icodebreaker_gem 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 042dbedd8e000d620a90aa17a91afc3f08bd64e486e7e06df12a409919503d57
4
- data.tar.gz: 40b79540a1bb21afb573b0ae671bb7d9fb05ccd53e6d82f33287a961329106f6
3
+ metadata.gz: 77686e016570a9a327c2588bdfc2d36d0a09b418b58081e827b2dd671058fe6a
4
+ data.tar.gz: 41071cc2d0f4fba6a345b0f9bab8cab982d45c7b91817514e1cfd3828d7865aa
5
5
  SHA512:
6
- metadata.gz: 600c4497bd0c6af0cb66ce0e6d26c8c4f8da62cb15b8b136ab4217676d8c74d137c904d7142c2077cec076e549b534d737cefb25c690d19a8c1db04132979642
7
- data.tar.gz: 15f30eeb6037b8329fba8f12baeaadb1c6a10158ab14fa5dc17fdb697815149e0f0e724cd3b012df4afb019c7d581f7f20844153f628fd0b7f3e8d858fcde79b
6
+ metadata.gz: 9ac145ebb5fb673c36f6bf801d4e638d6fbc24550ccc5ee5442e65576ece7ce4332ec8fa74cc721cba6fdef4c8c1e878aacdddb4cebda5f63b03b192ae964eae
7
+ data.tar.gz: d9c6fcf607a08a56433888bec900a0af213a6f3adb6cb176a5737fe34623ae1fe3e5f0ae5148dbc00d45c6d267829e47fb6af452c74f8fcf30fe57816d2095e3
data/.rspec_status CHANGED
@@ -1,30 +1,30 @@
1
1
  example_id | status | run_time |
2
2
  ------------------------------------ | ------ | --------------- |
3
3
  ./spec/game_core_spec.rb[1:1] | passed | 0.00023 seconds |
4
- ./spec/game_core_spec.rb[1:2] | passed | 0.00073 seconds |
4
+ ./spec/game_core_spec.rb[1:2] | passed | 0.00066 seconds |
5
5
  ./spec/game_core_spec.rb[1:3:1] | passed | 0.00034 seconds |
6
- ./spec/game_core_spec.rb[1:4:1] | passed | 0.00055 seconds |
7
- ./spec/game_core_spec.rb[1:5:1:1] | passed | 0.00008 seconds |
8
- ./spec/game_core_spec.rb[1:5:1:2] | passed | 0.0001 seconds |
9
- ./spec/game_core_spec.rb[1:5:1:3] | passed | 0.00008 seconds |
10
- ./spec/game_core_spec.rb[1:5:1:4] | passed | 0.0001 seconds |
11
- ./spec/game_core_spec.rb[1:5:1:5] | passed | 0.00005 seconds |
12
- ./spec/game_core_spec.rb[1:5:1:6] | passed | 0.00005 seconds |
6
+ ./spec/game_core_spec.rb[1:4:1] | passed | 0.00053 seconds |
7
+ ./spec/game_core_spec.rb[1:5:1:1] | passed | 0.00011 seconds |
8
+ ./spec/game_core_spec.rb[1:5:1:2] | passed | 0.00006 seconds |
9
+ ./spec/game_core_spec.rb[1:5:1:3] | passed | 0.00006 seconds |
10
+ ./spec/game_core_spec.rb[1:5:1:4] | passed | 0.00006 seconds |
11
+ ./spec/game_core_spec.rb[1:5:1:5] | passed | 0.00008 seconds |
12
+ ./spec/game_core_spec.rb[1:5:1:6] | passed | 0.00006 seconds |
13
13
  ./spec/game_core_spec.rb[1:5:1:7] | passed | 0.00004 seconds |
14
14
  ./spec/game_core_spec.rb[1:5:2:1] | passed | 0.00005 seconds |
15
- ./spec/game_core_spec.rb[1:5:2:2] | passed | 0.00005 seconds |
15
+ ./spec/game_core_spec.rb[1:5:2:2] | passed | 0.00006 seconds |
16
16
  ./spec/game_core_spec.rb[1:5:3:1] | passed | 0.00005 seconds |
17
- ./spec/game_core_spec.rb[1:5:3:2] | passed | 0.00005 seconds |
18
- ./spec/game_core_spec.rb[1:5:3:3] | passed | 0.00007 seconds |
19
- ./spec/game_spec.rb[1:1:1] | passed | 0.00013 seconds |
20
- ./spec/game_spec.rb[1:2:1] | passed | 0.00025 seconds |
21
- ./spec/game_spec.rb[1:2:2] | passed | 0.00006 seconds |
22
- ./spec/game_spec.rb[1:2:3] | passed | 0.00006 seconds |
23
- ./spec/game_spec.rb[1:2:4] | passed | 0.00006 seconds |
24
- ./spec/game_spec.rb[1:2:5] | passed | 0.00006 seconds |
25
- ./spec/game_spec.rb[1:3:1] | passed | 0.00039 seconds |
26
- ./spec/game_spec.rb[1:3:2] | passed | 0.00018 seconds |
17
+ ./spec/game_core_spec.rb[1:5:3:2] | passed | 0.00004 seconds |
18
+ ./spec/game_core_spec.rb[1:5:3:3] | passed | 0.00004 seconds |
19
+ ./spec/game_spec.rb[1:1:1] | passed | 0.0001 seconds |
20
+ ./spec/game_spec.rb[1:2:1] | passed | 0.0002 seconds |
21
+ ./spec/game_spec.rb[1:2:2] | passed | 0.00008 seconds |
22
+ ./spec/game_spec.rb[1:2:3] | passed | 0.00007 seconds |
23
+ ./spec/game_spec.rb[1:2:4] | passed | 0.00008 seconds |
24
+ ./spec/game_spec.rb[1:2:5] | passed | 0.00005 seconds |
25
+ ./spec/game_spec.rb[1:3:1] | passed | 0.00034 seconds |
26
+ ./spec/game_spec.rb[1:3:2] | passed | 0.00017 seconds |
27
27
  ./spec/game_spec.rb[1:3:3] | passed | 0.00014 seconds |
28
- ./spec/game_spec.rb[1:4:1] | passed | 0.00011 seconds |
29
- ./spec/game_spec.rb[1:5:1] | passed | 0.00112 seconds |
30
- ./spec/icodebreaker_gem_spec.rb[1:1] | passed | 0.00008 seconds |
28
+ ./spec/game_spec.rb[1:4:1] | passed | 0.00014 seconds |
29
+ ./spec/game_spec.rb[1:5:1] | passed | 0.00104 seconds |
30
+ ./spec/icodebreaker_gem_spec.rb[1:1] | passed | 0.00007 seconds |
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- icodebreaker_gem (0.2.2)
4
+ icodebreaker_gem (0.3.0)
5
5
  rake (~> 13.0)
6
6
 
7
7
  GEM
data/lib/config.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
3
  require 'yaml'
5
4
 
6
5
  require_relative 'modules/validation'
data/lib/game_core.rb CHANGED
@@ -4,19 +4,16 @@ module IcodebreakerGem
4
4
  class GameCore
5
5
  include Validation
6
6
 
7
- attr_reader :secret
8
-
9
7
  def initialize(secret)
10
8
  validate_code secret
11
9
 
12
10
  @secret = secret.to_s
13
- @shuffle = @secret.each_char.to_a.shuffle
14
- @hint_idx = 0
11
+ @shuffle = @secret.chars.shuffle
15
12
  end
16
13
 
17
14
  def compare(guess)
18
15
  return '++++' if @secret == guess
19
- return '' if (@secret.each_char.to_a & guess.each_char.to_a).empty?
16
+ return '' if (@secret.chars & guess.chars).blank?
20
17
 
21
18
  pluses1, minuses1 = pluses_and_minuses(@secret, guess)
22
19
 
@@ -26,24 +23,21 @@ module IcodebreakerGem
26
23
  end
27
24
 
28
25
  def hint
29
- result = @shuffle[@hint_idx]
30
- @hint_idx += 1
31
- @hint_idx = 0 if @hint_idx >= @shuffle.size
32
- result
26
+ @shuffle.pop
33
27
  end
34
28
 
35
29
  def self.random
36
- (0..3).map { rand(1..6) }.map(&:to_s).join
30
+ (0..3).map { rand(1..6) }.join
37
31
  end
38
32
 
39
33
  private
40
34
 
41
- def pluses_and_minuses(word1, word2)
35
+ def pluses_and_minuses(guess_secret, secret_guess)
42
36
  pluses = minuses = 0
43
- word1.each_char.to_a.each_index do |index|
44
- if word2[index] == word1[index]
37
+ guess_secret.chars.each_index do |index|
38
+ if secret_guess[index] == guess_secret[index]
45
39
  pluses += 1
46
- elsif word2.include? word1[index]
40
+ elsif secret_guess.include? guess_secret[index]
47
41
  minuses += 1
48
42
  end
49
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IcodebreakerGem
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -2,7 +2,4 @@
2
2
 
3
3
  require_relative 'icodebreaker_gem/version'
4
4
  require_relative 'config'
5
- module IcodebreakerGem
6
- class Error < StandardError; end
7
- # Your code goes here...
8
- end
5
+ module IcodebreakerGem end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icodebreaker_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JohnnyGsy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-27 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -124,6 +124,7 @@ files:
124
124
  - lib/modules/storage.rb
125
125
  - lib/modules/validation.rb
126
126
  - reek.yml
127
+ - storage/codebreakers.yml
127
128
  homepage: https://github.com/JohnnyGsy/icodebreaker_gem
128
129
  licenses:
129
130
  - MIT