codebreaker-d3n 0.1.8 → 0.1.9
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/game.rb +19 -4
- data/lib/codebreaker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f49dbd4c3857d46763fce325d8124ebd3122d043a9e24aa6b26cfea374622e0f
|
|
4
|
+
data.tar.gz: dfa8bbbd2f0202af790ce69ff3dd47e816ccc1d09c385b315d854baa94e0772a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8951da49533f949d34f2ee6c728dccbdcd0c13d79d95abada257925a6588fd6d163691cc960d165bedb1f488140dec2dbbb254e2b439bffe54b850a61528ae9f
|
|
7
|
+
data.tar.gz: 5ebcbd91edb9680a73262af49d591ed346d230ae86897302050b7776482e7acff3dfed847b22eed0041e1bcbbf6c9ba4d0d71df988c27e0346efaadf60ce3e03
|
data/Gemfile.lock
CHANGED
data/lib/codebreaker/game.rb
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
module Codebreaker
|
|
4
4
|
class Game
|
|
5
5
|
include Validations
|
|
6
|
-
attr_reader :difficulty, :errors, :secret_code
|
|
6
|
+
attr_reader :difficulty, :errors, :secret_code, :result, :hints, :attempts_total, :hint_keeper,
|
|
7
|
+
:attempts_used, :attempts_available, :hints_total, :hints_used, :hints_available
|
|
7
8
|
|
|
8
9
|
CODE_DIGITS = (1..6).freeze
|
|
9
10
|
CODE_LENGTH = 4
|
|
@@ -55,7 +56,8 @@ module Codebreaker
|
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
def hint
|
|
58
|
-
@hints.pop
|
|
59
|
+
@hint_keeper << tip = @hints.pop
|
|
60
|
+
tip
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
def hints_left?
|
|
@@ -68,6 +70,19 @@ module Codebreaker
|
|
|
68
70
|
@difficulty = LEVELS.dig(input.to_sym, :command)
|
|
69
71
|
@hints = @secret_code.sample(LEVELS.dig(@difficulty.to_sym, :hints))
|
|
70
72
|
@attempts = LEVELS.dig(@difficulty.to_sym, :attempts)
|
|
73
|
+
@hint_keeper = []
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def attempts_calculations
|
|
77
|
+
@attempts_total = LEVELS.dig(@difficulty.to_sym, :attempts)
|
|
78
|
+
@attempts_used = LEVELS.dig(@difficulty.to_sym, :attempts) - @attempts
|
|
79
|
+
@attempts_available = @attempts_total - @attempts_used
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def hints_calculations
|
|
83
|
+
@hints_total = LEVELS.dig(@difficulty.to_sym, :hints)
|
|
84
|
+
@hints_used = LEVELS.dig(@difficulty.to_sym, :hints) - @hints.size
|
|
85
|
+
@hints_available = @hints_total - @hints_used
|
|
71
86
|
end
|
|
72
87
|
|
|
73
88
|
def to_h(name)
|
|
@@ -75,9 +90,9 @@ module Codebreaker
|
|
|
75
90
|
name: name,
|
|
76
91
|
difficulty: @difficulty,
|
|
77
92
|
attempts_total: LEVELS.dig(@difficulty.to_sym, :attempts),
|
|
78
|
-
attempts_used:
|
|
93
|
+
attempts_used: LEVELS.dig(@difficulty.to_sym, :attempts) - @attempts,
|
|
79
94
|
hints_total: LEVELS.dig(@difficulty.to_sym, :hints),
|
|
80
|
-
hints_used:
|
|
95
|
+
hints_used: LEVELS.dig(@difficulty.to_sym, :hints) - @hints.size
|
|
81
96
|
}
|
|
82
97
|
end
|
|
83
98
|
|
data/lib/codebreaker/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: codebreaker-d3n
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denny_Dee
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-01-
|
|
11
|
+
date: 2019-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|