aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/slots_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-31 17:44:10 -0400
committerhistoria <[not public]>2026-07-31 17:44:10 -0400
commitf51424c90dbce7191a31b6e675818c985f0f4539 (patch)
treea7845a2e09bd6e83d2d034f5e702a4940f38126a /internal/casino/slots_test.go
parent58758d41488a777d2bc0e787be655363bdd9eb60 (diff)
downloadthehouseoficarus-f51424c90dbce7191a31b6e675818c985f0f4539.tar.gz
feat: casino framework and basic slot machine
Diffstat (limited to 'internal/casino/slots_test.go')
-rw-r--r--internal/casino/slots_test.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/casino/slots_test.go b/internal/casino/slots_test.go
new file mode 100644
index 0000000..22e39bf
--- /dev/null
+++ b/internal/casino/slots_test.go
@@ -0,0 +1,44 @@
+package casino
+
+import "testing"
+
+func TestCalculateRTPUsesLongestWayOnly(t *testing.T) {
+ profile := SlotProfile{
+ Rows: 3, Reels: 5, Ways: 243,
+ Symbols: []SlotSymbol{{ID: "x", Weight: 1, Payout: map[int]float64{3: 1, 4: 2, 5: 3}}},
+ FreeSpinTrigger: "scatter", FreeSpinCount: 8,
+ }
+ if got := CalculateRTP(profile); got != 3 {
+ t.Fatalf("RTP = %v, want 3", got)
+ }
+}
+
+func TestValidateRTP(t *testing.T) {
+ profile := SlotProfile{Rows: 3, Reels: 5, Ways: 243, TargetRTP: 3,
+ Symbols: []SlotSymbol{{ID: "x", Weight: 1, Payout: map[int]float64{5: 3}}}}
+ if err := ValidateRTP(profile, 0.000001); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestScaleToRTP(t *testing.T) {
+ profile := ScaleToRTP(DefaultHuffAndPuffProfile(), 0.97)
+ if err := ValidateRTP(profile, 0.000000001); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestEvaluateSlotReportsWinningWays(t *testing.T) {
+ profile := SlotProfile{Rows: 3, Reels: 5, Ways: 243,
+ Symbols: []SlotSymbol{{ID: "x", Weight: 1, Payout: map[int]float64{5: 2}}}}
+ grid := [3][5]string{}
+ for row := range grid {
+ for reel := range grid[row] {
+ grid[row][reel] = "x"
+ }
+ }
+ payout, wins := evaluateSlot(grid, 10, profile)
+ if payout != 20 || len(wins) != 1 || wins[0].Ways != 243 || wins[0].Length != 5 {
+ t.Fatalf("payout=%v wins=%+v", payout, wins)
+ }
+}