package game import ( "strings" "testing" "thehouseoficarus/internal/casino" ) // The felt is fixed-width art: a commission percentage must not lose its // trailing zero (0.9 used to trim "10" down to "1"). func TestBaccaratFeltPrintsExactCommission(t *testing.T) { cases := map[float64]string{ 0.9: "10% COMMISSION", 0.8: "20% COMMISSION", 0.95: "5% COMMISSION", 0.99: "1% COMMISSION", } for payout, want := range cases { cfg := casino.TableConfig{ID: "x", Game: casino.GameBaccarat, Baccarat: casino.BaccaratConfig{Variant: casino.BaccaratCommission, BankerPayout: payout}} art := renderBaccaratRulesFelt(cfg, "none", false) if !strings.Contains(art, want) { t.Fatalf("payout %v: missing %q in felt", payout, want) } } } // Bare %g prints shortest-round-trip floats (0.29 -> 28.999999999999996), // which overruns the fixed-width box borders. func TestBlackjackFeltPrintsRoundedShuffle(t *testing.T) { cfg := casino.TableConfig{ID: "x", Game: casino.GameBlackjack, Blackjack: casino.BlackjackConfig{ShuffleAt: 0.29}} art := renderBlackjackRulesFelt(cfg, "none", false) if !strings.Contains(art, "29% REMAINING") { t.Fatalf("missing rounded shuffle value: %s", art) } if strings.Contains(art, "99999") || strings.Contains(art, "000000") { t.Fatalf("float noise leaked into the felt: %s", art) } }