codebreaker_kirill 0.2.19 → 0.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42247fb0876ec4ccc153b8ea388699b2554fa77df10350ff5d5593d4732b0cb4
|
4
|
+
data.tar.gz: 3b93911002084a839fbfe931fd5aa70833bb1a60b54500ad6774a9cfdb8d5e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b672feeb7094d448091b0fcde89597dae42d3c51605cdc29b7b5b3fbe8aaec5695e342d67fa149672540b511741e92c9bda3d73fa39eca964e2fd42eb856cde
|
7
|
+
data.tar.gz: 4298392ee1d2376a614c625405ad2c101476c7a64d01f25761c11a1f64df1c5f57a3d92325eb716f139fe3240d618f88c5da0641a315b2a411ce0adb0a049e89
|
@@ -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
|
@@ -7,13 +7,18 @@ class User
|
|
7
7
|
attr_reader :name, :difficulty, :attempts, :hints
|
8
8
|
|
9
9
|
def initialize(name, difficulty)
|
10
|
-
|
11
|
-
Validations.validate_difficulty(difficulty)
|
10
|
+
validation(name, difficulty)
|
12
11
|
@name = name
|
13
12
|
@difficulty = Settings::DIFFICULTY[difficulty]
|
14
13
|
@attempts = { all: @difficulty[:attempts], used: 0 }
|
15
14
|
@hints = { all: @difficulty[:hints], used: 0 }
|
16
15
|
end
|
17
|
-
end
|
18
16
|
|
19
|
-
|
17
|
+
def validation(name, difficulty)
|
18
|
+
Validations.validate_name(name)
|
19
|
+
Validations.validate_difficulty(difficulty)
|
20
|
+
rescue StandardError => e
|
21
|
+
puts e.message
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
@@ -9,9 +9,9 @@ class Validations
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.validate_guess(guess)
|
12
|
-
raise "
|
13
|
-
raise '
|
14
|
-
raise '
|
12
|
+
raise "Guess shouldn't be empty" if guess.empty?
|
13
|
+
raise 'Guess should be at least 3 characters long' if guess.length < 4
|
14
|
+
raise 'Guess shouldn\'t be more than 4 characters long' if guess.length > 4
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.validate_difficulty(difficulty)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebreaker_kirill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Dudchenko
|
@@ -32,7 +32,6 @@ files:
|
|
32
32
|
- lib/codebreaker_kirill/guess_handler.rb
|
33
33
|
- lib/codebreaker_kirill/settings.rb
|
34
34
|
- lib/codebreaker_kirill/stats.rb
|
35
|
-
- lib/codebreaker_kirill/stats.yml
|
36
35
|
- lib/codebreaker_kirill/user.rb
|
37
36
|
- lib/codebreaker_kirill/validations.rb
|
38
37
|
- lib/codebreaker_kirill/version.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/object:User
|
3
|
-
name: dima
|
4
|
-
difficulty:
|
5
|
-
:attempts: 10
|
6
|
-
:hints: 1
|
7
|
-
attempts:
|
8
|
-
:all: 10
|
9
|
-
:used: 0
|
10
|
-
hints:
|
11
|
-
:all: 1
|
12
|
-
:used: 0
|
13
|
-
- !ruby/object:User
|
14
|
-
name: stacy
|
15
|
-
difficulty:
|
16
|
-
:attempts: 5
|
17
|
-
:hints: 1
|
18
|
-
attempts:
|
19
|
-
:all: 5
|
20
|
-
:used: 0
|
21
|
-
hints:
|
22
|
-
:all: 1
|
23
|
-
:used: 0
|
24
|
-
- !ruby/object:User
|
25
|
-
name: kirill
|
26
|
-
difficulty:
|
27
|
-
:attempts: 5
|
28
|
-
:hints: 1
|
29
|
-
attempts:
|
30
|
-
:all: 5
|
31
|
-
:used: 0
|
32
|
-
hints:
|
33
|
-
:all: 1
|
34
|
-
:used: 0
|