gem_codebreaker_amidasd 0.1.2 → 0.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac06d8b9d0d3f2d7945afb251704c20a4b714d11889ebcdc7c380e939523fa4d
|
4
|
+
data.tar.gz: f735a06aaf9a60afae5180d53b627c7e885bd308c6c3e549967300162986087d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5ee989b70f7df009e0ba50a34c95fe1790c8e202a8c0034758c478764bf8255ae4011fb57e3ef99842f194f2c772307fa1292aabff4f8e19ef737ffbe2389ac
|
7
|
+
data.tar.gz: 1ed3a127d84345a67e1252c6a800ef0ee16acfd0007a70784e34d36df8df6091807e060896ae6be43777af69a12e41c9dd65c9cd1839d94244c57dd9b95e0874
|
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module GemCodebreakerAmidasd
|
2
|
+
class DbUtility
|
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
|
+
|
9
|
+
def load_yaml_db(yml_db)
|
10
|
+
# yml_db = CodebreakerConfig::PATH_DB
|
11
|
+
return unless File.exist?(yml_db)
|
12
|
+
|
13
|
+
YAML.load_file(yml_db)
|
14
|
+
end
|
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)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,13 +1,17 @@
|
|
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 }}
|
5
|
+
|
2
6
|
class GemCodebreaker
|
3
|
-
|
7
|
+
|
8
|
+
attr_accessor :difficulty_hash, :difficulty
|
4
9
|
attr_accessor :length_code, :max_num, :min_num
|
5
|
-
attr_reader :error, :win, :count_plus, :count_minus, :hint
|
10
|
+
attr_reader :total_count_attempt, :total_count_hints, :error, :win, :count_plus, :count_minus, :hint
|
6
11
|
attr_reader :count_attempt, :secret_code, :array_hints
|
7
12
|
|
8
|
-
def initialize(
|
9
|
-
@
|
10
|
-
@total_count_hints = total_count_hints
|
13
|
+
def initialize(other_difficulty: {})
|
14
|
+
@difficulty_hash = DIFFICULTY_HASH.merge(other_difficulty)
|
11
15
|
@array_hints = []
|
12
16
|
@length_code = 4
|
13
17
|
@min_num = 1
|
@@ -17,6 +21,17 @@ module GemCodebreakerAmidasd
|
|
17
21
|
empty_result
|
18
22
|
end
|
19
23
|
|
24
|
+
def string_secertcode
|
25
|
+
@secret_code.join('')
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_difficulty(difficulty)
|
29
|
+
return unless @difficulty_hash.has_key? difficulty
|
30
|
+
@difficulty = difficulty
|
31
|
+
@total_count_attempt = @difficulty_hash[difficulty][:total_count_attempt]
|
32
|
+
@total_count_hints = @difficulty_hash[difficulty][:total_count_hints]
|
33
|
+
end
|
34
|
+
|
20
35
|
def gets_hint
|
21
36
|
return_hint
|
22
37
|
end
|
@@ -0,0 +1,27 @@
|
|
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
|
9
|
+
|
10
|
+
def initialize(name:)
|
11
|
+
@name = name
|
12
|
+
end
|
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
|
21
|
+
|
22
|
+
def self.validtion_name(name)
|
23
|
+
name.is_a?(String) && !name.empty? && name.length.between?(3, 20)
|
24
|
+
end
|
25
|
+
|
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.3
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,9 +131,12 @@ files:
|
|
131
131
|
- fasterer.yml
|
132
132
|
- gem_codebreaker_amidasd-0.1.0.gem
|
133
133
|
- gem_codebreaker_amidasd-0.1.1.gem
|
134
|
+
- gem_codebreaker_amidasd-0.1.2.gem
|
134
135
|
- gem_codebreaker_amidasd.gemspec
|
135
136
|
- lib/gem_codebreaker_amidasd.rb
|
137
|
+
- lib/gem_codebreaker_amidasd/db_utility.rb
|
136
138
|
- lib/gem_codebreaker_amidasd/gem_codebreaker.rb
|
139
|
+
- lib/gem_codebreaker_amidasd/user.rb
|
137
140
|
- lib/gem_codebreaker_amidasd/version.rb
|
138
141
|
homepage: https://github.com/Amidasd/gem_codebreaker_amidasd
|
139
142
|
licenses:
|
@@ -154,7 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
157
|
- !ruby/object:Gem::Version
|
155
158
|
version: '0'
|
156
159
|
requirements: []
|
157
|
-
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 2.7.9
|
158
162
|
signing_key:
|
159
163
|
specification_version: 4
|
160
164
|
summary: Codebreaker game
|