diff options
| author | historia <[not public]> | 2026-08-03 14:08:09 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-08-03 14:08:09 -0400 |
| commit | 612e429de438821ae8e099d6b54f87c11ff6c1b5 (patch) | |
| tree | ad6f9edf74339b9b50f9c7c2cd314ee7b6e04b2c /internal/casino/machine_test.go | |
| parent | f51424c90dbce7191a31b6e675818c985f0f4539 (diff) | |
| download | thehouseoficarus-612e429de438821ae8e099d6b54f87c11ff6c1b5.tar.gz | |
refactor: casino game slop refactor
Diffstat (limited to 'internal/casino/machine_test.go')
| -rw-r--r-- | internal/casino/machine_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/casino/machine_test.go b/internal/casino/machine_test.go new file mode 100644 index 0000000..fdfa42c --- /dev/null +++ b/internal/casino/machine_test.go @@ -0,0 +1,44 @@ +package casino + +import ( + "math/rand" + "testing" +) + +func TestMachineFreeSpinsUseProfileCount(t *testing.T) { + m := newMachine(1, MachineConfig{ID: "slots", Game: GameSlots}, rand.New(rand.NewSource(7))) + m.profile.FreeSpinCount = 5 + m.player = &Participant{Name: "alice", Connected: true, Wallet: &testWallet{credits: 100}} + m.spinBet = 10 + m.spin = &SlotSpin{ScatterCount: 3} + events := m.finishSpin() + if m.freeSpins != 4 { + t.Fatalf("freeSpins=%d, want 4 remaining after the first of 5 chained spins", m.freeSpins) + } + if m.phase != machineSpinning { + t.Fatalf("phase=%s, want spinning", m.phase) + } + if !hasMessage(events, "trigger 5 free spins") { + t.Fatalf("missing profile-count free spin message: %+v", events) + } +} + +func TestMachineMenuEventCarriesStructuredMenu(t *testing.T) { + m := newMachine(1, MachineConfig{ID: "slots", Game: GameSlots}, rand.New(rand.NewSource(7))) + m.player = &Participant{Name: "alice", Connected: true} + events := m.privateMenu("You sit down at the slot machine.") + if len(events) != 1 || events[0].Menu == nil || events[0].Menu.Kind != MenuSlotCommands || events[0].Menu.Body == "" { + t.Fatalf("slot menu event=%+v", events) + } +} + +func TestMachineLeaveResetsPayoutRemainder(t *testing.T) { + m := newMachine(1, MachineConfig{ID: "slots", Game: GameSlots}, rand.New(rand.NewSource(7))) + m.player = &Participant{Name: "alice", Connected: true} + m.bet = 10 + m.payoutRemainder = 0.5 + m.leave("alice") + if m.payoutRemainder != 0 { + t.Fatalf("payoutRemainder=%v leaked to the next player", m.payoutRemainder) + } +} |
