aboutsummaryrefslogtreecommitdiff
path: root/internal/game/casino_edge_list_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/casino_edge_list_test.go')
-rw-r--r--internal/game/casino_edge_list_test.go97
1 files changed, 97 insertions, 0 deletions
diff --git a/internal/game/casino_edge_list_test.go b/internal/game/casino_edge_list_test.go
new file mode 100644
index 0000000..ff0b965
--- /dev/null
+++ b/internal/game/casino_edge_list_test.go
@@ -0,0 +1,97 @@
+package game
+
+import (
+ "strings"
+ "testing"
+
+ "thehouseoficarus/internal/item"
+ "thehouseoficarus/internal/player"
+)
+
+func TestEdgeListAllTableGames(t *testing.T) {
+ for _, game := range []string{"blackjack", "baccarat", "roulette", "craps", "paigow", "video_poker"} {
+ t.Run(game, func(t *testing.T) {
+ g, sess, conn := houseEdgeGame(t, "name: Casino\ncasino_tables:\n - id: test\n game: "+game+"\n")
+ writeHouseEdgeManual(t, g, sess, 2)
+ g.executePlay(sess, []string{game}, "play "+game)
+ if strings.Contains(stripANSI(string(conn.data)), "RTP") {
+ t.Fatal("readout on join")
+ }
+ conn.data = nil
+ g.executeList(sess, nil, "list")
+ text := stripANSI(string(conn.data))
+ if !strings.Contains(text, "RTP") {
+ t.Fatalf("no RTP column for %s: %s", game, text)
+ }
+ assertRTPColumn(t, text)
+ sess.Player.Inventory = nil
+ conn.data = nil
+ g.executeList(sess, nil, "list")
+ if strings.Contains(stripANSI(string(conn.data)), "RTP") {
+ t.Fatal("readout after reference removed")
+ }
+ })
+ }
+}
+
+func TestEdgeListBlackjackActionsOmitRTP(t *testing.T) {
+ g, sess, conn := houseEdgeGame(t, "name: BJ\ncasino_tables:\n - id: bj\n game: blackjack\n")
+ writeHouseEdgeManual(t, g, sess, 2)
+ g.executePlay(sess, []string{"bj"}, "play bj")
+ 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")
+ }
+ rows := table.Wagers(sess.Player.Name)
+ if len(rows) == 0 {
+ t.Skip("no action rows this deal")
+ }
+ insurance := false
+ for _, r := range rows {
+ if r.Bet == "insurance" {
+ insurance = true
+ }
+ }
+ conn.data = nil
+ g.executeList(sess, nil, "list")
+ text := stripANSI(string(conn.data))
+ if insurance {
+ // Insurance is a real wager and carries an RTP.
+ if !strings.Contains(text, "RTP") {
+ t.Fatalf("insurance list lost its RTP:\n%s", text)
+ }
+ return
+ }
+ if strings.Contains(text, "RTP") {
+ t.Fatalf("action-only list showed an RTP column:\n%s", text)
+ }
+}
+
+func TestEdgeListRealInstruments(t *testing.T) {
+ g, sess, conn := houseEdgeGame(t, roomRoulette)
+ g.ItemStore = item.NewItemStore("../../data")
+ sess.Player.Inventory = map[int]*player.InventorySlot{
+ 0: {ItemID: "house_edge_tile", Quantity: 1},
+ 1: {ItemID: "house_edge_computus", Quantity: 1},
+ }
+ g.executePlay(sess, []string{"roulette"}, "play roulette")
+ conn.data = nil
+ g.executeList(sess, nil, "list")
+ text := stripANSI(string(conn.data))
+ if strings.Count(text, "97.30%") != 12 {
+ t.Fatalf("best instrument not used: %s", text)
+ }
+ sess.Player.Inventory[1].Quantity = 0
+ conn.data = nil
+ g.executeList(sess, nil, "list")
+ text = stripANSI(string(conn.data))
+ if strings.Count(text, "97%") != 12 {
+ t.Fatalf("tile not used: %s", text)
+ }
+ sess.Player.Inventory[0].Quantity = 0
+ conn.data = nil
+ g.executeList(sess, nil, "list")
+ if strings.Contains(stripANSI(string(conn.data)), "RTP") {
+ t.Fatal("zero-quantity item activated")
+ }
+}