Public Repository

Last pushed: a year ago
Short Description
Test game - Tournament
Full Description

Backend developer coding task "Social tournament service"
As a gaming website we want to implement a tournament service with a feature called "Back a friend".
Each player holds certain amount of bonus points. Website funds its players with bonus points based on all kind of activity. Bonus points can
traded to goods and represent value like real money.
One of the social products class is a social tournament. This is a competition between players in a multi-player game like poker, bingo, etc)
Entering a tournament requires a player to deposit certain amount of entry fee in bonus points. If a player has not enough point he can ask other
players to back him and get a part the prize in case of a win.
In case of multiple backers, they submit equal part of the deposit and share the winning money in the same ration.
From a technical side, the following REST service with 5 endpoints should be implemented

#1 Take and fund player account
/take?playerId=P1&points=300 takes 300 points from player P1 account
/fund?playerId=P2&points=300 funds player P2 with 300 points

#2 Announce tournament specifying the entry deposit

#3 Join player into a tournament and is he backed by a set of backers
Backing is not mandatory and a player can be play on his own money

#4 Result tournament winners and prizes
/resultTournament with a POST document in format
{"tournamentId": "1", "winners": [{"playerId": "P1", "prize": 500}]}

#5 Player balance
Example response: {"playerId": "P1", "balance": 456.00}
Full use case example:
Prepare initial balances
Tournament deposit is 1000 points
P5 joins on his own
P1 joins backed by P2, P3, P4
All of them P1, P2, P3, P4 contribute 250 points each.
P1 wins the tournament and his prize is 2000. P2 P3 P4 they all get 25% of the prize.
/resultTournament with a POST

{"winners": [{"playerId": "P1", "prize": 2000}]}
After tournament result is processed the balances for players must be as specified below
P1, P2, P3 - 550
P4 - 750
P5 - 0
Implementation must guarantee that
no player balance ever goes to zero
no point is lost due to service outage
Endpoints 1-4 must return HTTP status codes only like 2xx, 4xx, 5xx
Endpoints 5 must return json document in the format on the example above

Docker Pull Command