games: the natural the deal test didn't expect
TestDealTakesTheStakeAndHidesTheHoleCard checked for a 900 stack straight after a 100 bet, and only afterwards looked at whether the hand had already settled. A dealt natural settles inside the deal, so the stake is back (with the win, or as a push) before the test looks, and it failed whenever the shoe handed out a blackjack. It now checks for a settled natural first and, if it finds one, only asks that the stack didn't lose more than the bet.
This commit is contained in:
@@ -93,9 +93,6 @@ func TestDealTakesTheStakeAndHidesTheHoleCard(t *testing.T) {
|
|||||||
if code != 200 {
|
if code != 200 {
|
||||||
t.Fatalf("deal = %d, want 200", code)
|
t.Fatalf("deal = %d, want 200", code)
|
||||||
}
|
}
|
||||||
if v.Chips != 900 {
|
|
||||||
t.Fatalf("chips after a 100 bet = %d, want 900", v.Chips)
|
|
||||||
}
|
|
||||||
if v.Hand == nil {
|
if v.Hand == nil {
|
||||||
t.Fatal("deal returned no hand")
|
t.Fatal("deal returned no hand")
|
||||||
}
|
}
|
||||||
@@ -103,10 +100,18 @@ func TestDealTakesTheStakeAndHidesTheHoleCard(t *testing.T) {
|
|||||||
t.Fatalf("player was dealt %d cards, want 2", len(v.Hand.Hands[0].Cards))
|
t.Fatalf("player was dealt %d cards, want 2", len(v.Hand.Hands[0].Cards))
|
||||||
}
|
}
|
||||||
|
|
||||||
// A natural settles on the spot and legitimately shows both dealer cards.
|
// A natural settles on the spot: the stake has already come back (with the
|
||||||
|
// win, or as a push), and both dealer cards are legitimately shown. Checking
|
||||||
|
// the stack for 900 before this made the test fail on every dealt natural.
|
||||||
if v.Hand.Phase == "done" {
|
if v.Hand.Phase == "done" {
|
||||||
|
if v.Chips < 900 {
|
||||||
|
t.Fatalf("chips after a settled natural = %d, want at least the 900 left after the bet", v.Chips)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if v.Chips != 900 {
|
||||||
|
t.Fatalf("chips after a 100 bet = %d, want 900", v.Chips)
|
||||||
|
}
|
||||||
if !v.Hand.Hole || len(v.Hand.Dealer) != 1 {
|
if !v.Hand.Hole || len(v.Hand.Dealer) != 1 {
|
||||||
t.Fatalf("dealer shows %d cards (hole=%v), want 1 with the hole card held back",
|
t.Fatalf("dealer shows %d cards (hole=%v), want 1 with the hole card held back",
|
||||||
len(v.Hand.Dealer), v.Hand.Hole)
|
len(v.Hand.Dealer), v.Hand.Hole)
|
||||||
|
|||||||
Reference in New Issue
Block a user