Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

goose_game

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

goose_game

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Table of Contents

  • Scope
  • Design
  • Installation
  • Usage

Scope

This gem is the Ruby implementation of the Goose Game code-kata (for more information refer to the OBJECTIVES).

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:

bundle install

Testing

The code is covered by fast, isolated unit testing.
Move to the installation path and run them by:

bundle exec rake

Gem

The library is packaged as a gem. Build and install it by:

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:

goose_game

Help

The game starts with no prompts, type help to see the available commands:

available commands:
* add player <player_name>
* move <player_name> 4, 5
* move <player_name>
* help
* exit

FAQs

Package last updated on 06 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc