feat: add info route
Some checks failed
Some checks failed
This commit is contained in:
parent
a22bfa4a60
commit
56ba9f783c
3 changed files with 29 additions and 35 deletions
|
@ -8,12 +8,12 @@ import de.szut.casino.user.UserEntity;
|
||||||
import de.szut.casino.user.UserService;
|
import de.szut.casino.user.UserService;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -49,4 +49,15 @@ public class SlotController {
|
||||||
|
|
||||||
return ResponseEntity.ok(spinResult);
|
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.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import static de.szut.casino.slots.Symbol.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SlotService {
|
public class SlotService {
|
||||||
private final int REEL_LENGTH = 32;
|
private final int REEL_LENGTH = 32;
|
||||||
|
@ -21,12 +23,6 @@ public class SlotService {
|
||||||
private final int CHERRY_COUNT = 10;
|
private final int CHERRY_COUNT = 10;
|
||||||
private final int BLANK_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> firstReel;
|
||||||
private final List<Symbol> secondReel;
|
private final List<Symbol> secondReel;
|
||||||
private final List<Symbol> thirdReel;
|
private final List<Symbol> thirdReel;
|
||||||
|
|
|
@ -1,35 +1,22 @@
|
||||||
package de.szut.casino.slots;
|
package de.szut.casino.slots;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
public enum Symbol {
|
||||||
@AllArgsConstructor
|
SEVEN("seven", new BigDecimal("1000")),
|
||||||
public class Symbol {
|
BAR("bar", new BigDecimal("85")),
|
||||||
private String name;
|
BELL("bell", new BigDecimal("40")),
|
||||||
private BigDecimal payoutMultiplier;
|
CHERRY("cherry", new BigDecimal("10")),
|
||||||
|
BLANK("blank", new BigDecimal("0"));
|
||||||
|
|
||||||
@Override
|
private final String displayName;
|
||||||
public boolean equals(Object other) {
|
private final BigDecimal payoutMultiplier;
|
||||||
if (!(other instanceof Symbol that)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.name.equals(that.name) && this.payoutMultiplier.equals(that.payoutMultiplier);
|
Symbol(String displayName, BigDecimal payoutMultiplier) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.payoutMultiplier = payoutMultiplier;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hashCode = 1;
|
|
||||||
|
|
||||||
hashCode = hashCode * 37 + this.name.hashCode();
|
|
||||||
hashCode = hashCode * 37 + this.payoutMultiplier.hashCode();
|
|
||||||
|
|
||||||
return hashCode;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in a new issue