# Table of Contents * [Scope](#scope) * [Design](#design) * [Cell](#cell) * [Dice](#dice) * [GameBoard](#gameboard) * [Gameplay](#gameplay) * [Player](#player) * [Installation](#installation) * [Runtime](#runtime) * [Dependencies](#dependencies) * [Testing](#testing) * [Gem](#gem) * [Usage](#usage) * [CLI](#cli) * [Help](help) # Scope This gem is the Ruby implementation of the `Goose Game` code-kata (for more information refer to the [OBJECTIVES](https://github.com/costajob/goose_game/blob/master/OBJECTIVES.md)). # Design The code design follows the single responsibility principle by using a dedicated class/module for any specific task. Each class exposes a minimal public API, when meaningful by using the `call` method, thus behaving like a plain `Proc` object. ## Cell The cell of the game board. They are responsible to compute the position of the player and properly display the output messages. Polymorphism is used to reduce conditional logic. ## Dice The class represents the two dice used to move players (creating a single Die class brings little benefit to the design). A factory class rolls dice with random values (within 1 to 6), constructor accepts any convertible integers, the absolute value is taken and limited to 6. ## Gameboard The board class uses a `Hash` for its data representation: this data structure grants quick access by key. ## Gameplay The main interface with the game core logic is enclosed within the `Gameplay` class: it recognizes input commands, performs actions by creating players, rolling dice and printing appropriate messages to the terminal. The whole game runs within an endless loop. ## Player The player of the game, record both current and previous position. # Installation ## Runtime This library supports from `Ruby 2.4.1` on. ## Dependencies There are no runtime dependencies, but some developments ones (testing). Just clone the repository, move to the directory and use `bundler`: ```shell bundle install ``` ## Testing The code is covered by fast, isolated unit testing. Move to the installation path and run them by: ```shell bundle exec rake ``` ## Gem The library is packaged as a `gem`. Build and install it by: ```shell gem build goose_game.gemspec ... gem install --local ./goose_game.gem ``` # Usage ## CLI The gem provides a CLI interface, once installed you will be able to start the game from the terminal: ```shell goose_game ``` ## Help The game starts with no prompts, type `help` to see the available commands: ```shell available commands: * add player * move 4, 5 * move * help * exit ```