codebreaker-rg-te 0.1.21 → 0.1.22

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
  SHA1:
3
- metadata.gz: 11cc44b29465b7d9b0c8712db4cec73dcb320263
4
- data.tar.gz: 2257c6a2af1fa0f124b2f09a9611164b31b5c854
3
+ metadata.gz: e39884b51fcae83eb263609cd2a0f0ba3fc3d6d5
4
+ data.tar.gz: 349facfcbdb6ae824d380822ffe1d1f63c53b975
5
5
  SHA512:
6
- metadata.gz: aa9e36c32f115476f517d4138bcc0685064474df76217ac671ed83421356423687e5b560fdaedb78a0620a58840dfa712b3112f198f75ef59381bc62fb5ad99d
7
- data.tar.gz: 8907879da73dbf8a49c985e3ad96bce9b1246c5b65cffdfae8bea942d3da49d9680cd6fa7909da7dff3ccebc86e113bd1aeb3841acc046e5f76d111156c99d0d
6
+ metadata.gz: 41832bd7b6861e5cb6ea9e56d91e5eb2fe1150d90002ea11dc2ff32ef6620f34dc8fd0d9796352a87c1e18ccdffb5b8aaa66c692a3856204d0cf92fba7604074
7
+ data.tar.gz: ab0cbb8bb1b4e60c211cee2faa4c15178308348f58b9479547b4293911d72549517eb796e933a396854de7024b3f0b1fe942b54cb6a188aec48af9323e95dcd9
@@ -66,14 +66,22 @@ module Codebreaker
66
66
  end
67
67
 
68
68
  def game_result
69
- count_plus + count_minus
69
+ secret_code_clone = @secret_code.clone
70
+ count_plus(secret_code_clone) + count_minus(secret_code_clone)
70
71
  end
71
72
 
72
73
  def storage_data(codebreaker_data)
73
74
  attempts_used = GAME_LEVELS.dig(level.to_sym, :attempts) - attempts
74
75
  hints_used = GAME_LEVELS.dig(level.to_sym, :hints) - hints
75
- game_date = Time.new.strftime "%Y/%m/%d %H:%M:%S"
76
- hash_stat = { name: @name, level: @level, level_num: @level_num, attempts: @attempts, attempts_used: attempts_used, hints: @hints, hints_used: hints_used, game_date: game_date }
76
+ game_date = Time.new.strftime '%Y/%m/%d %H:%M:%S'
77
+ hash_stat = { name: @name,
78
+ level: @level,
79
+ level_num: @level_num,
80
+ attempts: @attempts,
81
+ attempts_used: attempts_used,
82
+ hints: @hints,
83
+ hints_used: hints_used,
84
+ game_date: game_date }
77
85
  codebreaker_data << hash_stat
78
86
  end
79
87
 
@@ -85,27 +93,25 @@ module Codebreaker
85
93
 
86
94
  private
87
95
 
88
- def count_plus
96
+ def count_plus(secret_code_clone)
89
97
  result = ''
90
- @secret_code_clone = @secret_code.clone
91
98
  @user_code.each_with_index do |digit, index|
92
- next unless digit == @secret_code_clone[index]
99
+ next unless digit == secret_code_clone[index]
93
100
 
94
101
  result += '+'
95
- @secret_code_clone[index] = nil
102
+ secret_code_clone[index] = nil
96
103
  @user_code[index] = nil
97
104
  end
98
105
  result
99
106
  end
100
107
 
101
- def count_minus
108
+ def count_minus(secret_code_clone)
102
109
  result = ''
103
- @secret_code_clone = @secret_code.clone
104
110
  @user_code.compact.each_with_index do |digit, _index|
105
- next unless @secret_code_clone.include?(digit)
111
+ next unless secret_code_clone.include?(digit)
106
112
 
107
113
  result += '-'
108
- @secret_code_clone[@secret_code_clone.index(digit)] = nil
114
+ secret_code_clone[secret_code_clone.index(digit)] = nil
109
115
  end
110
116
  result
111
117
  end
@@ -1,8 +1,11 @@
1
1
  module Codebreaker
2
2
  class Statistics
3
+ def initialize
4
+ @storage = StorageInterceptor.new
5
+ end
6
+
3
7
  def stats
4
- storage = StorageInterceptor.new
5
- return unless codebreaker_data = storage.read_database
8
+ return unless codebreaker_data = @storage.read_database
6
9
 
7
10
  codebreaker_data.sort_by! { |stat| [stat[:level_num], stat[:hints], stat[:attempts]] }
8
11
  codebreaker_data.each { |stat| stat.delete_if { |key, _value| key == :level_num } }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebreaker-rg-te
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Tereschenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-27 00:00:00.000000000 Z
11
+ date: 2019-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n