codeguessing 0.3.0 → 0.3.1
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/codeguessing/console.rb +2 -2
- data/lib/codeguessing/game.rb +2 -5
- data/lib/codeguessing/scores.yml +2 -38
- data/lib/codeguessing/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5f995c58157757c2bb029dfe79c0b502f55630a
|
4
|
+
data.tar.gz: f84b6142e9fc028e716b7db328f2e84be559a72f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0520c2ba19395703254e8a046c4924337f7511aee93a940b29f06393ec34ad48027fbe2f4aed2215c643ded8144ad369f699e152bd6a023459b3a77272f75b4
|
7
|
+
data.tar.gz: 8cc9bec66b8262825f04e839613c7710ea49b9ac6c29242642520b53e519aa6c95af7540198488723e8c0a4d71d0867b8a6233d180694ee8ece2175485d15528
|
data/lib/codeguessing/console.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Codeguessing
|
2
2
|
class Console
|
3
|
-
def initialize(again = false, opt)
|
3
|
+
def initialize(again = false, opt = {})
|
4
4
|
@path = File.join(File.dirname(__FILE__), 'scores.yml')
|
5
5
|
@scores = load(@path)
|
6
6
|
@game = Game.new(opt)
|
@@ -82,7 +82,7 @@ module Codeguessing
|
|
82
82
|
|
83
83
|
def save(name = 'Anonim')
|
84
84
|
return if @game.state != true
|
85
|
-
@scores << @game.cur_score
|
85
|
+
@scores << @game.cur_score(name)
|
86
86
|
File.new(@path, 'w') unless File.exist?(@path)
|
87
87
|
File.open(@path, "r+") do |f|
|
88
88
|
f.write(@scores.to_yaml)
|
data/lib/codeguessing/game.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Codeguessing
|
2
2
|
class Game
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :attempts, :hint_count, :state
|
4
4
|
attr_accessor :secret_code
|
5
5
|
|
6
6
|
MAX_HINT = 2
|
@@ -10,7 +10,7 @@ module Codeguessing
|
|
10
10
|
@secret_code = opt[:secret_code] || random
|
11
11
|
@attempts = opt[:attempts] || MAX_ATTEMPTS
|
12
12
|
@hint_count = opt[:hint_count] || MAX_HINT
|
13
|
-
@state = ''
|
13
|
+
@state = opt[:state] || ''
|
14
14
|
end
|
15
15
|
|
16
16
|
def guess(code)
|
@@ -49,9 +49,6 @@ module Codeguessing
|
|
49
49
|
new_k = k.to_s.gsub('@','').to_sym
|
50
50
|
hash[new_k] = self.instance_variable_get(k)
|
51
51
|
end
|
52
|
-
hash.delete(:scores)
|
53
|
-
hash.delete(:result)
|
54
|
-
hash.delete(:state)
|
55
52
|
hash
|
56
53
|
end
|
57
54
|
|
data/lib/codeguessing/scores.yml
CHANGED
@@ -1,42 +1,6 @@
|
|
1
1
|
---
|
2
|
-
- :
|
3
|
-
:attempts: 5
|
4
|
-
:hint_count: 2
|
5
|
-
:name: Yaroslav
|
6
|
-
- :secret_code: '1121'
|
7
|
-
:attempts: 5
|
8
|
-
:hint_count: 2
|
9
|
-
:name: Yaroslav
|
10
|
-
- :secret_code: '2562'
|
11
|
-
:attempts: 5
|
12
|
-
:hint_count: 2
|
13
|
-
:name: Yaroslav
|
14
|
-
- :secret_code: '3445'
|
15
|
-
:attempts: 5
|
16
|
-
:hint_count: 2
|
17
|
-
:name: Yaroslav
|
18
|
-
- :secret_code: '2163'
|
19
|
-
:attempts: 0
|
20
|
-
:hint_count: 0
|
21
|
-
:name: Yaroslav
|
22
|
-
- :secret_code: '1234'
|
23
|
-
:attempts: 4
|
24
|
-
:hint_count: 2
|
25
|
-
:name: dasdad
|
26
|
-
- :secret_code: '1234'
|
27
|
-
:attempts: 4
|
28
|
-
:hint_count: 2
|
29
|
-
:name: Y
|
30
|
-
- Anonim
|
31
|
-
- :secret_code: '1234'
|
32
|
-
:attempts: 4
|
33
|
-
:hint_count: 2
|
34
|
-
:name: Anonim
|
35
|
-
- :name: Anonim
|
2
|
+
- :name: Yaroslav
|
36
3
|
:secret_code: '1234'
|
37
4
|
:attempts: 4
|
38
5
|
:hint_count: 2
|
39
|
-
|
40
|
-
:secret_code: '1234'
|
41
|
-
:attempts: 2
|
42
|
-
:hint_count: 4
|
6
|
+
:state: true
|
data/lib/codeguessing/version.rb
CHANGED