aboutsummaryrefslogtreecommitdiff
path: root/internal/game/render_felt_precision_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-06 12:57:23 -0400
committerhistoria <[not public]>2026-10-06 12:57:23 -0400
commit9666676766bf21364f4fc4d0d1d336e72f2a91b4 (patch)
tree0cade34091d7602790dc38cd44053f0b74bbadf2 /internal/game/render_felt_precision_test.go
parent4bc1daaf259e0c19c5fe4a12ec8bc7f6e5a735c1 (diff)
downloadthehouseoficarus-9666676766bf21364f4fc4d0d1d336e72f2a91b4.tar.gz
refactor: split casino.go, dedup helpers, remove audit docs
Diffstat (limited to 'internal/game/render_felt_precision_test.go')
-rw-r--r--internal/game/render_felt_precision_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/internal/game/render_felt_precision_test.go b/internal/game/render_felt_precision_test.go
new file mode 100644
index 0000000..da96d71
--- /dev/null
+++ b/internal/game/render_felt_precision_test.go
@@ -0,0 +1,41 @@
+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)
+ }
+}