cinch_hangman 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.markdown +1 -1
- data/lib/cinch_hangman/game.rb +7 -4
- data/lib/cinch_hangman/version.rb +1 -1
- data/spec/game_spec.rb +7 -0
- metadata +8 -8
data/Readme.markdown
CHANGED
data/lib/cinch_hangman/game.rb
CHANGED
@@ -12,22 +12,25 @@ module CinchHangman
|
|
12
12
|
def describe
|
13
13
|
if @guesses.empty?
|
14
14
|
"(#{hint}) hangman started."
|
15
|
-
elsif solved
|
15
|
+
elsif solved?
|
16
16
|
"(#{@answer}) was solved!"
|
17
17
|
elsif guesses_left <= 0
|
18
18
|
"(#{@answer}) was too difficult!"
|
19
19
|
else
|
20
|
-
"(#{hint}) #{guesses_left} guesses left."
|
20
|
+
"(#{hint}) #{guesses_left} guesses left, guessed: #{incorrect_guesses.join}"
|
21
21
|
end
|
22
22
|
end
|
23
|
-
def solved
|
23
|
+
def solved?
|
24
24
|
!hint.include?(MASK)
|
25
25
|
end
|
26
26
|
def guesses_left
|
27
|
-
@max_guesses -
|
27
|
+
@max_guesses - incorrect_guesses.size
|
28
28
|
end
|
29
29
|
def hint
|
30
30
|
@answer.gsub(/[^\s#{@guesses}]/, MASK)
|
31
31
|
end
|
32
|
+
def incorrect_guesses
|
33
|
+
@guesses.gsub(/[#{@answer}]/, "").split(//).sort
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
data/spec/game_spec.rb
CHANGED
@@ -43,6 +43,13 @@ describe CinchHangman::Game do
|
|
43
43
|
subject.describe.should include '3 guesses'
|
44
44
|
end
|
45
45
|
end
|
46
|
+
describe 'strikeouts' do
|
47
|
+
it 'already guessed letters' do
|
48
|
+
subject.guess("b")
|
49
|
+
subject.guess("a")
|
50
|
+
subject.describe.should include 'guessed: ab'
|
51
|
+
end
|
52
|
+
end
|
46
53
|
end
|
47
54
|
describe 'hints' do
|
48
55
|
it 'show the number of letters in the answer' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch_hangman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-12 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cinch
|
16
|
-
requirement: &
|
16
|
+
requirement: &2169564320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2169564320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2169563840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2169563840
|
36
36
|
description:
|
37
37
|
email:
|
38
38
|
- shanonmcquay@gmail.com
|
@@ -64,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
segments:
|
66
66
|
- 0
|
67
|
-
hash:
|
67
|
+
hash: 4239588220923122799
|
68
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
70
70
|
requirements:
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
segments:
|
75
75
|
- 0
|
76
|
-
hash:
|
76
|
+
hash: 4239588220923122799
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project: cinch_hangman
|
79
79
|
rubygems_version: 1.8.6
|