Skip to content

claranet-it/goose-game-springboot-kata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Goose Game "Spring Boot" Kata

Goose game is a game where two or more players move pieces around a track by rolling a die. The aim of the game is to reach square number sixty-three before any of the other players and avoid obstacles. (wikipedia)

This kata has been invented by Matteo Vaccari, you can find the original slides here.

Your task is to build a Spring Boot Application, that implements the following features.

Features

1. Add players

As a player, I want to add me to the game so that I can play.

Scenario 1: Add Player

If there is no participant

The client sends a request

POST /players

{
   "name": "Pippo"
} 

the API replies with

HTTP/1.1 201 CREATED

{
    "players": [
        {
            "name": "Pippo
        }
    ]
}

The client sends a request


POST /players

{
   "name": "Pluto"
} 

the API replies with

HTTP/1.1 201 CREATED

{
    "players": [
        {
            "name": "Pippo
        },
        {
            "name": "Pluto"
        }
    ]
}

Scenario 2: Duplicated Player

If there is already a participant "Pippo"

The client sends a request

POST /players

{
   "name": "Pippo"
} 

the API replies with

HTTP/1.1 409 Conflict

{
    "message": "Pippo: already existing player"
}

Scenario 3: Persisting Players

The list of the current players must be stored on a database

2. Move a player

As a player, I want to move the marker on the board to make the game progress

Scenario 1: Start

If there are two participants "Pippo" and "Pluto" on space "Start"

The client sends a request

POST /rolls

{
    "playerName": "Pippo",
    "firstDiceValue": 4,
    "secondDiceValue": 2
}

the API replies with

HTTP/1.1 200 OK

{
    "playerName": "Pippo",
    "firstDiceValue": 4,
    "secondDiceValue": 2,
    "oldPosition": "Start",
    "newPosition": "6" 
}

The client sends a request

POST /rolls

{
    "playerName": "Pluto",
    "firstDiceValue": 2,
    "secondDiceValue": 2
}

the API replies with

HTTP/1.1 200 OK

{
    "playerName": "Pluto",
    "firstDiceValue": 2,
    "secondDiceValue": 2,
    "oldPosition": "Start",
    "newPosition": "4" 
}

The client sends a request

POST /rolls

{
    "playerName": "Pippo",
    "firstDiceValue": 2,
    "secondDiceValue": 3
}

the API replies with

HTTP/1.1 200 OK

{
    "playerName": "Pluto",
    "firstDiceValue": 2,
    "secondDiceValue": 3,
    "oldPosition": "6",
    "newPosition": "11" 
}

3. Win

As a player, I win the game if I land on space "63"

Scenario 1: Victory

If there is one participant "Pippo" on space "60"

The client sends a request

POST /rolls

{
   "playerName": "Pippo",
   "firstDiceValue": 1,
   "secondDiceValue": 2
}

the API replies with

HTTP/1.1 200 OK

{
   "playerName": "Pippo",
   "firstDiceValue": 1,
   "secondDiceValue": 2,
   "oldPosition": "60",
   "newPosition": "63",
   "event": "Pippo moves from 60 to 63. Pippo Wins!!"
}

Scenario 2: Winning with the exact dice shooting (a.k.a "Bouncing")

If there is one participant "Pippo" on space "60"

The client sends a request

POST /rolls

{
    "playerName": "Pippo",
    "firstDiceValue": 3,
    "secondDiceValue": 2
}

the API replies with

HTTP/1.1 200 OK

{
    "playerName": "Pippo",
    "firstDiceValue": 3,
    "secondDiceValue": 2,
    "oldPosition": "60",
    "newPosition": "61",
    "event": "Pippo moves from 60 to 63. Pippo bounces! Pippo returns to 61" 
}

4. The game gets the dice from an External Service

As a player, I want the game throws the dice for me to save effort.

A Dice Roll, that is an object that contains the two dice values, must be taken from an External RollDiceServer Web Service

POST http://<RollDiceServer_url>/diceRoll

Response

HTTP/1.1 200 OK

{
    "firstDiceValue": 2,
    "secondDiceValue": 4
}

Scenario 1: Dice roll

If there is one participant "Pippo" on space "4"
Assuming that the RollDiceServer returns 1 and 2

The client sends a request

POST /rolls

{
    "playerName": "Pippo"
}

the API replies with

HTTP/1.1 200 OK

{
    "playerName": "Pippo",
    "firstDiceValue": 1,
    "secondDiceValue": 2,
    "oldPosition": "4",
    "newPosition": "7"
}

5. Space "6" is "The Bridge"

As a player, when I get to the space "The Bridge", I jump to the space "12"

Scenario 1: Get to "The Bridge"

If there is one participant "Pippo" on space "4"
Assuming that the RollDiceServer returns 1 and 1

The client sends a request

POST /rolls

{
    "playerName": "Pippo"
}

the API replies with

HTTP/1.1 200 OK

{
    "playerName": "Pippo",
    "firstDiceValue": 1,
    "secondDiceValue": 1,
    "oldPosition": "4",
    "newPosition": "12",
    "event": "Pippo moves from 4 to The Bridge. Pippo jumps to 12" 
}

6. If you land on "The Goose", move again

As a player, when I get to a space with a picture of "The Goose", I move forward again by the sum of the two dice rolled before

The spaces 5, 9, 14, 18, 23, 27 have a picture of "The Goose"

Scenario 1: Single Jump

If there is one participant "Pippo" on space "3"
Assuming that the RollDiceServer returns 1 and 1

The client sends a request

POST /rolls

{
    "playerName": "Pippo"
}

the API replies with

HTTP/1.1 200 OK

{
    "playerName": "Pippo",
    "firstDiceValue": 1,
    "secondDiceValue": 1,
    "oldPosition": "3",
    "newPosition": "7",
    "event": "Pippo moves from 3 to 5, The Goose. Pippo moves again and goes to 7" 
}

Scenario 2: Multiple Jump

If there is one participant "Pippo" on space "10"
Assuming that the RollDiceServer returns 2 and 2

The client sends a request

POST /rolls

{
    "playerName": "Pippo"
}

the API replies with

HTTP/1.1 200 OK

{
    "playerName": "Pippo",
    "firstDiceValue": 2,
    "secondDiceValue": 2,
    "oldPosition": "10",
    "newPosition": "22",
    "event": "Pippo moves from 10 to 14, The Goose. Pippo moves again and goes to 18, The Goose. Pippo moves again and goes to 22" 
}

7. Prank (Optional Step)

As a player, when I land on a space occupied by another player, I send him to my previous position so that the game can be more entertaining.

Scenario 1: Prank

If there is one participant "Pippo" on space "10"
If there is one participant "Pluto" on space "15"
Assuming that the RollDiceServer returns 2 and 3

The client sends a request

POST /rolls

{
    "playerName": "Pippo"
}

the API replies with

{
    "playerName": "Pippo",
    "firstDiceValue": 2,
    "secondDiceValue": 3,
    "oldPosition": "10",
    "newPosition": "15",
    "event": "Pippo moves from 10 to 15. Pippo found Pluto on 15. Pluto goes back to 10" 
}

About

A code kata on the Goose Game - using Spring Boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •