chore: Remove old Anhang and add some code to the docs
All checks were successful
Build docs / build-docs (pull_request) Successful in 29s
Label PRs based on size / Check PR size (pull_request) Successful in 27s
CI / Get Changed Files (pull_request) Successful in 34s
CI / Backend Tests (pull_request) Has been skipped
CI / eslint (pull_request) Has been skipped
Pull Request Labeler / labeler (pull_request_target) Successful in 4s
CI / Checkstyle Main (pull_request) Has been skipped
CI / oxlint (pull_request) Has been skipped
CI / Docker frontend validation (pull_request) Has been skipped
CI / prettier (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / test-build (pull_request) Has been skipped
CI / Playwright (pull_request) Has been skipped
Claude PR Review / claude-code (pull_request) Successful in 1m41s
All checks were successful
Build docs / build-docs (pull_request) Successful in 29s
Label PRs based on size / Check PR size (pull_request) Successful in 27s
CI / Get Changed Files (pull_request) Successful in 34s
CI / Backend Tests (pull_request) Has been skipped
CI / eslint (pull_request) Has been skipped
Pull Request Labeler / labeler (pull_request_target) Successful in 4s
CI / Checkstyle Main (pull_request) Has been skipped
CI / oxlint (pull_request) Has been skipped
CI / Docker frontend validation (pull_request) Has been skipped
CI / prettier (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / test-build (pull_request) Has been skipped
CI / Playwright (pull_request) Has been skipped
Claude PR Review / claude-code (pull_request) Successful in 1m41s
This commit is contained in:
parent
c87a0593b3
commit
0e9e729fdf
10 changed files with 489 additions and 53 deletions
35
projektdokumentation/Listings/CoinflipService.java
Normal file
35
projektdokumentation/Listings/CoinflipService.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package de.szut.casino.coinflip;
|
||||
|
||||
import de.szut.casino.shared.service.BalanceService;
|
||||
import de.szut.casino.user.UserEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Random;
|
||||
|
||||
@Service
|
||||
public class CoinflipService {
|
||||
private final Random random;
|
||||
private final BalanceService balanceService;
|
||||
|
||||
public CoinflipService(BalanceService balanceService, Random random) {
|
||||
this.balanceService = balanceService;
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
public CoinflipResult play(UserEntity user, CoinflipDto coinflipDto) {
|
||||
this.balanceService.subtractFunds(user, coinflipDto.getBetAmount());
|
||||
|
||||
CoinSide coinSide = this.random.nextBoolean() ? CoinSide.HEAD : CoinSide.TAILS;
|
||||
CoinflipResult coinflipResult = new CoinflipResult(false, BigDecimal.ZERO, coinSide);
|
||||
if (coinSide == coinflipDto.getCoinSide()) {
|
||||
coinflipResult.setWin(true);
|
||||
|
||||
BigDecimal payout = coinflipDto.getBetAmount().multiply(BigDecimal.TWO);
|
||||
this.balanceService.addFunds(user, payout);
|
||||
coinflipResult.setPayout(payout);
|
||||
}
|
||||
|
||||
return coinflipResult;
|
||||
}
|
||||
}
|
Reference in a new issue