codebreaker 0.1.3.2 → 0.1.4
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/lib/codebreaker/game.rb +13 -8
- data/lib/codebreaker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96cf022f71b4fc75219ea6ccee86b4d3085ef252
|
4
|
+
data.tar.gz: 9735cfc7994c9f6861e120af44dc8098963a67a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0c42183ef6b7314c3a0a16607f11e538a0f83091d767cd4161fd07c391463962f6c469a06d963533a0fd40de6fa2f7e8f272f0d4411286d56e7420904a879c0
|
7
|
+
data.tar.gz: 263bdf9f20a1c664716f3c171cd39d344ae682873a5c5ea66aecd1ae34bf67e429c94c1b9026f054933e54802db83be387cbb6bd1cf735e31137bc675469df4b
|
data/lib/codebreaker/game.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
module Codebreaker
|
2
2
|
class Game
|
3
|
-
HINTS_COUNT = 2
|
4
3
|
MAX_SCORE = 500
|
5
4
|
MAX_ROUNDS = 500
|
6
5
|
CODE_LENGTH = 4
|
7
6
|
ROUND_PENALTY = 10
|
8
7
|
HINT_PENALTY = 50
|
9
8
|
|
10
|
-
attr_reader :round_number, :gues_results, :game_status
|
9
|
+
attr_reader :round_number, :gues_results, :game_status, :hint_val
|
11
10
|
|
12
11
|
def initialize
|
13
|
-
@secret_code =
|
12
|
+
@secret_code = ''
|
14
13
|
@round_number = 0
|
15
|
-
@hints_used = 0
|
16
14
|
@gues_results = {}
|
17
15
|
@game_status = 'play'
|
16
|
+
@hint_val = ''
|
18
17
|
end
|
19
18
|
|
20
19
|
def start
|
@@ -54,13 +53,19 @@ module Codebreaker
|
|
54
53
|
end
|
55
54
|
|
56
55
|
def hint
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
if @hint_val.empty?
|
57
|
+
hint_pos = Random.rand(CODE_LENGTH);
|
58
|
+
hint_pos.times {@hint_val += '*'}
|
59
|
+
@hint_val += @secret_code[hint_pos].to_s
|
60
|
+
(CODE_LENGTH - hint_pos - 1).times {@hint_val += '*'}
|
61
|
+
end
|
62
|
+
@hint_val
|
60
63
|
end
|
61
64
|
|
62
65
|
def score
|
63
|
-
|
66
|
+
hints_used = 0
|
67
|
+
hints_used = 1 unless @hint_val.empty?
|
68
|
+
MAX_SCORE - hints_used*HINT_PENALTY - @round_number*ROUND_PENALTY
|
64
69
|
end
|
65
70
|
end
|
66
71
|
end
|
data/lib/codebreaker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebreaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliy Burlaka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|