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 +4 -4
- data/lib/codeguessing/console.rb +1 -1
- data/lib/codeguessing/game.rb +12 -4
- data/lib/codeguessing/scores.yml +16 -0
- data/lib/codeguessing/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: 047e3995be8f530e9bdabfc971a420dd32bbf191
|
4
|
+
data.tar.gz: 83a0e3abad28f67917f85ff50b72e4ac7317c692
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963795b20259881a44a8f52b8ceb46df397c6516e954061876859cd264eb872cb5b22f5753da0165835e2cc3bc0ce7063f65d46a68e98f6a3b10b560dd19ddb5
|
7
|
+
data.tar.gz: f99eb025924bcbf607a4560209eea4491a66aa78a47e0a54d15a8548501d54ff239e6a21c225152b9bbe1491a83cca144f2cc3a093a609acf5f53a5f7e849dbc
|
data/lib/codeguessing/console.rb
CHANGED
data/lib/codeguessing/game.rb
CHANGED
@@ -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
|
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
|
data/lib/codeguessing/scores.yml
CHANGED
@@ -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
|
data/lib/codeguessing/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|