codeguessing 0.4.1 → 0.4.2
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 -0
- data/lib/codeguessing/game.rb +12 -8
- data/lib/codeguessing/scores.yml +4 -0
- 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: 7ece0753557c94c9f27962f4be47bf9a65c87e07
|
4
|
+
data.tar.gz: 0f954cb55e92f23112bf842a425a0492f7e271be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 806954eb7f9db130340e8f878179afb0bd9a09dfde1a051dfe68d14e90f9816b253ddae63b2e43194ec38c6a438cc208e510450aae8c3edd0415e6e2dd507c3d
|
7
|
+
data.tar.gz: 7dac3cc93fb7fcad15a6a4d74b01a0479f57339e82df3a6b3db7c54649819075e2945ea98addb26408ab077e85ebe7bdc94be7f849211cf3233be41c16613730
|
data/lib/codeguessing/console.rb
CHANGED
data/lib/codeguessing/game.rb
CHANGED
@@ -16,15 +16,19 @@ module Codeguessing
|
|
16
16
|
def guess(code)
|
17
17
|
loose unless check?(use_attempt)
|
18
18
|
hash = {}
|
19
|
-
res = ''
|
20
|
-
|
19
|
+
res = ''
|
20
|
+
remaine_chars = code
|
21
|
+
right_chars = []
|
22
|
+
secret_code.each_char.with_index do |char, i|
|
21
23
|
case
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
when code[i] == char
|
25
|
+
res += '+'
|
26
|
+
right_chars << char
|
27
|
+
remaine_chars[i] = '*'
|
28
|
+
hash.delete(char) if right_chars.include?(char)
|
29
|
+
when remaine_chars.include?(char)
|
30
|
+
hash[char] = '-'
|
31
|
+
end
|
28
32
|
end
|
29
33
|
res += hash.values.join('')
|
30
34
|
win if res == '++++'
|
data/lib/codeguessing/scores.yml
CHANGED
data/lib/codeguessing/version.rb
CHANGED