Compare commits

..

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

2 changed files with 4 additions and 11 deletions

View file

@ -42,15 +42,8 @@ public class BlackJackService {
dealerCard.setCardType(CardType.DEALER);
game.getDealerCards().add(dealerCard);
BlackJackState state = getState(game);
if (state == BlackJackState.PLAYER_BLACKJACK) {
BigDecimal blackjackWinnings = betAmount.multiply(new BigDecimal("1.5"));
user.setBalance(user.getBalance().add(blackjackWinnings));
} else {
game.setState(getState(game));
user.setBalance(user.getBalance().subtract(betAmount));
}
game.setState(state);
userRepository.save(user);
blackJackGameRepository.save(game);
@ -95,7 +88,7 @@ public class BlackJackService {
int playerHandValue = calculateHandValue(game.getPlayerCards());
if (playerHandValue == 21) {
return BlackJackState.PLAYER_BLACKJACK;
return BlackJackState.PLAYER_WON;
} else if (playerHandValue > 21) {
return BlackJackState.PLAYER_LOST;
}

View file

@ -1,7 +1,7 @@
package de.szut.casino.blackjack;
public enum BlackJackState {
PLAYER_WON,
IN_PROGRESS,
PLAYER_BLACKJACK,
PLAYER_LOST,
}