Compare commits

...

3 commits

Author SHA1 Message Date
d2038ee160
Merge pull request 'feat: add info route (CAS-59)' (!147) from feat-CAS-59-slotinfo into main
All checks were successful
Release / Release (push) Successful in 58s
Release / Build Frontend Image (push) Successful in 24s
Release / Build Backend Image (push) Successful in 1m1s
Reviewed-on: #147
Reviewed-by: Constantin Simonis <constantin@simonis.lol>
2025-04-24 13:47:37 +00:00
Phan Huy Tran
6ab095e6db chore: bruh
All checks were successful
CI / Get Changed Files (pull_request) Successful in 6s
CI / eslint (pull_request) Has been skipped
CI / prettier (pull_request) Has been skipped
CI / test-build (pull_request) Has been skipped
CI / Checkstyle Main (pull_request) Successful in 38s
2025-04-24 15:42:29 +02:00
Phan Huy Tran
56ba9f783c feat: add info route
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / eslint (pull_request) Has been skipped
CI / prettier (pull_request) Has been skipped
CI / test-build (pull_request) Has been skipped
CI / Checkstyle Main (pull_request) Failing after 25s
2025-04-24 15:40:39 +02:00
3 changed files with 28 additions and 34 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.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);
}
} }

View file

@ -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;

View file

@ -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;
} }
} }