aboutsummaryrefslogtreecommitdiff
path: root/internal/game/blackjack_rules.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/blackjack_rules.go')
-rw-r--r--internal/game/blackjack_rules.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/game/blackjack_rules.go b/internal/game/blackjack_rules.go
new file mode 100644
index 0000000..61aab47
--- /dev/null
+++ b/internal/game/blackjack_rules.go
@@ -0,0 +1,46 @@
+package game
+
+import (
+ "strings"
+
+ "thehouseoficarus/internal/casino"
+ "thehouseoficarus/internal/net"
+)
+
+// Tables are room fixtures in their own right, not authored scenery objects.
+func (g *Game) lookBlackjackTable(sess *net.Session, target string) bool {
+ return g.lookCardTable(sess, target, casino.GameBlackjack)
+}
+
+func (g *Game) lookBaccaratTable(sess *net.Session, target string) bool {
+ return g.lookCardTable(sess, target, casino.GameBaccarat)
+}
+
+func (g *Game) lookCardTable(sess *net.Session, target string, game casino.GameName) bool {
+ room, err := g.World.LoadRoom(sess.Player.RoomID)
+ if err != nil {
+ return false
+ }
+ target = strings.TrimSpace(strings.ToLower(target))
+ for _, cfg := range room.CasinoTables {
+ if cfg.Game != game {
+ continue
+ }
+ id := strings.ToLower(cfg.ID)
+ if target != string(game) && target != string(game)+" table" && target != id && target != id+" table" && !(target == "table" && len(room.CasinoTables) == 1) {
+ continue
+ }
+ // Use the active configuration: live edits may be pending until a round ends.
+ table, ok := g.casinoTable(room.ID, string(cfg.Game))
+ if !ok {
+ return false
+ }
+ if game == casino.GameBaccarat {
+ sess.WriteLine(table.Config.BaccaratRulesText())
+ } else {
+ sess.WriteLine(table.Config.BlackjackRulesText())
+ }
+ return true
+ }
+ return false
+}