package game import ( "strings" "testing" "thehouseoficarus/internal/casino" ) func TestVideoPokerCommandsAndLook(t *testing.T) { g, sess, conn := casinoCrapsGame(t, "name: Poker\ncasino_tables:\n - id: vp\n game: video_poker\n") g.executePlay(sess, []string{"vp"}, "play vp") conn.data = nil g.executeRules(sess, nil, "rules") if text := stripANSI(string(conn.data)); !strings.Contains(text, "Jacks or Better") { t.Fatal(text) } g.executeBet(sess, []string{"max"}, "bet max") g.executeTableAction(sess, "deal") if classifyCommand("531") != ClassInstant { t.Fatal("numeric holds rejected by dispatch") } g.executeCommand(sess, "531", nil, "531") table, _ := g.Casino.Participation(sess.Player.Name) snap := table.Status(sess.Player.Name)[0].Snapshot.(*casino.VideoPokerSnapshot) if snap.Held != ([5]bool{true, false, true, false, true}) { t.Fatalf("numeric holds: %+v", snap.Held) } conn.data = nil room, _ := g.World.LoadRoom(1) g.showCasinoGameLook(sess, sess.Player, room) text := stripANSI(string(conn.data)) for _, want := range []string{"1 HELD", "3 HELD", "5 HELD", "draw"} { if !strings.Contains(text, want) { t.Fatalf("look missing %q: %s", want, text) } } after := table.Status(sess.Player.Name)[0].Snapshot.(*casino.VideoPokerSnapshot) if after.Held != snap.Held { t.Fatal("look altered holds") } conn.data = nil g.executeList(sess, nil, "list") if text := stripANSI(string(conn.data)); !strings.Contains(text, "No wagers are available") || strings.Contains(text, "COINS PER HAND") { t.Fatal(text) } g.executeCommand(sess, "1", []string{"3", "5"}, "1 3 5") if got := table.Status(sess.Player.Name)[0].Snapshot.(*casino.VideoPokerSnapshot).Held; got != ([5]bool{}) { t.Fatalf("holds did not toggle off: %v", got) } g.executeCommand(sess, "d", nil, "d") if table.Status(sess.Player.Name)[0].Snapshot.(*casino.VideoPokerSnapshot).Drawing || len(sess.Player.PendingWagers) != 0 { t.Fatal("d did not draw") } g.executeCommand(sess, "game", []string{"deuces", "wild"}, "game deuces wild") conn.data = nil g.executeTableStatus(sess, []string{"rules"}, "table rules") if text := stripANSI(string(conn.data)); !strings.Contains(text, "Deuces Wild / 25/15/9/5/3/2") || !strings.Contains(text, "4000") || !strings.Contains(text, "COINS PER HAND") { t.Fatal(text) } } func TestBlackjackListUsesRealActionCommands(t *testing.T) { g, sess, conn := casinoCrapsGame(t, "name: BJ\ncasino_tables:\n - id: bj\n game: blackjack\n") g.executePlay(sess, []string{"bj"}, "play bj") // Deal until a hand has available action rows (a natural can settle immediately). table, _ := g.Casino.Participation(sess.Player.Name) for i := 0; i < 10 && len(table.Wagers(sess.Player.Name)) == 0; i++ { g.executeBet(sess, []string{"1"}, "bet 1") } if len(table.Wagers(sess.Player.Name)) == 0 { t.Fatal("no action rows") } conn.data = nil g.executeList(sess, nil, "list") text := stripANSI(string(conn.data)) if strings.Contains(text, "bet on") || len(listTargets(text)) == 0 { t.Fatal(text) } }