checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: ac06d8b9d0d3f2d7945afb251704c20a4b714d11889ebcdc7c380e939523fa4d
4
- data.tar.gz: f735a06aaf9a60afae5180d53b627c7e885bd308c6c3e549967300162986087d
3
+ metadata.gz: 65f81d2ecb7263634807f5d042e8d513534dcf7420dd8469e77672078860060b
4
+ data.tar.gz: c30e98b582e54cf7adea32993e74e9033359b532183a98de51f95b6a2025b2a0
5
5
SHA512:
6
- metadata.gz: a5ee989b70f7df009e0ba50a34c95fe1790c8e202a8c0034758c478764bf8255ae4011fb57e3ef99842f194f2c772307fa1292aabff4f8e19ef737ffbe2389ac
7
- data.tar.gz: 1ed3a127d84345a67e1252c6a800ef0ee16acfd0007a70784e34d36df8df6091807e060896ae6be43777af69a12e41c9dd65c9cd1839d94244c57dd9b95e0874
6
+ metadata.gz: 3677c98735935df4d0cb7b48c864a59489138eec00bc7370aa54ae4fe4a2c5927f4087710840a352416d1d9ef4cbd2484aa26b91c21e4be55f836b2b6a6efe6e
7
+ data.tar.gz: d5d987b906b62309208b98ca1339c29cd867809e6ff468d873a006e9bee5fd549748af18aab2c341868c2ffa0bfe7ebe11ce5153650ad329ef5e93d7b85fb786
data/Gemfile.lock DELETED
@@ -1,73 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- gem_codebreaker_amidasd (0.1.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.0)
10
- coderay (1.1.2)
11
- colorize (0.8.1)
12
- diff-lcs (1.3)
13
- docile (1.3.2)
14
- fasterer (0.5.1)
15
- colorize (~> 0.7)
16
- ruby_parser (>= 3.13.0)
17
- jaro_winkler (1.5.3)
18
- json (2.2.0)
19
- method_source (0.9.2)
20
- parallel (1.17.0)
21
- parser (2.6.3.0)
22
- ast (~> 2.4.0)
23
- pry (0.12.2)
24
- coderay (~> 1.1.0)
25
- method_source (~> 0.9.0)
26
- rainbow (3.0.0)
27
- rake (10.5.0)
28
- rspec (3.8.0)
29
- rspec-core (~> 3.8.0)
30
- rspec-expectations (~> 3.8.0)
31
- rspec-mocks (~> 3.8.0)
32
- rspec-core (3.8.2)
33
- rspec-support (~> 3.8.0)
34
- rspec-expectations (3.8.4)
35
- diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.8.0)
37
- rspec-mocks (3.8.1)
38
- diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.8.0)
40
- rspec-support (3.8.2)
41
- rubocop (0.69.0)
42
- jaro_winkler (~> 1.5.1)
43
- parallel (~> 1.10)
44
- parser (>= 2.6)
45
- rainbow (>= 2.2.2, < 4.0)
46
- ruby-progressbar (~> 1.7)
47
- unicode-display_width (>= 1.4.0, < 1.7)
48
- ruby-progressbar (1.10.1)
49
- ruby_parser (3.13.1)
50
- sexp_processor (~> 4.9)
51
- sexp_processor (4.12.1)
52
- simplecov (0.16.1)
53
- docile (~> 1.1)
54
- json (>= 1.8, < 3)
55
- simplecov-html (~> 0.10.0)
56
- simplecov-html (0.10.2)
57
- unicode-display_width (1.6.0)
58
-
59
- PLATFORMS
60
- ruby
61
-
62
- DEPENDENCIES
63
- bundler (~> 2.0)
64
- fasterer (~> 0.5.1)
65
- gem_codebreaker_amidasd!
66
- pry (~> 0.12.2)
67
- rake (~> 10.0)
68
- rspec (~> 3.8)
69
- rubocop (~> 0.69.0)
70
- simplecov (~> 0.16.1)
71
-
72
- BUNDLED WITH
73
- 2.0.1
data/gem_codebreaker_amidasd-0.1.3.gem ADDED
Binary file
data/gem_codebreaker_amidasd-0.1.4.gem ADDED
Binary file
data/lib/gem_codebreaker_amidasd.rb CHANGED
@@ -1,7 +1,4 @@
1
1
require 'gem_codebreaker_amidasd/version'
2
+ require 'gem_codebreaker_amidasd/db_utility'
3
+ require 'gem_codebreaker_amidasd/user'
2
4
require 'gem_codebreaker_amidasd/gem_codebreaker'
3
-
4
- # module GemCodebreakerAmidasd
5
- # # class Error < StandardError; end
6
- # #
7
- # # end
data/lib/gem_codebreaker_amidasd/db_utility.rb CHANGED
@@ -1,25 +1,25 @@
1
1
module GemCodebreakerAmidasd
2
- class DbUtility
2
+ require 'yaml'
3
- class << self
4
- def save_yaml_db(user, yml_db)
5
- # yml_db = CodebreakerConfig::PATH_DB
6
- File.write(yml_db, user.to_yaml)
7
- end
8
3
9
- def load_yaml_db(yml_db)
10
- # yml_db = CodebreakerConfig::PATH_DB
11
- return unless File.exist?(yml_db)
4
+ class DbUtility
5
+ class << self
6
+ def save_yaml_db(user, yml_db)
7
+ File.write(yml_db, user.to_yaml)
8
+ end
12
9
13
- YAML.load_file(yml_db)
14
- end
10
+ def load_yaml_db(yml_db)
11
+ return unless File.exist?(yml_db)
12
+
13
+ YAML.load_file(yml_db)
14
+ end
15
15
16
- def add_db(user, path)
17
- db = load_yaml_db(path)
18
- db ||= []
19
- db << (user)
20
- db = db.sort_by { |value| [value.total_count_attempt, value.count_attempt, value.count_hint] }
21
- save_yaml_db(db, path)
16
+ def add_db(user, path)
17
+ db = load_yaml_db(path)
18
+ db ||= []
19
+ db << user
20
+ db = db.sort_by { |value| [value.total_count_attempt, value.count_attempt, value.count_hint] }
21
+ save_yaml_db(db, path)
22
+ end
22
23
end
23
24
end
24
25
end
25
- end
data/lib/gem_codebreaker_amidasd/gem_codebreaker.rb CHANGED
@@ -1,10 +1,9 @@
1
1
module GemCodebreakerAmidasd
2
- DIFFICULTY_HASH = {:easy => { total_count_attempt: 15, total_count_hints: 2 },
3
- :medium => { total_count_attempt: 10, total_count_hints: 1 },
4
- :hell => { total_count_attempt: 5, total_count_hints: 1 }}
2
+ DIFFICULTY_HASH = { easy: { total_count_attempt: 15, total_count_hints: 2 },
3
+ medium: { total_count_attempt: 10, total_count_hints: 1 },
4
+ hell: { total_count_attempt: 5, total_count_hints: 1 } }.freeze
5
5
6
6
class GemCodebreaker
7
-
8
7
attr_accessor :difficulty_hash, :difficulty
9
8
attr_accessor :length_code, :max_num, :min_num
10
9
attr_reader :total_count_attempt, :total_count_hints, :error, :win, :count_plus, :count_minus, :hint
@@ -21,12 +20,13 @@ module GemCodebreakerAmidasd
21
20
empty_result
22
21
end
23
22
24
- def string_secertcode
23
+ def string_secretcode
25
24
@secret_code.join('')
26
25
end
27
26
28
27
def set_difficulty(difficulty)
29
- return unless @difficulty_hash.has_key? difficulty
28
+ return unless @difficulty_hash.key? difficulty
29
+
30
30
@difficulty = difficulty
31
31
@total_count_attempt = @difficulty_hash[difficulty][:total_count_attempt]
32
32
@total_count_hints = @difficulty_hash[difficulty][:total_count_hints]
@@ -71,17 +71,17 @@ module GemCodebreakerAmidasd
71
71
def search_hint
72
72
cache_array = []
73
73
@secret_code.each { |val| cache_array << val if !@array_hints.include?(val) && !cache_array.include?(val) }
74
- @error = 'HintsEnd' unless @total_count_hints > @array_hints.size
75
- @error = 'NoCluesAvailable' if cache_array.empty?
74
+ @error = :HintsEnd unless @total_count_hints > @array_hints.size
75
+ @error = :NoCluesAvailable if cache_array.empty?
76
76
cache_array
77
77
end
78
78
79
79
def check_code(code_attempt)
80
80
correct_code = to_array(code_attempt)
81
81
empty_result
82
- @error = 'WrongCode' unless code_attempt.match(/[1-6]+#x2F;)
83
- @error = 'WrongCode' unless correct_code.size == @length_code
84
- return nil if @error == 'WrongCode'
82
+ @error = :WrongCode unless code_attempt.match(/[1-6]+#x2F;)
83
+ @error = :WrongCode unless correct_code.size == @length_code
84
+ return nil if @error == :WrongCode
85
85
86
86
status_game(correct_code)
87
87
@count_attempt += 1
data/lib/gem_codebreaker_amidasd/user.rb CHANGED
@@ -1,27 +1,26 @@
1
1
module GemCodebreakerAmidasd
2
- class User
3
- attr_accessor :name,
4
- :difficulty,
5
- :total_count_attempt,
6
- :count_attempt,
7
- :total_count_hints,
8
- :count_hint
2
+ class User
3
+ attr_accessor :name,
4
+ :difficulty,
5
+ :total_count_attempt,
6
+ :count_attempt,
7
+ :total_count_hints,
8
+ :count_hint
9
9
10
- def initialize(name:)
11
- @name = name
12
- end
10
+ def initialize(name:)
11
+ @name = name
12
+ end
13
13
14
- def set_params(difficulty:, total_count_attempt:, count_attempt:, total_count_hints:,count_hint:)
15
- @difficulty = difficulty
16
- @total_count_attempt = total_count_attempt
17
- @count_attempt = count_attempt
18
- @total_count_hints = total_count_hints
19
- @count_hint = count_hint
20
- end
14
+ def set_params(difficulty:, total_count_attempt:, count_attempt:, total_count_hints:, count_hint:)
15
+ @difficulty = difficulty
16
+ @total_count_attempt = total_count_attempt
17
+ @count_attempt = count_attempt
18
+ @total_count_hints = total_count_hints
19
+ @count_hint = count_hint
20
+ end
21
21
22
- def self.validtion_name(name)
23
- name.is_a?(String) && !name.empty? && name.length.between?(3, 20)
22
+ def self.validtion_name(name)
23
+ name.is_a?(String) && !name.empty? && name.length.between?(3, 20)
24
+ end
24
25
end
25
-
26
26
end
27
- end
data/lib/gem_codebreaker_amidasd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
module GemCodebreakerAmidasd
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: gem_codebreaker_amidasd
3
3
version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
platform: ruby
6
6
authors:
7
7
- Amidasd
8
8
autorequire:
9
9
bindir: exe
10
10
cert_chain: []
11
- date: 2019-08-12 00:00:00.000000000 Z
11
+ date: 2019-08-14 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: bundler
@@ -122,7 +122,6 @@ files:
122
122
- ".travis.yml"
123
123
- CODE_OF_CONDUCT.md
124
124
- Gemfile
125
- - Gemfile.lock
126
125
- LICENSE.txt
127
126
- README.md
128
127
- Rakefile
@@ -132,6 +131,8 @@ files:
132
131
- gem_codebreaker_amidasd-0.1.0.gem
133
132
- gem_codebreaker_amidasd-0.1.1.gem
134
133
- gem_codebreaker_amidasd-0.1.2.gem
134
+ - gem_codebreaker_amidasd-0.1.3.gem
135
+ - gem_codebreaker_amidasd-0.1.4.gem
135
136
- gem_codebreaker_amidasd.gemspec
136
137
- lib/gem_codebreaker_amidasd.rb
137
138
- lib/gem_codebreaker_amidasd/db_utility.rb