Code Monkey home page Code Monkey logo

makers_fruit_machine_ruby's Introduction

Build Status Maintainability

Makers Academy - Week 10 Solo Tech Test Practice

Fruit Machine

Test Outline | Specification | User Stories | Modelling | Installation Instructions | IRB Testing | Classes & Methods |

The Game

We are going to create a virtual fruit machine. To make things easier instead of symbols we are going to use colours: black, white, green, yellow.

Each time a player plays our fruit machine we display four 'slots' each with a randomly selected colour in each slot.

If the colours in each slot are the same then the player wins the jackpot which is all of the money that is currently in the machine.

Implement a basic machine, along with the concept of a player who has a fixed amount of money to play the machine.

Floats and prizes

Next we are now going to add a "float" to our fruit machine, this is an initial sum of money that the machine has. In addition we are going to implement a prize system.

If each slot has a different colour then the machine should pay out half the current money in the machine.

If a given play results in two or more adjacent slots containing the same colour then the machine should pay out a prize of 5 times the cost of a single play.

If the machine does not have enought money to pay a prize it should credit the player with a number of free plays equal to the difference between the full prize and the amount of money available. This does not affect a jackpot win.

Requirements

  • Each round of the game will feature a display of four 'slots' each with a randomly selected colour, black, white, green, or yellow.
  • The machine will have a float, an initial amount of money in the machine, that will be awarded along with any received money to a winning player.
  • If the colours in the four slots are the same, then the player wins the jackpot, with all the money in the machine being awarded to the player.
  • If all the colours across the four slots are different, the machine will pay out half of all the money in the machine to the player.
  • If a play results in two or more adjacent slots containing the same colour, then the machine pays out 5 times the cost of a single play.
  • If the machine does not have enough money for the prize, it should credit the player with a number of free plays equal to the difference between the full prize and the amount of money available. (This doesn't affect the jackpot prize)
As a fruit machine owner, so I can entice people to play my virtual fruit machine,
I'd like to add a float to each machine.

As a player, so I can play a game on the virtual fruit machine, 
I'd like to insert a fixed amount of money for a single play.

As a player, in a game of virtual fruit machine,
I'd like to see 4 'slots' of random colours, potentially being black, white, green, or yellow.

As a player, in a play of virtual fruit machine, 
When the colours in each adjacent slot are the same,
I'd expect to win the jackpot, and receive all the money currently inside the machine.

As a player, in a play of virtual fruit machine, 
When the colours in each every slot are different,
I'd expect to win a prize, and receive half the current money in the machine.

As a player, in a play of virtual fruit machine, 
When the colours in two or more adjacent slots are the same,
I'd expect to win a prize, and receive 5 times the cost of a single play.

Domain Model

Nouns Verbs
fruit machine play/spin
colour payout
slots insert money
jackpot
prize
money

Class Diagram

Fruit Machine Player Slots
@money @money SLOTS
@game_credits
#insert(money) #play(fruit_machine, money) #random
#pull_lever
#player_wins?
#game_jackpot?
#game_half_jackpot?
#game_adjacent_colours?
#payout

Responsiblities

Fruit Machine = Covert money into game credits, keep track of remaining credits, keep track of the machines money, display the slots, payout prizes if the player wins. Player = Keep track of money, and play the fruit machine.

Clone the repository from github then change directory into it.

$ git clone https://github.com/BenSheridanEdwards/Makers_Fruit_Machine_Ruby.git
$ cd Makers_Fruit_Machine_Ruby

Load dependencies with bundle.

$ gem install bundle
$ bundle

Run Rspec for tests and coverage, then rubocop for linting

$ rspec
$ rubocop

Load the app in IRB, require X files, create an instance of X class, then use the class methods below.

Class

Methods Description

makers_fruit_machine_ruby's People

Contributors

bensheridanedwards avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.