Compare commits
No commits in common. "v1.43.0" and "v1.42.3" have entirely different histories.
2 changed files with 17 additions and 43 deletions
|
@ -42,37 +42,32 @@ public class SlotService {
|
|||
Symbol symbol2 = getSymbolAt(this.secondReel, index2);
|
||||
Symbol symbol3 = getSymbolAt(this.thirdReel, index3);
|
||||
|
||||
Status status = determineStatus(symbol1, symbol2, symbol3);
|
||||
boolean isWin = symbol1.equals(symbol2) && symbol1.equals(symbol3);
|
||||
|
||||
SpinResult spinResult = processResult(betAmount, user, status, symbol1);
|
||||
SpinResult spinResult = processResult(betAmount, user, isWin, symbol1);
|
||||
buildResultMatrix(spinResult, index1, index2, index3);
|
||||
|
||||
return spinResult;
|
||||
}
|
||||
|
||||
private SpinResult processResult(BigDecimal betAmount, UserEntity user, Status status, Symbol winSymbol) {
|
||||
SpinResult spinResult = new SpinResult();
|
||||
private SpinResult processResult(BigDecimal betAmount, UserEntity user, boolean isWin, Symbol winSymbol) {
|
||||
BigDecimal resultAmount;
|
||||
String status;
|
||||
|
||||
switch (status) {
|
||||
case WIN:
|
||||
BigDecimal winAmount = betAmount.multiply(winSymbol.getPayoutMultiplier());
|
||||
this.balanceService.addFunds(user, winAmount);
|
||||
spinResult.setAmount(winAmount);
|
||||
spinResult.setStatus(Status.WIN.name().toLowerCase());
|
||||
break;
|
||||
|
||||
case BLANK:
|
||||
spinResult.setAmount(BigDecimal.ZERO);
|
||||
spinResult.setStatus(Status.BLANK.name().toLowerCase());
|
||||
break;
|
||||
|
||||
case LOSE:
|
||||
if (isWin) {
|
||||
resultAmount = betAmount.multiply(winSymbol.getPayoutMultiplier());
|
||||
status = "win";
|
||||
this.balanceService.addFunds(user, resultAmount);
|
||||
} else {
|
||||
resultAmount = betAmount;
|
||||
status = "lose";
|
||||
this.balanceService.subtractFunds(user, betAmount);
|
||||
spinResult.setAmount(betAmount);
|
||||
spinResult.setStatus(Status.LOSE.name().toLowerCase());
|
||||
break;
|
||||
}
|
||||
|
||||
SpinResult spinResult = new SpinResult();
|
||||
spinResult.setStatus(status);
|
||||
spinResult.setAmount(resultAmount);
|
||||
|
||||
return spinResult;
|
||||
}
|
||||
|
||||
|
@ -129,18 +124,4 @@ public class SlotService {
|
|||
|
||||
return reel.get(effectiveIndex);
|
||||
}
|
||||
|
||||
private Status determineStatus(Symbol symbol1, Symbol symbol2, Symbol symbol3) {
|
||||
boolean allSymbolsMatch = symbol1.equals(symbol2) && symbol1.equals(symbol3);
|
||||
|
||||
if (allSymbolsMatch) {
|
||||
if (symbol1 == Symbol.BLANK) {
|
||||
return Status.BLANK;
|
||||
} else {
|
||||
return Status.WIN;
|
||||
}
|
||||
}
|
||||
|
||||
return Status.LOSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package de.szut.casino.slots;
|
||||
|
||||
public enum Status {
|
||||
WIN,
|
||||
LOSE,
|
||||
BLANK
|
||||
}
|
Reference in a new issue