Overview
ThePOST /game/{id}/play endpoint allows you to play moves in an active Blackjack game. You can either HIT (draw another card) or STAND (end your turn and let the dealer play).
Endpoint
Path Parameters
The unique identifier of the game
Request Body
The move to play. Must be either
HIT or STAND (case-insensitive)Response
Returns a200 OK status with the updated game state (same structure as GET /game/):
The game identifier
The player identifier
Updated game status after the move
Player’s current hand score
Dealer’s score (partial if game still in progress, full if game ended)
Array of card objects representing the player’s hand
Array of card objects representing the dealer’s hand (some cards may be hidden if game is in progress)
Move Actions
HIT
Draws one additional card from the deck and adds it to your hand. What happens:- A card is drawn from the deck
- The card is added to your hand
- Your score is recalculated
- If your score exceeds 21, you bust and the game ends with status
DEALER_WINS - If you don’t bust, the game remains
IN_PROGRESSand you can make another move
STAND
Ends your turn and triggers the dealer’s play sequence. What happens:- Your turn ends (no more cards drawn for you)
- The dealer automatically draws cards until reaching a score of 17 or higher
- The game outcome is determined:
- If dealer busts (score > 21): status becomes
PLAYER_WINS - If dealer score > player score: status becomes
DEALER_WINS - If player score > dealer score: status becomes
PLAYER_WINS - If scores are equal: status becomes
PUSH(tie)
- If dealer busts (score > 21): status becomes
- Player ranking stats are updated (wins/losses)
Game Flow Example
1. Initial State (after creating game)
2. After HIT (score still under 21)
3. After STAND (game ends)
Game Status Transitions
Possible status values after playing a move:IN_PROGRESS- Game continues, you can make another movePLAYER_BUST- You exceeded 21 (transitions toDEALER_WINS)DEALER_BUST- Dealer exceeded 21 (transitions toPLAYER_WINS)PLAYER_WINS- You won (higher score or dealer bust)DEALER_WINS- Dealer won (higher score or you bust)PUSH- Tie (same final score)
Error Responses
400 Bad Request
Returned when the action is invalid:404 Not Found
Returned when the game doesn’t exist:409 Conflict
Returned when trying to play a move on a finished game:Implementation Details
The move logic is handled byPlayMoveUseCase.java:24-32:
PlayMoveUseCase.java:41-54).
Next Steps
- View the current game state at any time
- Delete the game when you’re done
- Check the player ranking to see your stats