codeguessing 0.3.2 → 0.3.3

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: 90f9a168f72cea878f0459996e22cefd09164549
4
- data.tar.gz: 269a901a4bb78ac34916c22fb8290f0af84422a4
3
+ metadata.gz: 047e3995be8f530e9bdabfc971a420dd32bbf191
4
+ data.tar.gz: 83a0e3abad28f67917f85ff50b72e4ac7317c692
5
5
  SHA512:
6
- metadata.gz: 3f78ce85aa51e5316ed555ebb332a2278f699f907465420539238f80c3f0e096735197611a4bb26e24b3bf00b52b37ae68f0dacc31de8f526ed2b7ca3d59e575
7
- data.tar.gz: 0f5e69bf9c6ff17b0bb7b3a777bf32f0b529bc36e8beae064568f14dc58e271d3d147f280315923d375a86ae2487da027d08af533d6cdc708b441150dad3388a
6
+ metadata.gz: 963795b20259881a44a8f52b8ceb46df397c6516e954061876859cd264eb872cb5b22f5753da0165835e2cc3bc0ce7063f65d46a68e98f6a3b10b560dd19ddb5
7
+ data.tar.gz: f99eb025924bcbf607a4560209eea4491a66aa78a47e0a54d15a8548501d54ff239e6a21c225152b9bbe1491a83cca144f2cc3a093a609acf5f53a5f7e849dbc
@@ -81,7 +81,7 @@ module Codeguessing
81
81
  end
82
82
 
83
83
  def save(name = 'Anonim')
84
- return if @game.state != true
84
+ return if @game.state != 'true'
85
85
  @scores << @game.cur_score(name)
86
86
  File.new(@path, 'w') unless File.exist?(@path)
87
87
  File.open(@path, "r+") do |f|
@@ -1,6 +1,6 @@
1
1
  module Codeguessing
2
2
  class Game
3
- attr_reader :attempts, :hint_count, :state
3
+ attr_reader :attempts, :hint_count, :state, :answer
4
4
  attr_accessor :secret_code
5
5
 
6
6
  MAX_HINT = 2
@@ -11,6 +11,7 @@ module Codeguessing
11
11
  @attempts = opt[:attempts] || MAX_ATTEMPTS
12
12
  @hint_count = opt[:hint_count] || MAX_HINT
13
13
  @state = opt[:state] || ''
14
+ @answer = opt[:answer] || ''
14
15
  end
15
16
 
16
17
  def guess(code)
@@ -24,7 +25,7 @@ module Codeguessing
24
25
  end
25
26
  end
26
27
  win if res == '++++'
27
- res
28
+ @answer = res
28
29
  end
29
30
 
30
31
  def hint
@@ -42,9 +43,8 @@ module Codeguessing
42
43
  res
43
44
  end
44
45
 
45
- def cur_score(name = 'Anonim')
46
+ def cur_game
46
47
  hash = {}
47
- hash[:name] = name
48
48
  self.instance_variables.each do |k, v|
49
49
  new_k = k.to_s.gsub('@','').to_sym
50
50
  hash[new_k] = self.instance_variable_get(k)
@@ -52,6 +52,14 @@ module Codeguessing
52
52
  hash
53
53
  end
54
54
 
55
+ def cur_score(name = 'Anonim')
56
+ hash = cur_game
57
+ hash[:name] = name
58
+ hash.delete(:answer)
59
+ hash.delete(:state)
60
+ hash
61
+ end
62
+
55
63
  def valid?(code)
56
64
  return true if code =~ /^[1-6]{4}$/s
57
65
  false
@@ -4,3 +4,19 @@
4
4
  :attempts: 4
5
5
  :hint_count: 2
6
6
  :state: true
7
+ - :name: '1234435'
8
+ :secret_code: '1234'
9
+ :attempts: 4
10
+ :hint_count: 2
11
+ :state: 'true'
12
+ :answer: "++++"
13
+ - :name: '1384848484'
14
+ :secret_code: '1234'
15
+ :attempts: 4
16
+ :hint_count: 2
17
+ :state: 'true'
18
+ :answer: "++++"
19
+ - :secret_code: '1234'
20
+ :attempts: 4
21
+ :hint_count: 2
22
+ :name: Yayryary
@@ -1,3 +1,3 @@
1
1
  module Codeguessing
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeguessing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bezrukavyi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-23 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize