Compare commits

..

19 commits

Author SHA1 Message Date
d397079561
refactor(blackjack): update import paths for modules
All checks were successful
CI / Get Changed Files (pull_request) Successful in 7s
CI / prettier (pull_request) Successful in 18s
CI / Checkstyle Main (pull_request) Successful in 29s
CI / eslint (pull_request) Successful in 56s
CI / test-build (pull_request) Successful in 1m11s
2025-04-02 09:54:17 +02:00
0654a98860
feat(landing): add NavbarComponent to landing page component
All checks were successful
CI / Get Changed Files (pull_request) Successful in 5s
CI / Checkstyle Main (pull_request) Has been skipped
CI / eslint (pull_request) Successful in 19s
CI / test-build (pull_request) Successful in 27s
CI / prettier (pull_request) Successful in 32s
2025-04-02 09:25:28 +02:00
3c0505b75e
style(game-controls): fix formatting in constructor method
Some checks failed
CI / Get Changed Files (pull_request) Successful in 7s
CI / Checkstyle Main (pull_request) Has been skipped
CI / eslint (pull_request) Successful in 18s
CI / test-build (pull_request) Failing after 26s
CI / prettier (pull_request) Successful in 31s
2025-04-02 09:23:26 +02:00
1ea2f7c086
refactor(game-controls): update import paths for consistency
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / Checkstyle Main (pull_request) Has been skipped
CI / eslint (pull_request) Successful in 20s
CI / test-build (pull_request) Failing after 26s
CI / prettier (pull_request) Failing after 32s
2025-04-02 09:21:24 +02:00
ae8dcab038
style: fix formatting in constructor definitions 2025-04-02 09:20:45 +02:00
aad692aea5
refactor(blackjack): update import paths for components 2025-04-02 09:20:42 +02:00
57a4b03bde
style(tsconfig): update path mappings to array syntax 2025-04-02 09:20:18 +02:00
ebf2ee0531
style(tsconfig): fix path configuration formatting 2025-04-02 09:20:17 +02:00
35d53bce30
style: format constructor style in components 2025-04-02 09:20:16 +02:00
f5a16efa67
refactor: update imports to use absolute paths 2025-04-02 09:20:15 +02:00
a425fdea80
refactor: update import paths for better readability 2025-04-02 09:20:11 +02:00
f881f82ef1
refactor(blackjack): move GameState to feature folder
All checks were successful
CI / Get Changed Files (pull_request) Successful in 6s
CI / eslint (pull_request) Successful in 19s
CI / test-build (pull_request) Successful in 27s
CI / prettier (pull_request) Successful in 41s
CI / Checkstyle Main (pull_request) Successful in 1m25s
2025-04-02 09:18:43 +02:00
f1c70f5f2c
style: format code and add missing newlines
All checks were successful
CI / Get Changed Files (pull_request) Successful in 7s
CI / prettier (pull_request) Successful in 22s
CI / eslint (pull_request) Successful in 24s
CI / test-build (pull_request) Successful in 56s
CI / Checkstyle Main (pull_request) Successful in 1m40s
2025-04-02 09:08:04 +02:00
732d475a84
feat: add game state enum and refactor game components
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / prettier (pull_request) Failing after 26s
CI / eslint (pull_request) Failing after 28s
CI / test-build (pull_request) Successful in 37s
CI / Checkstyle Main (pull_request) Successful in 2m25s
2025-04-02 09:06:44 +02:00
05322e3d83
refactor(blackjack): remove unnecessary comments and clean code
All checks were successful
CI / Get Changed Files (pull_request) Successful in 6s
CI / prettier (pull_request) Successful in 19s
CI / Checkstyle Main (pull_request) Successful in 27s
CI / eslint (pull_request) Successful in 45s
CI / test-build (pull_request) Successful in 56s
2025-03-27 15:50:34 +01:00
23888ceb27
style(blackjack): format code for better readability
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / eslint (pull_request) Failing after 8s
CI / prettier (pull_request) Successful in 20s
CI / Checkstyle Main (pull_request) Successful in 31s
CI / test-build (pull_request) Successful in 46s
2025-03-27 15:47:16 +01:00
adc5bbd345
feat(blackjack): add action indicators and loading states
Some checks failed
CI / Get Changed Files (pull_request) Successful in 7s
CI / prettier (pull_request) Failing after 1m0s
CI / eslint (pull_request) Failing after 1m3s
CI / test-build (pull_request) Successful in 1m18s
CI / Checkstyle Main (pull_request) Successful in 1m31s
2025-03-27 15:44:38 +01:00
c9f71f70fa
feat: add double down feature to blackjack game 2025-03-27 15:40:26 +01:00
68ea66d4f9
feat: add stand and get game features to blackjack game 2025-03-27 15:22:24 +01:00
4 changed files with 6 additions and 19 deletions

View file

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

View file

@ -96,6 +96,7 @@ public class BlackJackService {
return game;
}
private BlackJackGameEntity refreshGameState(BlackJackGameEntity game) {
return blackJackGameRepository.findById(game.getId()).orElse(game);
}
@ -204,20 +205,7 @@ public class BlackJackService {
int playerHandValue = calculateHandValue(game.getPlayerCards());
if (playerHandValue == 21) {
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;
}
return BlackJackState.PLAYER_WON;
} else if (playerHandValue > 21) {
return BlackJackState.PLAYER_LOST;
}
@ -228,6 +216,7 @@ 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,9 +1,8 @@
package de.szut.casino.blackjack;
public enum BlackJackState {
IN_PROGRESS,
PLAYER_BLACKJACK,
PLAYER_LOST,
PLAYER_WON,
IN_PROGRESS,
PLAYER_LOST,
DRAW,
}

View file

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