codebreaker 0.1.3.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 904895105cd8b6cbdc13466d430e2d1249eadf7f
4
- data.tar.gz: 5652ce5daefdeb63969823ef9650f90c665059c5
3
+ metadata.gz: 96cf022f71b4fc75219ea6ccee86b4d3085ef252
4
+ data.tar.gz: 9735cfc7994c9f6861e120af44dc8098963a67a6
5
5
  SHA512:
6
- metadata.gz: 072b2c250caa00c9d735c502a5ba5acca8dde3801112d83c0f88eec1ea6ce8d2b43ca5abd3c7b72ea0c3e7982dbc178b37968782fab7b77773f5723cdc865aa7
7
- data.tar.gz: 838c5dd41da14d89b296e891d95780b6a40d120f2b13483321e659b3c28335ce095637c93eac9e14dfc6fe5037a27ca0c30568abe68633f74336c84140842eb1
6
+ metadata.gz: d0c42183ef6b7314c3a0a16607f11e538a0f83091d767cd4161fd07c391463962f6c469a06d963533a0fd40de6fa2f7e8f272f0d4411286d56e7420904a879c0
7
+ data.tar.gz: 263bdf9f20a1c664716f3c171cd39d344ae682873a5c5ea66aecd1ae34bf67e429c94c1b9026f054933e54802db83be387cbb6bd1cf735e31137bc675469df4b
@@ -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
- raise 'Called hint to many times' unless @hints_used < HINTS_COUNT
58
- @hints_used += 1
59
- @secret_code[Random.rand(4)]
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
- MAX_SCORE - @hints_used*HINT_PENALTY - @round_number*ROUND_PENALTY
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
@@ -1,3 +1,3 @@
1
1
  module Codebreaker
2
- VERSION = "0.1.3.2"
2
+ VERSION = "0.1.4"
3
3
  end
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.3.2
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-28 00:00:00.000000000 Z
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler