Code Dojo #4 Christmas Special: Reindeer race
Tags: java, microservices, challenge, beginners
Published: 2019-12-11 22:45:56


# Intro

The code for this monthly challenge is at [git repository](https://github.com/nchriz/codedojo). On this month challenge there will be a complete server and a template client to communicate with the server. Unfortunately there won't be any new C++ code for this challenge.
I won't be presenting any solution for this.

# Code Dojo

This Code Dojo is a Christmas special. It's a reindeer race, who is the fastest reindeer to help Santa to deliver present to all the children. But unfortunately there is a snowstorm and the reindeer is blind.

The code is divided into two parts: Server and Client.

The Server which holds the obstacle course for the reindeer that want to compete to be on the Santa team. Client is each reindeer that want to compete. One Client will register with the Server and get a UUID that identify that reindeer. 

The Server have five endpoints
```
@RequestMapping(method = RequestMethod.POST, value = "/{id}/drawMap/{map}")
public ResponseEntity drawMap(@PathVariable(value = "id") UUID id, @PathVariable(value = "map") String map);

@RequestMapping(method = RequestMethod.POST, value = "/{id}/clear")
public ResponseEntity clearMap(@PathVariable(value = "id") UUID id);

@RequestMapping(method = RequestMethod.POST, value = "/{id}/startRace")
public ResponseEntity startRace(@PathVariable(value = "id") UUID id);

@RequestMapping(method = RequestMethod.POST, value = "/createBlindeer/{color}")
public ResponseEntity<CreateDeerDto> createBlindeer(@PathVariable(value = "color") String color);

@RequestMapping(method = RequestMethod.POST, value = "/{id}/move/{move}")
public ResponseEntity<MovedDeerDto> moveRaindeer(@PathVariable(value = "id") UUID id, @PathVariable(value = "move") Move move);
```
The master ID for the Server is: 0ef506e8-5f6b-45ed-a81a-53eab6d7eb6b.
Use this when communicating with the endpoints a Client shouldn't touch. There are three maps already implemented with two types of obstacle and one type of environment, but you are more than welcome to add as many as you like. Ice environment make the reindeer move faster in the direction it is going.

The `clear` endpoint is to wipe the screen.

`startRace` endpoint let the reindeer out of their boxes and they can start going down the course.

`createBlindeer` take a color as path variable. It can be any of the standard colors. And the response will be the ID that identify the reindeer.

`move` endpoint has two path variable: one that identify the reindeer and a move variable. Four moves are implemented: Up, Down, Left and Right. A reindeer can't move until the race have started. The response will be 200 with a body. The body will have a SUCCESS, if the movement succeeded, or a FAIL, if the reindeer bump into something. The body will also tell the coordinates where the reindeer is. 

To run the program, follow these steps:
1. Start the server - Server side
2. Draw the map - Server side
3. Create reindeer - Client side
4. Start the race - Server side
5. Move the reindeer - Client side

Set up a Server, gather some friends that each implement a Client with a pathing algorithm and see who can race down the track fastest.