codebreaker_mats 0.1.0 → 0.1.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 +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +7 -1
- data/lib/codebreaker_mats.rb +2 -3
- data/lib/codebreaker_mats/game.rb +3 -18
- data/lib/codebreaker_mats/matcher.rb +0 -8
- data/lib/codebreaker_mats/version.rb +1 -1
- data/stat.yml +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '09050fec89126a3ab9c2c82ea1c896d333470bafcaba1caf2619f063528c5b82'
|
|
4
|
+
data.tar.gz: 3654625e41217b5caf993637526a1a508c7e901da9efbf8a014e645bb7824fa5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 709c26a51c13ce88544e3b9bd3f1484ca0f8db7f4234b559f1d51924bde451b7755423238aa9d95aba9cf6150f7f57896bb93e65af6f592391dec40742f0baf3
|
|
7
|
+
data.tar.gz: f28b2fc04bf78b386a0a1c81831a2c9b0c79f52c9d6d54636d2d3b879671d58c7d0132fae157bf8c15f11d43c231981c37c12b227683614b29eefc86841bd87e
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
codebreaker_mats (0.1.
|
|
4
|
+
codebreaker_mats (0.1.1)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
9
|
diff-lcs (1.4.4)
|
|
10
|
+
docile (1.3.2)
|
|
10
11
|
rake (12.3.3)
|
|
11
12
|
rspec (3.9.0)
|
|
12
13
|
rspec-core (~> 3.9.0)
|
|
@@ -21,6 +22,10 @@ GEM
|
|
|
21
22
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
22
23
|
rspec-support (~> 3.9.0)
|
|
23
24
|
rspec-support (3.9.3)
|
|
25
|
+
simplecov (0.18.5)
|
|
26
|
+
docile (~> 1.1)
|
|
27
|
+
simplecov-html (~> 0.11)
|
|
28
|
+
simplecov-html (0.12.2)
|
|
24
29
|
|
|
25
30
|
PLATFORMS
|
|
26
31
|
ruby
|
|
@@ -29,6 +34,7 @@ DEPENDENCIES
|
|
|
29
34
|
codebreaker_mats!
|
|
30
35
|
rake (~> 12.0)
|
|
31
36
|
rspec (~> 3.0)
|
|
37
|
+
simplecov
|
|
32
38
|
|
|
33
39
|
BUNDLED WITH
|
|
34
40
|
2.1.4
|
data/lib/codebreaker_mats.rb
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
require_relative "codebreaker_mats/version"
|
|
2
|
-
|
|
3
1
|
require 'yaml'
|
|
4
|
-
require 'i18n'
|
|
5
2
|
|
|
6
3
|
require_relative 'codebreaker_mats/version'
|
|
7
4
|
require_relative 'codebreaker_mats/matcher'
|
|
@@ -12,3 +9,5 @@ require_relative 'codebreaker_mats/exceptions/terminate_error'
|
|
|
12
9
|
require_relative 'codebreaker_mats/markers/plus_minus_marker'
|
|
13
10
|
require_relative 'codebreaker_mats/markers/classical_marker'
|
|
14
11
|
|
|
12
|
+
require 'simplecov'
|
|
13
|
+
SimpleCov.start
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
module Codebreaker
|
|
4
4
|
# Game of bulls and cows.
|
|
5
5
|
class Game
|
|
6
|
-
|
|
7
|
-
attr_reader :storage, :matcher, :hints, :status
|
|
6
|
+
attr_reader :storage, :matcher, :hints, :status, :secret_code
|
|
8
7
|
|
|
9
8
|
attr_accessor :user, :number_of_attempts, :number_of_hints, :attempts_left, :hints_left, :difficulty
|
|
10
9
|
def initialize(matcher: Matcher.new)
|
|
@@ -29,8 +28,6 @@ module Codebreaker
|
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
def guess(guess)
|
|
32
|
-
raise Exceptions::NoAttemptsLeft unless attempts_available?
|
|
33
|
-
|
|
34
31
|
@attempts_left -= 1
|
|
35
32
|
matcher.match?(guess) && won
|
|
36
33
|
end
|
|
@@ -58,16 +55,8 @@ module Codebreaker
|
|
|
58
55
|
status == :in_progress
|
|
59
56
|
end
|
|
60
57
|
|
|
61
|
-
def
|
|
62
|
-
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def scores
|
|
66
|
-
storage.to_a
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def save_stat
|
|
70
|
-
File.open(FILESTAT, 'a+') do |f|
|
|
58
|
+
def save_stat(stat_file)
|
|
59
|
+
File.open(stat_file, 'a+') do |f|
|
|
71
60
|
f.write({ user: @user,
|
|
72
61
|
difficulty: @difficulty,
|
|
73
62
|
attempts: @number_of_attempts,
|
|
@@ -93,15 +82,11 @@ module Codebreaker
|
|
|
93
82
|
|
|
94
83
|
def won
|
|
95
84
|
@status = :won
|
|
96
|
-
print I18n.t(:secret_code)
|
|
97
|
-
puts @secret_code
|
|
98
85
|
true
|
|
99
86
|
end
|
|
100
87
|
|
|
101
88
|
def lost
|
|
102
89
|
@status = :lost
|
|
103
|
-
print I18n.t(:secret_code)
|
|
104
|
-
puts @secret_code
|
|
105
90
|
false
|
|
106
91
|
end
|
|
107
92
|
end
|
|
@@ -16,8 +16,6 @@ module Codebreaker
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def match?(guess)
|
|
19
|
-
raise Exceptions::InvalidGuessFormat unless valid_code?(guess)
|
|
20
|
-
|
|
21
19
|
match(array_to_hash_of_positions(unify_code(guess)))
|
|
22
20
|
|
|
23
21
|
bulls == 4
|
|
@@ -29,12 +27,6 @@ module Codebreaker
|
|
|
29
27
|
|
|
30
28
|
private
|
|
31
29
|
|
|
32
|
-
def valid_code?(code)
|
|
33
|
-
code = code.join('') if code.is_a?(Array)
|
|
34
|
-
|
|
35
|
-
code.match(/^[1-6]{4}$/)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
30
|
def unify_code(code)
|
|
39
31
|
code.is_a?(String) ? code.split('') : code
|
|
40
32
|
end
|
data/stat.yml
ADDED
|
File without changes
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: codebreaker_mats
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-07-
|
|
11
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: The app provides core for codebreaker game
|
|
14
14
|
email:
|
|
@@ -36,6 +36,7 @@ files:
|
|
|
36
36
|
- lib/codebreaker_mats/markers/plus_minus_marker.rb
|
|
37
37
|
- lib/codebreaker_mats/matcher.rb
|
|
38
38
|
- lib/codebreaker_mats/version.rb
|
|
39
|
+
- stat.yml
|
|
39
40
|
homepage: https://github.com/Swooty18/codebreaker_mats.git
|
|
40
41
|
licenses:
|
|
41
42
|
- MIT
|