diff --git a/backend/src/main/java/de/szut/casino/slots/SlotController.java b/backend/src/main/java/de/szut/casino/slots/SlotController.java index 5e27b52..e69de94 100644 --- a/backend/src/main/java/de/szut/casino/slots/SlotController.java +++ b/backend/src/main/java/de/szut/casino/slots/SlotController.java @@ -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.*; +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 java.math.BigDecimal; import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import java.util.Optional; @RestController @@ -49,15 +49,4 @@ public class SlotController { return ResponseEntity.ok(spinResult); } - - @GetMapping("/slots/info") - public ResponseEntity spinSlots() { - Map info = new HashMap<>(); - - for (Symbol symbol : Symbol.values()) { - info.put(symbol.getDisplayName(), symbol.getPayoutMultiplier()); - } - - return ResponseEntity.ok(info); - } } diff --git a/backend/src/main/java/de/szut/casino/slots/SlotService.java b/backend/src/main/java/de/szut/casino/slots/SlotService.java index ccc2133..39ebeab 100644 --- a/backend/src/main/java/de/szut/casino/slots/SlotService.java +++ b/backend/src/main/java/de/szut/casino/slots/SlotService.java @@ -10,8 +10,6 @@ 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; @@ -23,6 +21,12 @@ 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 firstReel; private final List secondReel; private final List thirdReel; diff --git a/backend/src/main/java/de/szut/casino/slots/Symbol.java b/backend/src/main/java/de/szut/casino/slots/Symbol.java index 74f4560..806d14b 100644 --- a/backend/src/main/java/de/szut/casino/slots/Symbol.java +++ b/backend/src/main/java/de/szut/casino/slots/Symbol.java @@ -1,22 +1,35 @@ package de.szut.casino.slots; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import java.math.BigDecimal; @Getter -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")); +@Setter +@AllArgsConstructor +public class Symbol { + private String name; + private BigDecimal payoutMultiplier; - private final String displayName; - private final BigDecimal payoutMultiplier; + @Override + public boolean equals(Object other) { + if (!(other instanceof Symbol that)) { + return false; + } - Symbol(String displayName, BigDecimal payoutMultiplier) { - this.displayName = displayName; - this.payoutMultiplier = 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; } }