nicolaViola / slotmachine

1 stars 0 forks source link

Slotmachine

This project implements a slotmachine game. Through a web interface you will receive three cards and if they are equal you will win

State-of-the-art

slotmachine implementation

The slotmachine is implemented by a State Pattern. There are four states and every state can execute one or more operations to make the slotmachine change to a new state. When the slotmachine starts, it is in a NoCoin state.

Alt text

As you can see from the above picture, the edges are the operation that a state can execute.

The real game is played in the GAME state. A Croupier object, which knows the rules of the game, is injected into the GAME state. This croupier implementation can give you three random cards from a sixteen-card pack. If the croupier gives you three equal cards you will win. Each new player will have three chances to win.

Alt text

controller implementation

The controller is implemented like a Spring REST service. It exposes the methods to make the slotmachine change state. It implements a Template Pattern to execute the operation. Alt text

code

The code is made up of four components:

Build

Use the following to build/startup backend:

$ git clone https://github.com/nicolaViola/slotmachine.git
$ cd slotmachine
$ mvn spring-boot:run

then access the Testing and documentation Swagger application through http://localhost:8080/swagger-ui.html

testing and documentation

The Rest service is documented by Swagger (http://swagger.io/) so you can also test it. You can try it following this url: http://localhost:8080/swagger-ui.html You will have an endpoints list. A lot of those come from Spring Boot Actuator but the " machine-controller : Machine Controller " endpoint will enable you to test the game. Every method matches with the operation of the game.

As the default state is the NoCoin state, you have to:

Used Techonlogy

The project uses Spring Core, Spring Boot, Rest API with Spring MVC, Swagger

To-do List