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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32d5525d256cee4093c3031c08f35eae55555fca640bc2542f561e75c1fdbb94
4
- data.tar.gz: 46a5bb6bf909bedb9d43cb96ad930f5c3edafc5d4adffa599dd74a2998d17150
3
+ metadata.gz: 73646f79231fa52be49e3228ef5e3f16b814ac331e156adffd78e10816280f5d
4
+ data.tar.gz: fc3a106ca28d4fa493697f29668acbbc8a01bb45457a2c65d297b55dcd4d1bab
5
5
  SHA512:
6
- metadata.gz: 227730e0f75877e6e1d3666c5a87289a79cf5ee2745aeb7e4f32d69ab6297976466841d7405bc95eda658c643194ebc7c145ab0270bc7cfe0a398bc3370535e8
7
- data.tar.gz: 777f6bd2b6fd54913b1fcf53a6645758de81d98d513e2e51cf5286e9eafbcfe3f9fc64579ce0251aad3624d1a654b3e34bb3dca9ddfdac09639743ca8a6cdc1d
6
+ metadata.gz: af7cac1998d5cbd213c6f2f65d67d5da2e0bf275d326fa8faa068d337dcca9292f0f8110a02a3f1cbcbb0615e54482a4ff52f32d582100948d3688866cd6c343
7
+ data.tar.gz: 43e23d476945d8f9c96b60d58ac5f84264f5f9efe8d84104bfa41758ad70769d073aa7de8838c05d254b09e45812496e0710d3b10c5daa3e8d508274470dd759
data/Gemfile CHANGED
@@ -8,3 +8,5 @@ gemspec
8
8
  gem 'rspec'
9
9
 
10
10
  gem 'rubocop', '~> 1.21'
11
+
12
+ gem 'simplecov', '~> 0.12.0'
data/Gemfile.lock CHANGED
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- codebreaker_kirill (0.1.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.0)
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.19
62
+ 2.3.20
@@ -6,3 +6,4 @@ require_relative 'guess_handler'
6
6
  require_relative 'settings'
7
7
  require_relative 'code_generator'
8
8
  require_relative 'stats'
9
+ require_relative 'user'
@@ -5,7 +5,7 @@ require_relative 'game'
5
5
 
6
6
  class GuessHandler
7
7
  def respond_to_guess(game, input, code)
8
- Validations.validate_guess(input)
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
- print @data
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: dima
3
+ name: kirill
4
4
  difficulty:
5
- :attempts: 10
5
+ :attempts: 5
6
6
  :hints: 1
7
7
  attempts:
8
- :all: 10
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: stacy
14
+ name: Stacy
15
15
  difficulty:
16
- :attempts: 5
16
+ :attempts: 10
17
17
  :hints: 1
18
18
  attempts:
19
- :all: 5
19
+ :all: 10
20
20
  :used: 0
21
21
  hints:
22
22
  :all: 1
23
- :used: 0
23
+ :used: 1
24
24
  - !ruby/object:User
25
- name: kirill
25
+ name: Dima
26
26
  difficulty:
27
27
  :attempts: 5
28
28
  :hints: 1
29
29
  attempts:
30
30
  :all: 5
31
- :used: 0
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
- Validations.validate_name(name)
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
@@ -3,5 +3,5 @@
3
3
  require_relative 'game'
4
4
 
5
5
  module CodebreakerKirill
6
- VERSION = '0.2.20'
6
+ VERSION = '0.3.2'
7
7
  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.20
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-19 00:00:00.000000000 Z
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.0.3.1
59
+ rubygems_version: 3.3.20
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Logic game