codebreaker234 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1986c09597fe6612e7c03d8d76a2e8de83842e1b
4
- data.tar.gz: 22107e316bb77ccf895583588b696a25d298d58b
3
+ metadata.gz: 99296c1d34150f88b7ee85ed38cea9e85811f2c3
4
+ data.tar.gz: ed780aa2cc8ecbec7a115da5ea3b71a28e2dc7fc
5
5
  SHA512:
6
- metadata.gz: 85685c9e5f0ebcd91bf87e2a8d7c4f2e0f285833f8c0ae6131f7619096c3b3f2a43dff095950abdbc1f93d2adf4ef468cefac3747158886fb9ba50cb85c15f8b
7
- data.tar.gz: 175c2e9962703cf79d4a6ece8b2d3c414645c380b81fe0f32e59aaa74f541d458aa299d195e02c506b116cc4ecf868d1da4ed45d176e5fdc06e19ef663d662b1
6
+ metadata.gz: 82ea1191e89fae6e1341a7d5b57dae706e7ffaba7d45859d73f505cc1f9ab072e623320dea74d0dd1c089aef4cec651f580c4232bd06c3188e61a8dea91e3435
7
+ data.tar.gz: 8510fed324151e97783de171e0bd1bc693b40753e0022e7927d397cdad6bb9d74752d7aaf177bc4ead45db927a87ca561499ee333b871f571eb71fbe70a91a45
@@ -22,27 +22,42 @@ module Codebreaker234
22
22
 
23
23
  def mark_user_guess(user_input)
24
24
  answer = ""
25
- tmp_code = ""
26
25
  tmp_input = ""
26
+ tmp_code = ""
27
27
  for i in 0...SECRET_CODE_LENGTH
28
28
  if user_input[i] == @secret_code[i]
29
- tmp_code << "+"
30
- tmp_input << "+"
29
+ answer << "+"
31
30
  else
32
31
  tmp_input << user_input[i]
33
32
  tmp_code << @secret_code[i]
34
33
  end
35
34
  end
36
- for i in 0...SECRET_CODE_LENGTH
37
- if tmp_input[i] == tmp_code[i]
38
- answer << "+"
39
- elsif tmp_code.include? tmp_input[i]
40
- answer << "-"
41
- end
42
- end
35
+ if tmp_code.size > 0
36
+ for i in 0...tmp_code.size
37
+ if tmp_code.include? tmp_input[i]
38
+ answer << "-"
39
+ end
40
+ end
41
+ end
43
42
  return answer
44
43
  end
45
44
 
45
+ def analize(user_input)
46
+ marked_guess = mark_user_guess(user_input)
47
+ if user_input.match(/^[1-6]{4}$/)
48
+ user_guesses_and_answers << {user_input => marked_guess}
49
+ decrease_avaliable_turns
50
+ else
51
+ user_guesses_and_answers << {user_input => "Wrong guess. Pls enter exectly 4 numbers. Each from 1 to 6."}
52
+ end
53
+
54
+ if marked_guess == "++++"
55
+ game_status = "win"
56
+ elsif number_of_turns <= 0
57
+ game_status = "lose"
58
+ end
59
+ end
60
+
46
61
  def hint
47
62
  hint = "****"
48
63
  hint[@hint_position] = @secret_code[@hint_position]
@@ -1,3 +1,3 @@
1
1
  module Codebreaker234
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebreaker234
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MaxKotsarev