Compare commits

..

No commits in common. "v1.39.0" and "v1.38.0" have entirely different histories.

3 changed files with 34 additions and 28 deletions

View file

@ -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.*; 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.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
@RestController @RestController
@ -49,15 +49,4 @@ 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);
}
} }

View file

@ -10,8 +10,6 @@ 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;
@ -23,6 +21,12 @@ 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;

View file

@ -1,22 +1,35 @@
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
public enum Symbol { @Setter
SEVEN("seven", new BigDecimal("1000")), @AllArgsConstructor
BAR("bar", new BigDecimal("85")), public class Symbol {
BELL("bell", new BigDecimal("40")), private String name;
CHERRY("cherry", new BigDecimal("10")), private BigDecimal payoutMultiplier;
BLANK("blank", new BigDecimal("0"));
private final String displayName; @Override
private final BigDecimal payoutMultiplier; public boolean equals(Object other) {
if (!(other instanceof Symbol that)) {
return false;
}
Symbol(String displayName, BigDecimal payoutMultiplier) { return this.name.equals(that.name) && this.payoutMultiplier.equals(that.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;
} }
} }