Merge pull request 'feat: add info route (CAS-59)' (!147) from feat-CAS-59-slotinfo into main
Reviewed-on: #147 Reviewed-by: Constantin Simonis <constantin@simonis.lol>
This commit is contained in:
commit
d2038ee160
3 changed files with 28 additions and 34 deletions
|
@ -8,12 +8,12 @@ import de.szut.casino.user.UserEntity;
|
|||
import de.szut.casino.user.UserService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
|
@ -49,4 +49,15 @@ public class SlotController {
|
|||
|
||||
return ResponseEntity.ok(spinResult);
|
||||
}
|
||||
|
||||
@GetMapping("/slots/info")
|
||||
public ResponseEntity<Object> spinSlots() {
|
||||
Map<String, BigDecimal> info = new HashMap<>();
|
||||
|
||||
for (Symbol symbol : Symbol.values()) {
|
||||
info.put(symbol.getDisplayName(), symbol.getPayoutMultiplier());
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static de.szut.casino.slots.Symbol.*;
|
||||
|
||||
@Service
|
||||
public class SlotService {
|
||||
private final int REEL_LENGTH = 32;
|
||||
|
@ -21,12 +23,6 @@ public class SlotService {
|
|||
private final int CHERRY_COUNT = 10;
|
||||
private final int BLANK_COUNT = 10;
|
||||
|
||||
private final Symbol SEVEN = new Symbol("seven", new BigDecimal("1000"));
|
||||
private final Symbol BAR = new Symbol("bar", new BigDecimal("85"));
|
||||
private final Symbol BELL = new Symbol("bell", new BigDecimal("40"));
|
||||
private final Symbol CHERRY = new Symbol("cherry", new BigDecimal("10"));
|
||||
private final Symbol BLANK = new Symbol("blank", new BigDecimal("0"));
|
||||
|
||||
private final List<Symbol> firstReel;
|
||||
private final List<Symbol> secondReel;
|
||||
private final List<Symbol> thirdReel;
|
||||
|
|
|
@ -1,35 +1,22 @@
|
|||
package de.szut.casino.slots;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class Symbol {
|
||||
private String name;
|
||||
private BigDecimal payoutMultiplier;
|
||||
public enum Symbol {
|
||||
SEVEN("seven", new BigDecimal("1000")),
|
||||
BAR("bar", new BigDecimal("85")),
|
||||
BELL("bell", new BigDecimal("40")),
|
||||
CHERRY("cherry", new BigDecimal("10")),
|
||||
BLANK("blank", new BigDecimal("0"));
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof Symbol that)) {
|
||||
return false;
|
||||
}
|
||||
private final String displayName;
|
||||
private final BigDecimal payoutMultiplier;
|
||||
|
||||
return this.name.equals(that.name) && this.payoutMultiplier.equals(that.payoutMultiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 1;
|
||||
|
||||
hashCode = hashCode * 37 + this.name.hashCode();
|
||||
hashCode = hashCode * 37 + this.payoutMultiplier.hashCode();
|
||||
|
||||
return hashCode;
|
||||
Symbol(String displayName, BigDecimal payoutMultiplier) {
|
||||
this.displayName = displayName;
|
||||
this.payoutMultiplier = payoutMultiplier;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue