Codebreaker is a logic game in which the code-breaker tries to break a secret code created by a code-maker. The code-maker, which will be played by the application we’re going to write, creates a secret code of four numbers between 1 and 6. This is new terminal version of a game represented as Ruby gem.
Codebreaker2018 Rack version: https://github.com/bestwebua/codebreaker-web
Add this line to your application's Gemfile:
gem 'codebreaker2018'And then execute:
$ bundle Or install it yourself as:
$ gem install codebreaker2018 Best way to demonstrate Codebreaker is auto start demo game:
require 'codebreaker' Codebreaker::Console.new- Configurator:
- Player's name
- Max attempts and hints: integers only
- Levels: :simple, :middle, :hard
- Languages: :en, :ru
- Autoloading localization by game language
- Color interface
- Ability to save results
- Ability to play again
- Ability to erase all results
- Demo mode
- Autoload localizations from locale dir
- Default language
- Ability to change locale
- Ability to use custom locale location
- Date
- Player's name
- Winner or not
- Level
- Score
- Ability to use custom game-data location
- RSpec tests have 100% code coverage
# Require Codebreaker gem require 'codebreaker' # Initialize Game instance with block game = Codebreaker::Game.new do |config| config.player_name = 'Mike' config.max_attempts = 5 config.max_hints = 2 config.level = :middle config.lang = :en end # Alternative initialize Game instance with args, args sequence: # :player_name, :max_attempts, :max_hints, :level, :lang game = Codebreaker::Game.new('Mike', 5, 2, :middle, :en) # Init Console instance with your game console = Codebreaker::Console.new(game) # Also you can auto load demo game instance and auto start it Codebreaker::Console.new # Interactive methods # Let's play! console.start_game # Erase all game statistic console.erase_scores # Static methods # Able to view current game instance into console console.game # Able to view path to yml-file console.storage_path # Able to view all game statistic console.scoresAfter checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/bestwebua/codebreaker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.