codebreaker_mats 0.1.5 → 0.1.6
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: 0ff4627a58b422bfa3ddb12eb95895884b4ba4825f5902bc8d3120a94048ab5e
|
|
4
|
+
data.tar.gz: e290744852397fdc2d76c1490beb37946f2ce881b0e2d48f078b46e98eb68e14
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4483a224c17951f96461b18f6b76740889a88e1bffc648cd001039df5dc33ef40e8c3910a09085854f6a95e643d5b506f2605710fe80823b5ccda3d2058c6304
|
|
7
|
+
data.tar.gz: 4186fd5aedc97d2d626ad70072262b6487db3dc65268c8823b6188d14964678c52de4ada457f50ff68e8c92c556a8dbfca3cdc1ac0f3909d6e1326ae8176dce1
|
data/Gemfile.lock
CHANGED
data/lib/codebreaker_mats.rb
CHANGED
|
@@ -7,7 +7,3 @@ require_relative 'codebreaker_mats/game'
|
|
|
7
7
|
require_relative 'codebreaker_mats/exceptions/terminate_error'
|
|
8
8
|
|
|
9
9
|
require_relative 'codebreaker_mats/markers/plus_minus_marker'
|
|
10
|
-
require_relative 'codebreaker_mats/markers/classical_marker'
|
|
11
|
-
|
|
12
|
-
require 'simplecov'
|
|
13
|
-
SimpleCov.start
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
1
|
module Codebreaker
|
|
4
|
-
# Game of bulls and cows.
|
|
5
2
|
class Game
|
|
6
|
-
|
|
3
|
+
CODE_RANGE_MIN = 1
|
|
4
|
+
CODE_RANGE_MAX = 6
|
|
5
|
+
COUNT_OF_NUMBER = 4
|
|
6
|
+
attr_reader :matcher, :hints, :status
|
|
7
7
|
|
|
8
8
|
attr_accessor :user, :number_of_attempts, :number_of_hints, :attempts_left, :hints_left, :difficulty, :secret_code
|
|
9
9
|
def initialize(matcher: Matcher.new)
|
|
10
|
-
@storage = storage
|
|
11
10
|
@matcher = matcher
|
|
12
11
|
end
|
|
13
12
|
|
|
@@ -75,11 +74,11 @@ module Codebreaker
|
|
|
75
74
|
private
|
|
76
75
|
|
|
77
76
|
def generate_secret_code
|
|
78
|
-
@secret_code = Array.new(
|
|
77
|
+
@secret_code = Array.new(COUNT_OF_NUMBER) { roll_dice }.join
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
def roll_dice
|
|
82
|
-
rand(
|
|
81
|
+
rand(CODE_RANGE_MIN..CODE_RANGE_MAX)
|
|
83
82
|
end
|
|
84
83
|
|
|
85
84
|
def generate_hints
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module Codebreaker
|
|
4
4
|
module Markers
|
|
5
|
-
# Marker that will interpret the number of bulls
|
|
6
|
-
# and cows in a codebreaker plus-minus style.
|
|
7
5
|
class PlusMinusMarker
|
|
8
|
-
def mark(
|
|
9
|
-
'+' *
|
|
6
|
+
def mark(exact, non_exact)
|
|
7
|
+
'+' * exact + '-' * non_exact
|
|
10
8
|
end
|
|
11
9
|
end
|
|
12
10
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan
|
|
@@ -34,7 +34,6 @@ files:
|
|
|
34
34
|
- lib/codebreaker_mats.rb
|
|
35
35
|
- lib/codebreaker_mats/exceptions/terminate_error.rb
|
|
36
36
|
- lib/codebreaker_mats/game.rb
|
|
37
|
-
- lib/codebreaker_mats/markers/classical_marker.rb
|
|
38
37
|
- lib/codebreaker_mats/markers/plus_minus_marker.rb
|
|
39
38
|
- lib/codebreaker_mats/matcher.rb
|
|
40
39
|
- lib/codebreaker_mats/version.rb
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Codebreaker
|
|
4
|
-
module Markers
|
|
5
|
-
# Marker that will interpret the number of bulls
|
|
6
|
-
# and cows in classical way.
|
|
7
|
-
class ClassicalMarker
|
|
8
|
-
def mark(bulls, cows)
|
|
9
|
-
format('%d Bulls, %d Cows', bulls, cows)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|