codebreaker_bo 0.1.5 → 0.1.6
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/Gemfile.lock +1 -1
- data/lib/codebreaker/config.rb +0 -0
- data/lib/codebreaker/console.rb +0 -0
- data/lib/codebreaker/const.rb +0 -0
- data/lib/codebreaker/constant.rb +5 -6
- data/lib/codebreaker/game.rb +19 -8
- data/lib/codebreaker/test_console.rb +0 -0
- data/lib/codebreaker/version.rb +1 -1
- metadata +6 -7
- data/.idea/codebreaker.iml +0 -86
- data/.idea/misc.xml +0 -4
- data/.idea/modules.xml +0 -8
- data/.idea/vcs.xml +0 -7
- data/e_attempts +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41c74c3d34c0613fd1561253030059a6ab61222e8aad34dc7d99e0b31f767456
|
4
|
+
data.tar.gz: 1d2d4570474a1e19262905b22a126e61e43dc9c9f97446b2984984f8a5b6b4c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6665492feee77e52af8e1838178520bb331d95c0964510ebf53f0f7624aa79baa157ada381223c480471efc40be6f2c7c9b8f9367bccbcb60a18419c6685370
|
7
|
+
data.tar.gz: c5ad83a10e7fd5948d97ec0ddcbe123bd84a88efb2780e2bd1d98584fb47abedfd80a1098ea246f8a3a0b0f1189b285cc28b10a7972cd2a00c6d15685b74edb7
|
data/Gemfile.lock
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/codebreaker/constant.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Constants
|
4
|
-
|
5
|
-
|
4
|
+
LEVELS = {
|
5
|
+
easy: { attempts: 15, hints: 2 },
|
6
|
+
medium: { attempts: 10, hints: 1 },
|
7
|
+
hell: { attempts: 5, hints: 1 }
|
8
|
+
}.freeze
|
6
9
|
|
7
|
-
MEDIUM = { attempts: 10,
|
8
|
-
hints: 1 }.freeze
|
9
|
-
HELL = { attempts: 5,
|
10
|
-
hints: 1 }.freeze
|
11
10
|
PLUS = '+'
|
12
11
|
MINUS = '-'
|
13
12
|
WIN_NUMBER = 4
|
data/lib/codebreaker/game.rb
CHANGED
@@ -17,8 +17,14 @@ module Codebreaker
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def save_stats
|
20
|
-
hash = {
|
21
|
-
|
20
|
+
hash = {
|
21
|
+
user_name: @player_name,
|
22
|
+
difficulty: level,
|
23
|
+
attempts_total: total_attempts,
|
24
|
+
attempts_used: used_attempts,
|
25
|
+
hints_total: total_hints,
|
26
|
+
hints_used: used_hints
|
27
|
+
}
|
22
28
|
@stat.collect_statistic(hash)
|
23
29
|
end
|
24
30
|
|
@@ -41,18 +47,23 @@ module Codebreaker
|
|
41
47
|
end
|
42
48
|
|
43
49
|
def accept_level(level)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
handle_errors('entered level is not present')
|
48
|
-
nil
|
50
|
+
current_level = Constants::LEVELS[level.to_sym]
|
51
|
+
handle_errors('entered level is not present') unless current_level
|
52
|
+
current_level
|
49
53
|
end
|
50
54
|
|
51
55
|
def create_level(level)
|
52
56
|
choice_level = accept_level(level)
|
53
57
|
return if choice_level.nil?
|
54
|
-
return unless @level.nil?
|
55
58
|
|
59
|
+
add_level(choice_level)
|
60
|
+
end
|
61
|
+
|
62
|
+
def difficulties
|
63
|
+
Constants::LEVELS.keys
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_level(choice_level)
|
56
67
|
@level = level
|
57
68
|
@used_hints = choice_level[:hints]
|
58
69
|
@total_hints = choice_level[:hints]
|
File without changes
|
data/lib/codebreaker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebreaker_bo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oladko Bohdan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -159,10 +159,6 @@ extensions: []
|
|
159
159
|
extra_rdoc_files: []
|
160
160
|
files:
|
161
161
|
- ".idea/.gitignore"
|
162
|
-
- ".idea/codebreaker.iml"
|
163
|
-
- ".idea/misc.xml"
|
164
|
-
- ".idea/modules.xml"
|
165
|
-
- ".idea/vcs.xml"
|
166
162
|
- ".rspec"
|
167
163
|
- ".rubocop.yml"
|
168
164
|
- CHANGELOG.md
|
@@ -173,12 +169,15 @@ files:
|
|
173
169
|
- README.md
|
174
170
|
- Rakefile
|
175
171
|
- data/statistic.yml
|
176
|
-
- e_attempts
|
177
172
|
- lib/codebreaker.rb
|
178
173
|
- lib/codebreaker/base_class.rb
|
174
|
+
- lib/codebreaker/config.rb
|
175
|
+
- lib/codebreaker/console.rb
|
176
|
+
- lib/codebreaker/const.rb
|
179
177
|
- lib/codebreaker/constant.rb
|
180
178
|
- lib/codebreaker/game.rb
|
181
179
|
- lib/codebreaker/statistic.rb
|
180
|
+
- lib/codebreaker/test_console.rb
|
182
181
|
- lib/codebreaker/user.rb
|
183
182
|
- lib/codebreaker/validation.rb
|
184
183
|
- lib/codebreaker/version.rb
|
data/.idea/codebreaker.iml
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
4
|
-
<shared />
|
5
|
-
</component>
|
6
|
-
<component name="NewModuleRootManager">
|
7
|
-
<content url="file://$MODULE_DIR$">
|
8
|
-
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
-
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
-
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
-
</content>
|
12
|
-
<orderEntry type="inheritedJdk" />
|
13
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-3.1.0) [gem]" level="application" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.9, RVM: ruby-3.1.0) [gem]" level="application" />
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.3, RVM: ruby-3.1.0) [gem]" level="application" />
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="colorize (v0.8.1, RVM: ruby-3.1.0) [gem]" level="application" />
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="docile (v1.4.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="fasterer (v0.9.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="json (v2.6.1, RVM: ruby-3.1.0) [gem]" level="application" />
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="lefthook (v0.7.7, RVM: ruby-3.1.0) [gem]" level="application" />
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="parser (v3.1.0.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="pry (v0.14.1, RVM: ruby-3.1.0) [gem]" level="application" />
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-3.1.0) [gem]" level="application" />
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-3.1.0) [gem]" level="application" />
|
29
|
-
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.2.1, RVM: ruby-3.1.0) [gem]" level="application" />
|
30
|
-
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-3.1.0) [gem]" level="application" />
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
34
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
35
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
36
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.25.1, RVM: ruby-3.1.0) [gem]" level="application" />
|
37
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.15.2, RVM: ruby-3.1.0) [gem]" level="application" />
|
38
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-rspec (v2.9.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
39
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
40
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby_parser (v3.18.1, RVM: ruby-3.1.0) [gem]" level="application" />
|
41
|
-
<orderEntry type="library" scope="PROVIDED" name="sexp_processor (v4.16.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
42
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.21.2, RVM: ruby-3.1.0) [gem]" level="application" />
|
43
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.3, RVM: ruby-3.1.0) [gem]" level="application" />
|
44
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.4, RVM: ruby-3.1.0) [gem]" level="application" />
|
45
|
-
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-3.1.0) [gem]" level="application" />
|
46
|
-
</component>
|
47
|
-
<component name="RakeTasksCache">
|
48
|
-
<option name="myRootTask">
|
49
|
-
<RakeTaskImpl id="rake">
|
50
|
-
<subtasks>
|
51
|
-
<RakeTaskImpl description="Build codebreaker_bo-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
52
|
-
<RakeTaskImpl id="build">
|
53
|
-
<subtasks>
|
54
|
-
<RakeTaskImpl description="Generate SHA512 checksum if codebreaker_bo-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
55
|
-
</subtasks>
|
56
|
-
</RakeTaskImpl>
|
57
|
-
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
58
|
-
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
59
|
-
<RakeTaskImpl description="Build and install codebreaker_bo-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
60
|
-
<RakeTaskImpl id="install">
|
61
|
-
<subtasks>
|
62
|
-
<RakeTaskImpl description="Build and install codebreaker_bo-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
63
|
-
</subtasks>
|
64
|
-
</RakeTaskImpl>
|
65
|
-
<RakeTaskImpl description="Create tag v0.1.0 and build and push codebreaker_bo-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
66
|
-
<RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
|
67
|
-
<RakeTaskImpl id="rubocop">
|
68
|
-
<subtasks>
|
69
|
-
<RakeTaskImpl description="Auto-correct RuboCop offenses" fullCommand="rubocop:auto_correct" id="auto_correct" />
|
70
|
-
</subtasks>
|
71
|
-
</RakeTaskImpl>
|
72
|
-
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
73
|
-
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
74
|
-
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
75
|
-
<RakeTaskImpl id="release">
|
76
|
-
<subtasks>
|
77
|
-
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
78
|
-
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
79
|
-
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
80
|
-
</subtasks>
|
81
|
-
</RakeTaskImpl>
|
82
|
-
</subtasks>
|
83
|
-
</RakeTaskImpl>
|
84
|
-
</option>
|
85
|
-
</component>
|
86
|
-
</module>
|
data/.idea/misc.xml
DELETED
data/.idea/modules.xml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectModuleManager">
|
4
|
-
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/codebreaker.iml" filepath="$PROJECT_DIR$/.idea/codebreaker.iml" />
|
6
|
-
</modules>
|
7
|
-
</component>
|
8
|
-
</project>
|
data/.idea/vcs.xml
DELETED
data/e_attempts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
|
2
|
-
[1mFrom:[0m /home/bo/rubypr/codebreaker/lib/codebreaker/Console.rb:75 Console#game_process:
|
3
|
-
|
4
|
-
[1;34m74[0m: [32mdef[0m [1;34mgame_process[0m
|
5
|
-
=> [1;34m75[0m: binding.pry
|
6
|
-
[1;34m76[0m: [32mif[0m !game.decrease_attempts == game.secret_code && [31m[1;31m'[0m[31mlose[1;31m'[0m[31m[0m
|
7
|
-
[1;34m77[0m: p game
|
8
|
-
[1;34m78[0m: game_actions
|
9
|
-
[1;34m79[0m: [32mend[0m
|
10
|
-
[1;34m80[0m:
|
11
|
-
[1;34m81[0m: [1;34m# if !game.used_attempts.nil? && !game.used_attempts.zero?[0m
|
12
|
-
[1;34m82[0m: [1;34m# p game[0m
|
13
|
-
[1;34m83[0m: [1;34m# game_actions[0m
|
14
|
-
[1;34m84[0m: [1;34m# else[0m
|
15
|
-
[1;34m85[0m: [1;34m# p 'attempts finished'[0m
|
16
|
-
[1;34m86[0m: [1;34m# lose[0m
|
17
|
-
[1;34m87[0m: [1;34m# new_process[0m
|
18
|
-
[1;34m88[0m: [1;34m# end[0m
|
19
|
-
[1;34m89[0m: [32mend[0m
|
20
|
-
|