Compare commits

..

24 commits

Author SHA1 Message Date
08b12d238e
feat(blackjack): add PLAYER_WON state to BlackJackState
All checks were successful
CI / Get Changed Files (pull_request) Successful in 6s
CI / eslint (pull_request) Successful in 18s
CI / test-build (pull_request) Successful in 28s
CI / prettier (pull_request) Successful in 59s
CI / Checkstyle Main (pull_request) Successful in 2m18s
2025-04-02 10:14:19 +02:00
d400986c34
refactor(blackjack): update import paths for modules 2025-04-02 10:12:29 +02:00
5d803e4b8b
feat(landing): add NavbarComponent to landing page component 2025-04-02 10:12:29 +02:00
6508a233b2
style(game-controls): fix formatting in constructor method 2025-04-02 10:12:29 +02:00
889863aad6
refactor(game-controls): update import paths for consistency 2025-04-02 10:12:29 +02:00
ba854be5db
style: fix formatting in constructor definitions 2025-04-02 10:12:29 +02:00
1d9eec4546
refactor(blackjack): update import paths for components 2025-04-02 10:12:29 +02:00
56c63d48f6
style(tsconfig): update path mappings to array syntax 2025-04-02 10:12:29 +02:00
db3d2e7b82
style(tsconfig): fix path configuration formatting 2025-04-02 10:12:29 +02:00
2a11675fb6
style: format constructor style in components 2025-04-02 10:12:28 +02:00
2405c00f49
refactor: update imports to use absolute paths 2025-04-02 10:12:28 +02:00
b4caf70ffe
refactor: update import paths for better readability 2025-04-02 10:12:28 +02:00
defe26d0c1
refactor(blackjack): move GameState to feature folder 2025-04-02 10:12:28 +02:00
2d8b137e69
style: format code and add missing newlines 2025-04-02 10:12:28 +02:00
4b569157aa
feat: add game state enum and refactor game components 2025-04-02 10:12:28 +02:00
349e4ce1ec
refactor(blackjack): remove unnecessary comments and clean code 2025-04-02 10:12:28 +02:00
deac128935
style(blackjack): format code for better readability 2025-04-02 10:12:28 +02:00
acdbea5a99
feat(blackjack): add action indicators and loading states 2025-04-02 10:12:28 +02:00
d2b22b561d
feat: add double down feature to blackjack game 2025-04-02 10:12:19 +02:00
d90fcdcf1e
feat: add stand and get game features to blackjack game 2025-04-02 10:11:26 +02:00
4e8530c861 Merge pull request 'refactor: refactor state logic' (!106) from refactor/state-logic into main
All checks were successful
Release / Release (push) Successful in 49s
Reviewed-on: #106
2025-03-27 17:25:00 +00:00
Phan Huy Tran
cb6c1550b7 refactor: refactor state logic
All checks were successful
CI / Get Changed Files (pull_request) Successful in 9s
CI / eslint (pull_request) Has been skipped
CI / prettier (pull_request) Has been skipped
CI / test-build (pull_request) Has been skipped
CI / Checkstyle Main (pull_request) Successful in 54s
2025-03-27 15:46:07 +01:00
ed6071a0ba Merge pull request 'feat: add balance when player wins with blackjack in first round' (!104) from feat/blackjack-win-on-start into main
All checks were successful
Release / Release (push) Successful in 1m12s
Reviewed-on: #104
Reviewed-by: Jan K9f <jan@kjan.email>
2025-03-27 13:34:38 +00:00
Phan Huy Tran
ffd651d74b feat: add balance when player wins gets blackjack in first round
All checks were successful
CI / Get Changed Files (pull_request) Successful in 30s
CI / eslint (pull_request) Has been skipped
CI / prettier (pull_request) Has been skipped
CI / test-build (pull_request) Has been skipped
CI / Checkstyle Main (pull_request) Successful in 1m19s
2025-03-27 14:18:03 +01:00
4 changed files with 18 additions and 5 deletions

View file

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

View file

@ -96,7 +96,6 @@ public class BlackJackService {
return game;
}
private BlackJackGameEntity refreshGameState(BlackJackGameEntity game) {
return blackJackGameRepository.findById(game.getId()).orElse(game);
}
@ -205,7 +204,20 @@ public class BlackJackService {
int playerHandValue = calculateHandValue(game.getPlayerCards());
if (playerHandValue == 21) {
return BlackJackState.PLAYER_WON;
CardEntity hole = drawCardFromDeck(game);
hole.setCardType(CardType.DEALER);
game.getDealerCards().add(hole);
int dealerHandValue = calculateHandValue(game.getDealerCards());
if (dealerHandValue == 21) {
return BlackJackState.DRAW;
} else {
BigDecimal blackjackWinnings = game.getBet().multiply(new BigDecimal("1.5"));
UserEntity user = getUserWithFreshData(game.getUser());
user.setBalance(user.getBalance().add(blackjackWinnings));
return BlackJackState.PLAYER_BLACKJACK;
}
} else if (playerHandValue > 21) {
return BlackJackState.PLAYER_LOST;
}
@ -216,7 +228,6 @@ public class BlackJackService {
private int calculateHandValue(List<CardEntity> hand) {
int sum = 0;
int aceCount = 0;
for (CardEntity card : hand) {
sum += card.getRank().getValue();
if (card.getRank() == Rank.ACE) {

View file

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

View file

@ -31,6 +31,7 @@ public class CardEntity {
private Rank rank;
@Enumerated(EnumType.STRING)
@JsonIgnore
private CardType cardType;
}