sarcasm-codebreaker 0.2.6 → 0.2.7
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.
- data/README.md +168 -1
- data/lib/codebreaker/game.rb +1 -1
- data/lib/codebreaker/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
|
@@ -1,6 +1,173 @@
|
|
|
1
1
|
# Codebreaker
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Tests
|
|
4
|
+
|
|
5
|
+
```rspec
|
|
6
|
+
Codebreaker::ConsoleInterface
|
|
7
|
+
#start
|
|
8
|
+
calls #welcome
|
|
9
|
+
calls #play
|
|
10
|
+
calls #goodbye
|
|
11
|
+
#welcome
|
|
12
|
+
displays Welcome Message
|
|
13
|
+
creates a new Game
|
|
14
|
+
#play
|
|
15
|
+
selects difficulty
|
|
16
|
+
shows difficulty
|
|
17
|
+
starts guessing
|
|
18
|
+
sets @played flag
|
|
19
|
+
displays results
|
|
20
|
+
asks for replay
|
|
21
|
+
reply "y"
|
|
22
|
+
starts over again
|
|
23
|
+
reply else
|
|
24
|
+
breakes the loop
|
|
25
|
+
#select_difficulty
|
|
26
|
+
displays difficulty info
|
|
27
|
+
asks user to input choice
|
|
28
|
+
by default
|
|
29
|
+
calls restart when played
|
|
30
|
+
otherwise
|
|
31
|
+
calls start with new difficulty
|
|
32
|
+
#difficulty_info
|
|
33
|
+
displays symbols range
|
|
34
|
+
displays symbols count
|
|
35
|
+
displays attempts
|
|
36
|
+
displays hints left
|
|
37
|
+
#guessing
|
|
38
|
+
asks for guess
|
|
39
|
+
guess
|
|
40
|
+
calls guess on Game
|
|
41
|
+
displays the response
|
|
42
|
+
hint
|
|
43
|
+
shows one of the symbols of code
|
|
44
|
+
#results
|
|
45
|
+
won game
|
|
46
|
+
displays victory text
|
|
47
|
+
shows attempts taken
|
|
48
|
+
shows result score
|
|
49
|
+
lost game
|
|
50
|
+
displays lose text
|
|
51
|
+
displays the real answer
|
|
52
|
+
#ask_for_replay
|
|
53
|
+
shows replay message
|
|
54
|
+
asks for answer
|
|
55
|
+
#goodbye
|
|
56
|
+
displays bye-bye text
|
|
57
|
+
|
|
58
|
+
Codebreaker
|
|
59
|
+
has a version number
|
|
60
|
+
|
|
61
|
+
Codebreaker::Game
|
|
62
|
+
instance
|
|
63
|
+
#start
|
|
64
|
+
resets number of attempts
|
|
65
|
+
resets number of hints
|
|
66
|
+
generates new code
|
|
67
|
+
calls generate_code method
|
|
68
|
+
changes state to :playing
|
|
69
|
+
clears @elements_revealed
|
|
70
|
+
#restart
|
|
71
|
+
calls #start with previous difficulty
|
|
72
|
+
#guess
|
|
73
|
+
decrements attempts number
|
|
74
|
+
last attempt
|
|
75
|
+
which is wrong
|
|
76
|
+
loses the game
|
|
77
|
+
secret is [1, 2, 2, 4]
|
|
78
|
+
when [1, 2, 3, 4] returns [3, 0]
|
|
79
|
+
when [1, 1, 1, 1] returns [1, 0]
|
|
80
|
+
when [6, 5, 2, 2] returns [1, 1]
|
|
81
|
+
when [3, 2, 3, 2] returns [1, 1]
|
|
82
|
+
when [4, 3, 2, 1] returns [1, 2]
|
|
83
|
+
when [5, 2, 3, 4] returns [2, 0]
|
|
84
|
+
secret is [4, 5, 6, 6]
|
|
85
|
+
when [1, 2, 3, 4] returns [0, 1]
|
|
86
|
+
when [1, 1, 1, 1] returns [0, 0]
|
|
87
|
+
when [6, 5, 2, 2] returns [1, 1]
|
|
88
|
+
when [4, 4, 4, 6] returns [2, 0]
|
|
89
|
+
when [4, 5, 6, 6] returns [4, 0]
|
|
90
|
+
when [5, 4, 6, 6] returns [2, 2]
|
|
91
|
+
secret is [1, 1, 1, 2]
|
|
92
|
+
when [1, 2, 3, 4] returns [1, 1]
|
|
93
|
+
when [1, 1, 1, 1] returns [3, 0]
|
|
94
|
+
when [6, 5, 2, 2] returns [1, 0]
|
|
95
|
+
when [1, 2, 2, 3] returns [1, 1]
|
|
96
|
+
when [1, 1, 2, 1] returns [2, 2]
|
|
97
|
+
when [5, 2, 3, 4] returns [0, 1]
|
|
98
|
+
when guess length doesn`t match code length
|
|
99
|
+
raises IndexError
|
|
100
|
+
#lost?
|
|
101
|
+
returns true when @state=:lost
|
|
102
|
+
returns false when @state!=:lost
|
|
103
|
+
#won?
|
|
104
|
+
returns true when @state=:won
|
|
105
|
+
returns false when @state!=:won
|
|
106
|
+
#hint
|
|
107
|
+
reveals one element of code
|
|
108
|
+
is unique
|
|
109
|
+
decrements number of hints left
|
|
110
|
+
when no more hints
|
|
111
|
+
raises an error
|
|
112
|
+
#win
|
|
113
|
+
changes state to :won
|
|
114
|
+
changes score
|
|
115
|
+
#lose
|
|
116
|
+
changes state to :lost
|
|
117
|
+
changes score
|
|
118
|
+
private
|
|
119
|
+
#extract_exact_matches
|
|
120
|
+
secret is [1, 2, 2, 4]
|
|
121
|
+
when [1, 2, 3, 4] returns 3
|
|
122
|
+
when [1, 1, 1, 1] returns 1
|
|
123
|
+
when [6, 5, 2, 2] returns 1
|
|
124
|
+
when [1, 2, 2, 3] returns 3
|
|
125
|
+
when [4, 3, 2, 1] returns 1
|
|
126
|
+
when [5, 2, 3, 4] returns 2
|
|
127
|
+
secret is [4, 5, 6, 6]
|
|
128
|
+
when [1, 2, 3, 4] returns 0
|
|
129
|
+
when [1, 1, 1, 1] returns 0
|
|
130
|
+
when [6, 5, 2, 2] returns 1
|
|
131
|
+
when [4, 4, 4, 6] returns 2
|
|
132
|
+
when [4, 5, 6, 6] returns 4
|
|
133
|
+
when [5, 4, 6, 6] returns 2
|
|
134
|
+
secret is [1, 1, 1, 2]
|
|
135
|
+
when [1, 2, 3, 4] returns 1
|
|
136
|
+
when [1, 1, 1, 1] returns 3
|
|
137
|
+
when [6, 5, 2, 2] returns 1
|
|
138
|
+
when [1, 2, 2, 3] returns 1
|
|
139
|
+
when [1, 1, 2, 1] returns 2
|
|
140
|
+
when [5, 2, 3, 4] returns 0
|
|
141
|
+
#extract_close_matches
|
|
142
|
+
secret is [1, 2, 2, 4]
|
|
143
|
+
when [1, 2, 3, 4] returns 3
|
|
144
|
+
when [1, 1, 1, 1] returns 1
|
|
145
|
+
when [6, 5, 2, 2] returns 2
|
|
146
|
+
when [1, 2, 2, 3] returns 3
|
|
147
|
+
when [4, 3, 2, 1] returns 3
|
|
148
|
+
when [5, 2, 3, 4] returns 2
|
|
149
|
+
secret is [4, 5, 6, 6]
|
|
150
|
+
when [1, 2, 3, 4] returns 1
|
|
151
|
+
when [1, 1, 1, 1] returns 0
|
|
152
|
+
when [6, 5, 2, 2] returns 2
|
|
153
|
+
when [4, 4, 4, 6] returns 2
|
|
154
|
+
when [4, 5, 6, 6] returns 4
|
|
155
|
+
when [5, 4, 6, 6] returns 4
|
|
156
|
+
secret is [1, 1, 1, 2]
|
|
157
|
+
when [1, 2, 3, 4] returns 2
|
|
158
|
+
when [1, 1, 1, 1] returns 3
|
|
159
|
+
when [6, 5, 2, 2] returns 1
|
|
160
|
+
when [1, 2, 2, 3] returns 2
|
|
161
|
+
when [1, 1, 2, 1] returns 4
|
|
162
|
+
when [5, 2, 3, 4] returns 1
|
|
163
|
+
#generate_code
|
|
164
|
+
by default
|
|
165
|
+
has 4 elements
|
|
166
|
+
all elements between 1..6
|
|
167
|
+
|
|
168
|
+
Finished in 0.04023 seconds (files took 0.08552 seconds to load)
|
|
169
|
+
112 examples, 0 failures
|
|
170
|
+
```
|
|
4
171
|
|
|
5
172
|
TODO: Delete this and the text above, and describe your gem
|
|
6
173
|
|
data/lib/codebreaker/game.rb
CHANGED
data/lib/codebreaker/version.rb
CHANGED