gem_codebreaker_amidasd 0.1.3 → 0.1.5
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 +4 -4
- data/gem_codebreaker_amidasd-0.1.3.gem +0 -0
- data/gem_codebreaker_amidasd-0.1.4.gem +0 -0
- data/lib/gem_codebreaker_amidasd.rb +2 -5
- data/lib/gem_codebreaker_amidasd/db_utility.rb +18 -18
- data/lib/gem_codebreaker_amidasd/gem_codebreaker.rb +11 -11
- data/lib/gem_codebreaker_amidasd/user.rb +20 -21
- data/lib/gem_codebreaker_amidasd/version.rb +1 -1
- metadata +4 -3
- data/Gemfile.lock +0 -73
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 65f81d2ecb7263634807f5d042e8d513534dcf7420dd8469e77672078860060b
|
|
4
|
+
data.tar.gz: c30e98b582e54cf7adea32993e74e9033359b532183a98de51f95b6a2025b2a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3677c98735935df4d0cb7b48c864a59489138eec00bc7370aa54ae4fe4a2c5927f4087710840a352416d1d9ef4cbd2484aa26b91c21e4be55f836b2b6a6efe6e
|
|
7
|
+
data.tar.gz: d5d987b906b62309208b98ca1339c29cd867809e6ff468d873a006e9bee5fd549748af18aab2c341868c2ffa0bfe7ebe11ce5153650ad329ef5e93d7b85fb786
|
|
Binary file
|
|
Binary file
|
|
@@ -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
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
module GemCodebreakerAmidasd
|
|
2
|
-
|
|
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
|
|
2
|
+
require 'yaml'
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
module GemCodebreakerAmidasd
|
|
2
|
-
DIFFICULTY_HASH = {:
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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.
|
|
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 =
|
|
75
|
-
@error =
|
|
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 =
|
|
83
|
-
@error =
|
|
84
|
-
return nil if @error ==
|
|
82
|
+
@error = :WrongCode unless code_attempt.match(/[1-6]+$/)
|
|
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
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
module GemCodebreakerAmidasd
|
|
2
|
-
class User
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
def initialize(name:)
|
|
11
|
+
@name = name
|
|
12
|
+
end
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
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.
|
|
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-
|
|
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
|
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
|