From f71f38dfc2e4fb09056fa809a3c6061fd090b707 Mon Sep 17 00:00:00 2001 From: Phan Huy Tran Date: Thu, 24 Apr 2025 15:50:50 +0200 Subject: [PATCH] refactor: define symbol counts to symbol enum instead of slot service --- .../java/de/szut/casino/slots/SlotService.java | 17 +++++------------ .../main/java/de/szut/casino/slots/Symbol.java | 14 ++++++++------ 2 files changed, 13 insertions(+), 18 deletions(-) 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..b75e103 100644 --- a/backend/src/main/java/de/szut/casino/slots/SlotService.java +++ b/backend/src/main/java/de/szut/casino/slots/SlotService.java @@ -16,13 +16,6 @@ import static de.szut.casino.slots.Symbol.*; public class SlotService { private final int REEL_LENGTH = 32; - // 98% RTP - private final int SEVEN_COUNT = 1; - private final int BAR_COUNT = 4; - private final int BELL_COUNT = 7; - private final int CHERRY_COUNT = 10; - private final int BLANK_COUNT = 10; - private final List firstReel; private final List secondReel; private final List thirdReel; @@ -109,11 +102,11 @@ public class SlotService { private List createReelStrip() { List reelStrip = new ArrayList<>(REEL_LENGTH); - addSymbolsToStrip(reelStrip, CHERRY, CHERRY_COUNT); - addSymbolsToStrip(reelStrip, BELL, BELL_COUNT); - addSymbolsToStrip(reelStrip, BAR, BAR_COUNT); - addSymbolsToStrip(reelStrip, SEVEN, SEVEN_COUNT); - addSymbolsToStrip(reelStrip, BLANK, BLANK_COUNT); + addSymbolsToStrip(reelStrip, CHERRY, CHERRY.getCountPerStrip()); + addSymbolsToStrip(reelStrip, BELL, BELL.getCountPerStrip()); + addSymbolsToStrip(reelStrip, BAR, BAR.getCountPerStrip()); + addSymbolsToStrip(reelStrip, SEVEN, SEVEN.getCountPerStrip()); + addSymbolsToStrip(reelStrip, BLANK, BLANK.getCountPerStrip()); return reelStrip; } 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..3cf0f72 100644 --- a/backend/src/main/java/de/szut/casino/slots/Symbol.java +++ b/backend/src/main/java/de/szut/casino/slots/Symbol.java @@ -6,17 +6,19 @@ 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")); + SEVEN("seven", new BigDecimal("1000"), 1), + BAR("bar", new BigDecimal("85"), 4), + BELL("bell", new BigDecimal("40"), 7), + CHERRY("cherry", new BigDecimal("10"), 10), + BLANK("blank", new BigDecimal("0"), 10); private final String displayName; private final BigDecimal payoutMultiplier; + private final int countPerStrip; - Symbol(String displayName, BigDecimal payoutMultiplier) { + Symbol(String displayName, BigDecimal payoutMultiplier, int count) { this.displayName = displayName; this.payoutMultiplier = payoutMultiplier; + this.countPerStrip = count; } }