package casino import "testing" func TestCrapsTakenDownRollDoesNotCarryIntoNewBet(t *testing.T) { tb := crapsFixture() tb.join("alice") w := &testWallet{chips: 100} tb.bet("alice", "field", 10, w) tb.action("alice", "roll") tb.tick() tb.action("alice", "unbet") if tb.pendingRollTicks != 0 { t.Fatal("taking down the last bet did not cancel the pending roll") } tb.bet("alice", "field", 10, w) tb.advance(10) if tb.dice != [2]int{} || !tb.hasLiveBets() { t.Fatal("new wager inherited a canceled roll") } tb.action("alice", "roll") tb.advance(crapsManualRollTicks) if tb.dice == [2]int{} || tb.hasLiveBets() { t.Fatal("fresh manual roll did not settle") } } func TestSimplifiedCrapsDeparturePreservesCountdown(t *testing.T) { for _, departing := range []string{"alice", "bob"} { t.Run(departing, func(t *testing.T) { tb := variantFixture("simplified") tb.join("alice") tb.join("bob") tb.join("carol") tb.bet("carol", "pass", 10, &testWallet{chips: 100}) tb.tick() tb.leave(departing) if tb.countdown != 1 || tb.view().ShootIn != 2 { t.Fatal("departure reset the shared countdown") } events := tb.tick() if len(events) != 1 || tb.countdown != 2 { t.Fatal("countdown repeated after departure", events) } tb.tick() if tb.dice == [2]int{} || tb.hasLiveBets() { t.Fatal("shared roll did not settle on schedule") } }) } }