Compare commits

..

No commits in common. "v1.21.0" and "v1.20.1" have entirely different histories.

4 changed files with 3 additions and 12 deletions

View file

@ -7,6 +7,6 @@ Content-Type: application/json
}
###
POST http://localhost:8080/blackjack/202/hit
POST http://localhost:8080/blackjack/103/hit
Authorization: Bearer {{token}}

View file

@ -40,12 +40,6 @@ public class BlackJackGameController {
return ResponseEntity.notFound().build();
}
if (game.getState() != BlackJackState.IN_PROGRESS) {
Map<String, String> errorResponse = new HashMap<>();
errorResponse.put("error", "Invalid state");
return ResponseEntity.badRequest().body(errorResponse);
}
return ResponseEntity.ok(blackJackService.hit(game));
}

View file

@ -89,14 +89,12 @@ public class BlackJackService {
if (playerHandValue == 21) {
return BlackJackState.PLAYER_WON;
} else if (playerHandValue > 21) {
return BlackJackState.PLAYER_LOST;
}
return BlackJackState.IN_PROGRESS;
}
private int calculateHandValue(List<CardEntity> hand) {
public int calculateHandValue(List<CardEntity> hand) {
int sum = 0;
int aceCount = 0;
for (CardEntity card : hand) {

View file

@ -2,6 +2,5 @@ package de.szut.casino.blackjack;
public enum BlackJackState {
PLAYER_WON,
IN_PROGRESS,
PLAYER_LOST,
IN_PROGRESS
}