Skip to content

Repository files navigation

Codebreaker Build Status

Codebreaker is a logic game in which a 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.

Installation

Add this line to your application's Gemfile:

gem'codebreaker',:git=>"git://github.com/gremax/codebreaker"

And then execute:

$ bundle

Usage

Start an example console game:

$ bundle --binstubs
$ bundle exec bin/codebreaker

Or write own:

require"bundler/setup"require"codebreaker"Attempts=10game=Codebreaker::Game.new(Attempts)game.startloopdoputs"\nEnter guess (? for help):"guess=gets.chompcaseguesswhen"hint"putsgame.hintwhen"start"game.startwhen"scores"beginputs"Score table:".underlinegame.scores.eachdo |s|
puts"/ #{s.username} / Attempts: #{s.attempts} / Time: #{(s.finish_at - s.start_at).to_i}s."endrescue=>eputseendwhen""exitelsebeginsubmit=game.submit(guess)rescue=>eputsenextendputssubmitifsubmit == "Game over" || submit == "++++"puts"\nSave your score? (y/n)"casegets.chompwhen"y"puts"Enter username:"game.save(gets.chomp)endputs"\nRestart Codebreaker? (y/n)"casegets.chompwhen"y"game.startwhen"n"puts"Bye!"exitendendendend

Tests

$ bundle exec rspec

Or

$ bundle exec rake

Rake

 $ rake -T db
rake db:remove # Remove database file
rake db:reset # Reset database

Contributing

  1. Fork it ( https://github.com/gremax/codebreaker/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Codebreaker is a logic game

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages