codebreaker_kirill 0.2.20 → 0.3.2
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 +2 -0
- data/Gemfile.lock +10 -3
- data/lib/codebreaker_kirill/autoload.rb +1 -0
- data/lib/codebreaker_kirill/guess_handler.rb +10 -1
- data/lib/codebreaker_kirill/stats.rb +19 -1
- data/lib/codebreaker_kirill/stats.yml +9 -9
- data/lib/codebreaker_kirill/user.rb +9 -3
- data/lib/codebreaker_kirill/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73646f79231fa52be49e3228ef5e3f16b814ac331e156adffd78e10816280f5d
|
4
|
+
data.tar.gz: fc3a106ca28d4fa493697f29668acbbc8a01bb45457a2c65d297b55dcd4d1bab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af7cac1998d5cbd213c6f2f65d67d5da2e0bf275d326fa8faa068d337dcca9292f0f8110a02a3f1cbcbb0615e54482a4ff52f32d582100948d3688866cd6c343
|
7
|
+
data.tar.gz: 43e23d476945d8f9c96b60d58ac5f84264f5f9efe8d84104bfa41758ad70769d073aa7de8838c05d254b09e45812496e0710d3b10c5daa3e8d508274470dd759
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
codebreaker_kirill (0.
|
4
|
+
codebreaker_kirill (0.3.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.2)
|
10
10
|
diff-lcs (1.5.0)
|
11
|
+
docile (1.1.5)
|
11
12
|
json (2.6.2)
|
12
13
|
parallel (1.22.1)
|
13
14
|
parser (3.1.2.1)
|
@@ -28,7 +29,7 @@ GEM
|
|
28
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
30
|
rspec-support (~> 3.11.0)
|
30
31
|
rspec-support (3.11.0)
|
31
|
-
rubocop (1.35.
|
32
|
+
rubocop (1.35.1)
|
32
33
|
json (~> 2.3)
|
33
34
|
parallel (~> 1.10)
|
34
35
|
parser (>= 3.1.2.1)
|
@@ -41,6 +42,11 @@ GEM
|
|
41
42
|
rubocop-ast (1.21.0)
|
42
43
|
parser (>= 3.1.1.0)
|
43
44
|
ruby-progressbar (1.11.0)
|
45
|
+
simplecov (0.12.0)
|
46
|
+
docile (~> 1.1.0)
|
47
|
+
json (>= 1.8, < 3)
|
48
|
+
simplecov-html (~> 0.10.0)
|
49
|
+
simplecov-html (0.10.2)
|
44
50
|
unicode-display_width (2.2.0)
|
45
51
|
|
46
52
|
PLATFORMS
|
@@ -50,6 +56,7 @@ DEPENDENCIES
|
|
50
56
|
codebreaker_kirill!
|
51
57
|
rspec
|
52
58
|
rubocop (~> 1.21)
|
59
|
+
simplecov (~> 0.12.0)
|
53
60
|
|
54
61
|
BUNDLED WITH
|
55
|
-
2.3.
|
62
|
+
2.3.20
|
@@ -5,7 +5,7 @@ require_relative 'game'
|
|
5
5
|
|
6
6
|
class GuessHandler
|
7
7
|
def respond_to_guess(game, input, code)
|
8
|
-
|
8
|
+
validation(input)
|
9
9
|
return game.give_a_hint if input == 'hint'
|
10
10
|
|
11
11
|
@result = []
|
@@ -41,4 +41,13 @@ class GuessHandler
|
|
41
41
|
end.sort
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def validation(input)
|
48
|
+
Validations.validate_guess(input)
|
49
|
+
rescue StandardError => e
|
50
|
+
puts e.message
|
51
|
+
nil
|
52
|
+
end
|
44
53
|
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'yaml'
|
4
|
+
require_relative 'user'
|
5
|
+
|
3
6
|
class Stats
|
4
7
|
def self.save_game(user)
|
5
8
|
@data = File.exist?('stats.yml') ? YAML.load_file('stats.yml') : []
|
@@ -10,6 +13,21 @@ class Stats
|
|
10
13
|
|
11
14
|
def self.show_stats
|
12
15
|
@data = File.exist?('stats.yml') ? YAML.load_file('stats.yml') : []
|
13
|
-
|
16
|
+
@data.each_with_index do |user, index|
|
17
|
+
stats_format(user, index)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.stats_format(user, index)
|
22
|
+
index += 1
|
23
|
+
puts "Rating: #{index}", "Name: #{user.name}",
|
24
|
+
"Difficulty: #{Settings::DIFFICULTY.key({ attempts: user.attempts[:all], hints: user.hints[:all] })}",
|
25
|
+
"Available Attempts: #{user.attempts[:all]}",
|
26
|
+
"Used Attempts: #{user.attempts[:used]}",
|
27
|
+
"Available Hints: #{user.hints[:all]}",
|
28
|
+
"Used Hints: #{user.hints[:used]}",
|
29
|
+
'-----------------------'
|
14
30
|
end
|
15
31
|
end
|
32
|
+
|
33
|
+
Stats.show_stats
|
@@ -1,34 +1,34 @@
|
|
1
1
|
---
|
2
2
|
- !ruby/object:User
|
3
|
-
name:
|
3
|
+
name: kirill
|
4
4
|
difficulty:
|
5
|
-
:attempts:
|
5
|
+
:attempts: 5
|
6
6
|
:hints: 1
|
7
7
|
attempts:
|
8
|
-
:all:
|
8
|
+
:all: 5
|
9
9
|
:used: 0
|
10
10
|
hints:
|
11
11
|
:all: 1
|
12
12
|
:used: 0
|
13
13
|
- !ruby/object:User
|
14
|
-
name:
|
14
|
+
name: Stacy
|
15
15
|
difficulty:
|
16
|
-
:attempts:
|
16
|
+
:attempts: 10
|
17
17
|
:hints: 1
|
18
18
|
attempts:
|
19
|
-
:all:
|
19
|
+
:all: 10
|
20
20
|
:used: 0
|
21
21
|
hints:
|
22
22
|
:all: 1
|
23
|
-
:used:
|
23
|
+
:used: 1
|
24
24
|
- !ruby/object:User
|
25
|
-
name:
|
25
|
+
name: Dima
|
26
26
|
difficulty:
|
27
27
|
:attempts: 5
|
28
28
|
:hints: 1
|
29
29
|
attempts:
|
30
30
|
:all: 5
|
31
|
-
:used:
|
31
|
+
:used: 2
|
32
32
|
hints:
|
33
33
|
:all: 1
|
34
34
|
:used: 0
|
@@ -1,17 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'autoload'
|
4
3
|
require_relative 'settings'
|
5
4
|
|
6
5
|
class User
|
7
6
|
attr_reader :name, :difficulty, :attempts, :hints
|
8
7
|
|
9
8
|
def initialize(name, difficulty)
|
10
|
-
|
11
|
-
Validations.validate_difficulty(difficulty)
|
9
|
+
validation(name, difficulty)
|
12
10
|
@name = name
|
13
11
|
@difficulty = Settings::DIFFICULTY[difficulty]
|
14
12
|
@attempts = { all: @difficulty[:attempts], used: 0 }
|
15
13
|
@hints = { all: @difficulty[:hints], used: 0 }
|
16
14
|
end
|
15
|
+
|
16
|
+
def validation(name, difficulty)
|
17
|
+
Validations.validate_name(name)
|
18
|
+
Validations.validate_difficulty(difficulty)
|
19
|
+
rescue StandardError => e
|
20
|
+
puts e.message
|
21
|
+
nil
|
22
|
+
end
|
17
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebreaker_kirill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Dudchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
|
-
rubygems_version: 3.
|
59
|
+
rubygems_version: 3.3.20
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Logic game
|