aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_registry.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/cmd_registry.go')
-rw-r--r--internal/game/cmd_registry.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/internal/game/cmd_registry.go b/internal/game/cmd_registry.go
index d8cc18f..4d48509 100644
--- a/internal/game/cmd_registry.go
+++ b/internal/game/cmd_registry.go
@@ -224,6 +224,40 @@ var commandRegistry = map[string]commandDef{
"hideallexits": {(*Game).executeHideAllExits, ClassInstant},
}
+// isAllDigits reports whether every rune is an ASCII digit.
+func isAllDigits(s string) bool {
+ if s == "" {
+ return false
+ }
+ for _, r := range s {
+ if r < '0' || r > '9' {
+ return false
+ }
+ }
+ return true
+}
+
+// casinoOwnedInput reports whether the seated game's interceptors in
+// executeCommand own this command. Bare square/card numbers and the retry
+// verbs (settle, set, house, autoset) are not all in the shared registry, so
+// without this they would be rejected as unknown before reaching the game.
+func (g *Game) casinoOwnedInput(sess *net.Session, cmd string) bool {
+ if sess == nil || sess.Player == nil || g.Casino == nil {
+ return false
+ }
+ table, playing := g.Casino.Participation(sess.Player.Name)
+ if !playing || table == nil {
+ return false
+ }
+ switch table.Config.Game {
+ case casino.GameCashHunt:
+ return isAllDigits(cmd) || cmd == "settle"
+ case casino.GamePaiGow:
+ return isAllDigits(cmd) || cmd == "set" || cmd == "house" || cmd == "autoset" || cmd == "settle"
+ }
+ return false
+}
+
func classifyCommand(cmd string) CommandClass {
if _, ok := casino.ParsePokerDigits(cmd); ok {
return ClassInstant
@@ -255,6 +289,7 @@ var casinoCommonVerbs = []string{"watch", "game", "table", "list", "stop", "rule
// command: "sp" is split at a blackjack table, but spin at a Big 6 wheel,
// because "split" is not a Big 6 verb and "spin" is not a blackjack verb.
var casinoVerbsByGame = map[casino.GameName][]string{
+ casino.GameCashHunt: {"bet", "rebet", "difficulty", "paytable", "pick", "settle"},
casino.GamePlinko: {"bet", "rebet", "difficulty", "balls", "paytable"},
casino.GameBlackjack: {"bet", "rebet", "unbet", "hit", "stand", "double", "split", "insurance", "surrender", "decline"},
casino.GameBaccarat: {"bet", "rebet", "unbet"},
@@ -363,6 +398,18 @@ func (g *Game) executeCommand(sess *net.Session, cmd string, args []string, rawI
}
}
+ // Cash Hunt owns numeric choices only while seated; other games and
+ // world commands keep their usual behavior.
+ if p != nil && g.Casino != nil {
+ if t, playing := g.Casino.Participation(p.Name); playing && t != nil && t.Config.Game == casino.GameCashHunt {
+ numeric := cmd != "" && cmd[0] >= '0' && cmd[0] <= '9'
+ if numeric || cmd == "pick" || cmd == "settle" {
+ g.executeTableAction(sess, strings.Join(append([]string{cmd}, args...), " "))
+ return
+ }
+ }
+ }
+
// Pai Gow owns these inputs only while seated; leave normal commands alone.
if p != nil && g.Casino != nil {
if t, playing := g.Casino.Participation(p.Name); playing && t != nil && t.Config.Game == casino.GamePaiGow {