player gets way to many cards and I dont know why pls help

This commit is contained in:
Jan K9f 2025-03-27 12:42:40 +01:00 committed by Phan Huy Tran
parent 59562e5b64
commit 500a76dd7a
3 changed files with 8 additions and 3 deletions
backend
requests
src/main/java/de/szut/casino/blackjack

View file

@ -5,3 +5,8 @@ Content-Type: application/json
{
"betAmount": 1.01
}
###
POST http://localhost:8080/blackjack/52/hit
Authorization: Bearer {{token}}

View file

@ -43,7 +43,7 @@ public class BlackJackGameController {
// TODO validate that hit is a valid action
blackJackService.hit(game);
return ResponseEntity.ok().build();
return ResponseEntity.ok(game);
}
@PostMapping("/blackjack/start")

View file

@ -6,6 +6,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.List;
import java.util.Random;
@ -52,10 +53,9 @@ public class BlackJackService {
public BlackJackGameEntity hit(BlackJackGameEntity game) {
CardEntity drawnCard = drawCardFromDeck(game);
ArrayList<CardEntity> playerCards = (ArrayList<CardEntity>) game.getPlayerCards();
List<CardEntity> playerCards = game.getPlayerCards();
playerCards.add(drawnCard);
game.setPlayerCards(playerCards);
blackJackGameRepository.save(game);
return game;
}