rav_codebreaker 0.1.3 → 0.2.0

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: 60b94583302c16075ecdaefb98e2df8f624ddc63
4
- data.tar.gz: 5077cb28e8a30f6742022b1ac54dd01b2f2a8b6a
3
+ metadata.gz: 5079fdd286b831dab2386879b8fb368d14d674d5
4
+ data.tar.gz: c4926ecfc3b2ca1557c1c8a0c36b61028365057e
5
5
  SHA512:
6
- metadata.gz: f225552172bbe2858c4a9e1c9baadf5ee09344ffbaa6952ca4ae5c40a4aee6f894303bbb477789f2a6130acc0f2b3442e88c0b5f4b98d05afe59e6bb5de6af7c
7
- data.tar.gz: 262acf349d1c6ffb8496eb4f7fea9be6bf4f29127f65eaf8c19258f5738d3d5e6b1967fa65e4ec2c0021b9d7151ec20fc66ab84c448115c8ec6b0c0869a4afcf
6
+ metadata.gz: 908b3086dfd89f4a4541c2db901e147c3bf27d20583aabfb2faf8f44911f4f2900cdc28c02976b6e93f3c73921bfc2fa60afcd12efe8a81bf7867083a9668af0
7
+ data.tar.gz: b2ac970cacd6c6d964bc04c32f1dd4f040f9e51e263b0e6bf8c8c13210d9faa25c74434b221b7d752cd5460ba726c80873b5c1478f96b6e5717674361db6de8e
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /.bundle
2
+ .rspec
3
+ /tmp
4
+ /pkg
5
+ /.score.dat
6
+
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rav_codebreaker.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rav_codebreaker.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rav_codebreaker (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ colorize (0.8.1)
10
+ diff-lcs (1.2.5)
11
+ rake (10.4.2)
12
+ rspec (3.5.0)
13
+ rspec-core (~> 3.5.0)
14
+ rspec-expectations (~> 3.5.0)
15
+ rspec-mocks (~> 3.5.0)
16
+ rspec-core (3.5.4)
17
+ rspec-support (~> 3.5.0)
18
+ rspec-expectations (3.5.0)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.5.0)
21
+ rspec-mocks (3.5.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.5.0)
24
+ rspec-support (3.5.0)
25
+
26
+ PLATFORMS
27
+ x86-mingw32
28
+
29
+ DEPENDENCIES
30
+ bundler (~> 1.13)
31
+ colorize
32
+ rake (~> 10.0)
33
+ rav_codebreaker!
34
+ rspec
35
+
36
+ BUNDLED WITH
37
+ 1.13.6
data/README.md CHANGED
@@ -1,42 +1,42 @@
1
- # RavCodebreaker
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rav_codebreaker`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- The logic game in which a code-breaker tries to break a secret code created by a code-maker.
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'rav_codebreaker'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install rav_codebreaker
22
-
23
-
24
- ## Usage
25
-
26
- require "rav_codebreaker"
27
- RavCodebreaker.play(:beginner || :expert || : master)
28
-
29
- ## Development
30
-
31
- After checking out the repo, run `bin/setup` to install dependencies.
32
- You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
-
34
- To install this gem onto your local machine, run `bundle exec rake install`.
35
- To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
36
- which will create a git tag for the version, push git commits and tags,
37
- and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
-
39
- ## Contributing
40
-
41
- Bug reports and pull requests are welcome on GitHub at https://github.com/romanenko1976/CodeBreaker
42
-
1
+ # RavCodebreaker
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rav_codebreaker`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ The logic game in which a code-breaker tries to break a secret code created by a code-maker.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rav_codebreaker'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rav_codebreaker
22
+
23
+
24
+ ## Usage
25
+
26
+ require "rav_codebreaker"
27
+ RavCodebreaker.play(:beginner || :expert || : master)
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies.
32
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake install`.
35
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
36
+ which will create a git tag for the version, push git commits and tags,
37
+ and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/romanenko1976/CodeBreaker
42
+
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "rav_codebreaker"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rav_codebreaker"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/game.example CHANGED
@@ -1,50 +1,40 @@
1
1
  ================================================================================
2
2
  Welcome to play the CodeBreaker Game!!!
3
3
  ================================================================================
4
- Try to guess the secret code! You have 10 attempts and 0 hints. Good luck!
5
- Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):
6
- h
7
- Sorry, but you have not any hints :(
8
- Try to guess the secret code! You have 10 attempts and 0 hints. Good luck!
4
+
5
+ Try to guess the secret code!
6
+ You have 20 attempts and 2 hints. Good luck!
9
7
  Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):
10
8
  1111
11
- You result is ""!
12
- Try to guess the secret code! You have 9 attempts and 0 hints. Good luck!
13
- Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):
14
- 2222
15
- You result is ""!
16
- Try to guess the secret code! You have 8 attempts and 0 hints. Good luck!
9
+ You result is "++"!
10
+ Try to guess the secret code!
11
+ You have 19 attempts and 2 hints. Good luck!
17
12
  Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):
18
- 3333
19
- You result is "+"!
20
- Try to guess the secret code! You have 7 attempts and 0 hints. Good luck!
21
- Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):
22
- 3444
23
- You result is "+-"!
24
- Try to guess the secret code! You have 6 attempts and 0 hints. Good luck!
25
- Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):
26
- 4355
27
- You result is "--"!
28
- Try to guess the secret code! You have 5 attempts and 0 hints. Good luck!
13
+ h
14
+ I exactly know that a number 6 is at position #3 (remember, it starts from 0).
15
+
16
+ Try to guess the secret code!
17
+ You have 19 attempts and 1 hints. Good luck!
29
18
  Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):
30
- 6643
31
- You result is "++--"!
32
- Try to guess the secret code! You have 4 attempts and 0 hints. Good luck!
19
+ 1126
20
+ You result is "+++"!
21
+ Try to guess the secret code!
22
+ You have 18 attempts and 1 hints. Good luck!
33
23
  Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):
34
- 6634
24
+ 1136
35
25
  You result is "++++"!
36
26
  We congratulate you on your victory!!!
37
27
  "Do you want to save your results (Y/N)?
38
28
  y
39
29
  Enter your name, please...
40
- Kiril
30
+ Henry
41
31
  --------------------------------------------------
42
32
  | ## | player name | game level | turns | hints |
43
33
  --------------------------------------------------
44
- | 1 | John | beginner | 5 | 1 |
45
- | 2 | roll | beginner | 5 | 2 |
46
- | 3 | Kiril | expert | 7 | 0 |
47
- | 4 | Andrey | beginner | 8 | 0 |
34
+ | 1 | Henry | beginner | 3 | 1 |
35
+ | 2 | Kiril | beginner | 3 | 2 |
36
+ | 3 | Andrey | expert | 5 | 0 |
37
+ | 4 | Semen | beginner | 6 | 2 |
48
38
  --------------------------------------------------
49
39
  Do you want to play again (Y or N)
50
- n
40
+ n
data/lib/play_test.rb CHANGED
@@ -4,4 +4,4 @@ module Test
4
4
  extend RavCodebreaker
5
5
  end
6
6
 
7
- RavCodebreaker::play('beginner')
7
+ RavCodebreaker::play(:beginner)
@@ -1,12 +1,21 @@
1
1
  require_relative 'rav_codebreaker/version'
2
2
  require_relative 'rav_codebreaker/game'
3
+ require_relative 'rav_codebreaker/console'
3
4
 
4
5
  module RavCodebreaker
5
- def self.play(level)
6
+ def self._play(level)
6
7
  begin
7
8
  game = Game.new(level)
8
9
  game.play
9
10
  end while game.again?
10
11
  end
12
+
13
+ def self.play(level)
14
+ begin
15
+ console = Console.new(level)
16
+ console.play
17
+ end while console.again?
18
+ end
19
+
11
20
  end
12
21
 
@@ -0,0 +1,123 @@
1
+ require 'colorize'
2
+ module RavCodebreaker
3
+ class Console
4
+ SCORES_FILE_NAME = './score.dat'
5
+
6
+ def initialize(level = :expert)
7
+ @score = []
8
+ @game = Game.new(level)
9
+ end
10
+
11
+ def play
12
+ @game.start
13
+ welcome_message
14
+ loop do
15
+ puts @game.format_error? ? incorrect_message : invitation_message
16
+ get_offer
17
+ exit if @game.exit?
18
+ show_hint if @game.show_hint?
19
+ next if @game.show_hint? || @game.format_error?
20
+ show_result_message
21
+ show_winner_message if win?
22
+ @game.next_turn
23
+ show_gameover_message if @game.game_over?
24
+ break if win? || @game.game_over?
25
+ end
26
+ load_scores_from_file
27
+ save_results
28
+ show_results
29
+ end
30
+
31
+ def get_offer
32
+ @game.offer = gets.chomp
33
+ end
34
+
35
+ def win?
36
+ @game.win?
37
+ end
38
+
39
+ def again?
40
+ puts 'Do you want to play again (Y or N)'.bold
41
+ gets =~ /y|Y/
42
+ end
43
+
44
+ def welcome_message
45
+ puts '='*80
46
+ puts 'Welcome to play the CodeBreaker Game!!!'.green
47
+ puts '='*80
48
+ end
49
+
50
+ def invitation_message
51
+ "Try to guess the secret code!\n"+
52
+ "You have #{@game.turns_left} attempts and #{@game.hints_left} hints. Good luck!\n" +
53
+ "Enter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):"
54
+ end
55
+
56
+ def incorrect_message
57
+ "\nincorrect number format, try again, please..."
58
+ end
59
+
60
+ def show_result_message
61
+ puts "You result is \"#{@game.decode_offer}\"!".green
62
+ end
63
+
64
+ def show_gameover_message
65
+ puts "Sorry, you lose the game :(\nThe secret code was #{@game.secret_code}.".red
66
+ end
67
+
68
+ def show_winner_message
69
+ puts 'We congratulate you on your victory!!!'.green
70
+ end
71
+
72
+ def show_hint
73
+ hint = @game.get_hint
74
+ if hint
75
+ puts "I exactly know that a number #{hint.first} is at position ##{hint.last} (remember, it starts from 0).\n".green
76
+ else
77
+ puts 'Sorry, but you have not any hints :('.red
78
+ end
79
+ end
80
+
81
+ def load_scores_from_file
82
+ return unless File.exist? SCORES_FILE_NAME
83
+ File.open(SCORES_FILE_NAME) do |file|
84
+ @score = Marshal.load(file)
85
+ end
86
+ end
87
+
88
+ def save_scores_to_file
89
+ File.open(SCORES_FILE_NAME, 'w+') do |file|
90
+ Marshal.dump(@score, file)
91
+ end
92
+ end
93
+
94
+ def show_results
95
+ @score.sort_by!{|player| player[:turns]}
96
+ format_str = "| %02s | %12s | %10s | %5s | %5s |"
97
+ format_str_length = 50
98
+ puts '-' * format_str_length
99
+ puts format_str % %w(## player\ name game\ level turns hints)
100
+ puts '-' * format_str_length
101
+ @score.each_with_index do |player, index|
102
+ arr = [index + 1] + player.values
103
+ puts format_str % arr
104
+ end
105
+ puts '-' * format_str_length
106
+ end
107
+
108
+ def save_results
109
+ puts '"Do you want to save your results (Y/N)?'
110
+ return if gets !~ /y|Y/
111
+ player = {}
112
+ begin
113
+ puts 'Enter your name, please...'
114
+ player[:name] = gets.chomp
115
+ end while player[:name].empty?
116
+ player[:level] = @game.level
117
+ player[:turns] = Game::TURNS_COUNT[@game.level] - @game.turns_left
118
+ player[:hints] = Game::HINTS_COUNT[@game.level] - @game.hints_left
119
+ @score << player
120
+ save_scores_to_file
121
+ end
122
+ end
123
+ end
@@ -2,15 +2,14 @@ module RavCodebreaker
2
2
  class Game
3
3
  TURNS_COUNT = {expert: 10, master: 15, beginner: 20}
4
4
  HINTS_COUNT = {expert: 0, master: 1, beginner: 2}
5
- SCORES_FILE_NAME = './score.dat'
6
5
 
7
- attr_reader :turns_left, :hints_left, :offer
6
+ attr_reader :turns_left, :hints_left, :secret_code, :level
7
+ attr_accessor :offer
8
8
 
9
9
  def initialize(level = :expert)
10
10
  @secret_code = ''
11
11
  @turns_left = 0
12
12
  TURNS_COUNT.keys.include?(level) ? @level = level : @level = :expert
13
- @score = []
14
13
  end
15
14
 
16
15
  def start
@@ -20,46 +19,6 @@ module RavCodebreaker
20
19
  @offer = '6666'
21
20
  end
22
21
 
23
- def play
24
- start
25
- welcome_message
26
- loop do
27
- puts format_error? ? incorrect_message : invitation_message
28
- get_offer
29
- exit if exit?
30
- next if show_hint? || format_error?
31
- test_offer
32
- show_winner_message if win?
33
- show_game_over_message if game_over?
34
- break if win? || game_over?
35
- end
36
- load_scores_from_file
37
- save_results
38
- show_results
39
- end
40
-
41
- def again?
42
- puts 'Do you want to play again (Y or N)'
43
- gets =~ /y|Y/
44
- end
45
-
46
- #private
47
-
48
- def welcome_message
49
- puts '='*80
50
- puts 'Welcome to play the CodeBreaker Game!!!'
51
- puts '='*80
52
- end
53
-
54
- def invitation_message
55
- "Try to guess the secret code! You have #{@turns_left} attempts and #{@hints_left} hints. Good luck!" +
56
- "\nEnter you four numbers code (from 1 to 6), please (or Q - for exit, H - for hint):"
57
- end
58
-
59
- def incorrect_message
60
- "\nincorrect number format, try again, please..."
61
- end
62
-
63
22
  def decode_offer
64
23
  code = @secret_code.split('')
65
24
  offer = @offer.split('')
@@ -69,13 +28,15 @@ module RavCodebreaker
69
28
  '+' * code.count(nil) + '-' * code.count('-')
70
29
  end
71
30
 
72
- def get_offer
73
- @offer = gets.chomp
31
+ def get_hint
32
+ return nil if @hints_left < 1
33
+ @hints_left -= 1
34
+ pos = rand(4)
35
+ [@secret_code[pos], pos]
74
36
  end
75
37
 
76
- def test_offer
38
+ def next_turn
77
39
  @turns_left -= 1
78
- puts "You result is \"#{decode_offer}\"!"
79
40
  end
80
41
 
81
42
  def win?
@@ -94,66 +55,8 @@ module RavCodebreaker
94
55
  @turns_left < 1
95
56
  end
96
57
 
97
- def show_game_over_message
98
- puts "Sorry, you lose the game :(\nThe secret code was #{@secret_code}."
99
- end
100
-
101
- def show_winner_message
102
- puts 'We congratulate you on your victory!!!'
103
- end
104
-
105
58
  def show_hint?
106
- return false unless @offer =~ /^[hH]$/
107
- if @hints_left < 1
108
- puts 'Sorry, but you have not any hints :('
109
- else
110
- @hints_left -= 1
111
- pos = rand(4)
112
- puts "I exactly know that a number #{@secret_code[pos]} is at position ##{pos} (remember, it starts from 0)."
113
- end
114
- true
115
- end
116
-
117
- def load_scores_from_file
118
- return unless File.exist? SCORES_FILE_NAME
119
- File.open(SCORES_FILE_NAME) do |file|
120
- @score = Marshal.load(file)
121
- end
122
- end
123
-
124
- def save_scores_to_file
125
- File.open(SCORES_FILE_NAME, 'w+') do |file|
126
- Marshal.dump(@score, file)
127
- end
128
- end
129
-
130
- def show_results
131
- @score.sort_by!{|player| player[:turns]}
132
- format_str = "| %02s | %12s | %10s | %5s | %5s |"
133
- format_str_length = 50
134
- puts '-' * format_str_length
135
- puts format_str % %w(## player\ name game\ level turns hints)
136
- puts '-' * format_str_length
137
- @score.each_with_index do |player, index|
138
- arr = [index + 1] + player.values
139
- puts format_str % arr
140
- end
141
- puts '-' * format_str_length
142
- end
143
-
144
- def save_results
145
- puts '"Do you want to save your results (Y/N)?'
146
- return if gets !~ /y|Y/
147
- player = {}
148
- begin
149
- puts 'Enter your name, please...'
150
- player[:name] = gets.chomp
151
- end while player[:name].empty?
152
- player[:level] = @level
153
- player[:turns] = TURNS_COUNT[@level] - @turns_left
154
- player[:hints] = HINTS_COUNT[@level] - @hints_left
155
- @score << player
156
- save_scores_to_file
59
+ @offer =~ /^[hH]$/
157
60
  end
158
61
  end
159
62
  end
@@ -1,3 +1,3 @@
1
1
  module RavCodebreaker
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,35 +1,36 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rav_codebreaker/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "rav_codebreaker"
8
- spec.version = RavCodebreaker::VERSION
9
- spec.authors = ["Andrii Romanenko"]
10
- spec.email = ["roand@ukr.net"]
11
-
12
- spec.summary = %q{Codebreaker Game}
13
- spec.description = %q{The logic game in which a code-breaker tries to break a secret code created by a code-maker.}
14
- # spec.homepage = "TODO: Put your gem's website or public repo URL here."
15
-
16
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
18
- if spec.respond_to?(:metadata)
19
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
- else
21
- raise "RubyGems 2.0 or newer is required to protect against " \
22
- "public gem pushes."
23
- end
24
-
25
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
- f.match(%r{^(test|spec|features)/})
27
- end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
32
- spec.add_development_dependency "bundler", "~> 1.13"
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "rspec"
35
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rav_codebreaker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rav_codebreaker"
8
+ spec.version = RavCodebreaker::VERSION
9
+ spec.authors = ["Andrii Romanenko"]
10
+ spec.email = ["roand@ukr.net"]
11
+
12
+ spec.summary = %q{Codebreaker Game}
13
+ spec.description = %q{The logic game in which a code-breaker tries to break a secret code created by a code-maker.}
14
+ # spec.homepage = "TODO: Put your gem's website or public repo URL here."
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.13"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec"
35
+ spec.add_development_dependency "colorize"
36
+ end
data/spec.example ADDED
@@ -0,0 +1,56 @@
1
+ C:\_RUBY_\CodeBreaker>rspec
2
+
3
+ RavCodebreaker::Game
4
+ #Start
5
+ generates secret code
6
+ saves 4 numbers secret code
7
+ saves secret code with numbers from 1 to 6
8
+ generates uniq secret code for different games
9
+ with Error level
10
+ starts with Master Level settings
11
+ with Beginner level
12
+ gives up to 20 attempts to guess the secret code
13
+ gives up to 2 hints to guess the secret code
14
+ with Master level
15
+ gives up to 20 attempts to guess the secret code
16
+ gives only 1 hints to guess the secret code
17
+ with Expert level
18
+ gives up to 10 attempts to guess the secret code
19
+ no gives hints to guess the secret code
20
+ #decode_offer
21
+ for secret code 1234 and offer 3333 must be "+"
22
+ for secret code 1111 and offer 3333 must be ""
23
+ for secret code 1234 and offer 2122 must be "--"
24
+ for secret code 1234 and offer 4216 must be "+--"
25
+ for secret code 1234 and offer 4321 must be "----"
26
+ for secret code 1122 and offer 1221 must be "++--"
27
+ for secret code 1313 and offer 3412 must be "+-"
28
+ #next_turn
29
+ decrease @turns_left variable after each test
30
+ #format_error?
31
+ return false if code-breakers answer has correct format
32
+ return true if code-breakers answer has less then 4 numbers
33
+ return true if code-breakers answer has more then 4 numbers
34
+ return true if code-breakers answer contains incorrect numbers
35
+ return false if code-breakers answer equal 'H' or 'h'
36
+
37
+ RavCodebreaker::Console
38
+ #again?
39
+ return false if a player enter N
40
+ return true if a player enter Y
41
+ return false if a player enter empty string
42
+ #play with Beginner level
43
+ finish the game after enter a correct answer
44
+ finish the game after 20 failure attempts
45
+ gives 2 hints for help
46
+ #play with Master level
47
+ finish the game after enter a correct answer
48
+ finish the game after 15 failure attempts
49
+ gives 1 hints for help
50
+ #play with Expert level
51
+ finish the game after enter a correct answer
52
+ finish the game after 10 failure attempts
53
+ gives 0 hints for help
54
+
55
+ Finished in 0.14 seconds (files took 0.72 seconds to load)
56
+ 36 examples, 0 failures
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rav_codebreaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrii Romanenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-02 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: The logic game in which a code-breaker tries to break a secret code created
56
70
  by a code-maker.
57
71
  email:
@@ -60,7 +74,9 @@ executables: []
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
77
+ - ".gitignore"
63
78
  - Gemfile
79
+ - Gemfile.lock
64
80
  - README.md
65
81
  - Rakefile
66
82
  - bin/console
@@ -69,9 +85,11 @@ files:
69
85
  - lib/play_codebreaker.rb
70
86
  - lib/play_test.rb
71
87
  - lib/rav_codebreaker.rb
88
+ - lib/rav_codebreaker/console.rb
72
89
  - lib/rav_codebreaker/game.rb
73
90
  - lib/rav_codebreaker/version.rb
74
91
  - rav_codebreaker.gemspec
92
+ - spec.example
75
93
  homepage:
76
94
  licenses: []
77
95
  metadata: