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.go71
1 files changed, 61 insertions, 10 deletions
diff --git a/internal/game/cmd_registry.go b/internal/game/cmd_registry.go
index fa3518a..d7b808b 100644
--- a/internal/game/cmd_registry.go
+++ b/internal/game/cmd_registry.go
@@ -5,6 +5,7 @@ import (
"strings"
"thehouseoficarus/internal/behavior"
+ "thehouseoficarus/internal/casino"
"thehouseoficarus/internal/net"
)
@@ -16,16 +17,46 @@ type commandDef struct {
}
var commandRegistry = map[string]commandDef{
- "get": {(*Game).executeGet, ClassActive},
- "take": {(*Game).executeGet, ClassActive},
- "grab": {(*Game).executeGet, ClassActive},
- "pick": {(*Game).executeGet, ClassActive},
- "drop": {(*Game).executeDrop, ClassActive},
- "attack": {(*Game).executeAttack, ClassActive},
- "kill": {(*Game).executeAttack, ClassActive},
- "work": {(*Game).executeWork, ClassActive},
- "play": {(*Game).executePlay, ClassActive},
- "rebet": {(*Game).executeBet, ClassActive},
+ "get": {(*Game).executeGet, ClassActive},
+ "take": {(*Game).executeGet, ClassActive},
+ "grab": {(*Game).executeGet, ClassActive},
+ "pick": {(*Game).executeGet, ClassActive},
+ "drop": {(*Game).executeDrop, ClassActive},
+ "attack": {(*Game).executeAttack, ClassActive},
+ "kill": {(*Game).executeAttack, ClassActive},
+ "work": {(*Game).executeWork, ClassActive},
+ "play": {(*Game).executePlay, ClassActive},
+ "rebet": {(*Game).executeBet, ClassActive},
+ "draw": {func(g *Game, s *net.Session, _ []string, _ string) { g.executeTableAction(s, "draw") }, ClassActive},
+ "hold": {func(g *Game, s *net.Session, args []string, _ string) {
+ g.executeTableAction(s, "hold "+strings.Join(args, " "))
+ }, ClassInstant},
+ "deal": {func(g *Game, s *net.Session, args []string, _ string) {
+ if len(args) > 0 {
+ s.WriteLine("Use deal.")
+ return
+ }
+ g.executeTableAction(s, "deal")
+ }, ClassActive},
+ "paytable": {func(g *Game, s *net.Session, _ []string, _ string) { g.executeTableAction(s, "paytable") }, ClassInstant},
+ "denom": {func(g *Game, s *net.Session, args []string, _ string) {
+ g.executeTableAction(s, "denom "+strings.Join(args, " "))
+ }, ClassInstant},
+ "denomination": {func(g *Game, s *net.Session, args []string, _ string) {
+ g.executeTableAction(s, "denom "+strings.Join(args, " "))
+ }, ClassInstant},
+ "hands": {func(g *Game, s *net.Session, args []string, _ string) {
+ g.executeTableAction(s, "hands "+strings.Join(args, " "))
+ }, ClassInstant},
+ "feature": {func(g *Game, s *net.Session, args []string, _ string) {
+ g.executeTableAction(s, "feature "+strings.Join(args, " "))
+ }, ClassInstant},
+ "game": {func(g *Game, s *net.Session, args []string, _ string) {
+ g.executeTableAction(s, "game "+strings.Join(args, " "))
+ }, ClassInstant},
+ "payout": {func(g *Game, s *net.Session, args []string, _ string) {
+ g.executeTableAction(s, "payout "+strings.Join(args, " "))
+ }, ClassInstant},
"roll": {func(g *Game, s *net.Session, _ []string, _ string) { g.executeTableAction(s, "roll") }, ClassActive},
"autoroll": {func(g *Game, s *net.Session, _ []string, _ string) { g.executeTableAction(s, "autoroll") }, ClassInstant},
"unbet": {func(g *Game, s *net.Session, args []string, _ string) {
@@ -192,6 +223,9 @@ var commandRegistry = map[string]commandDef{
}
func classifyCommand(cmd string) CommandClass {
+ if _, ok := casino.ParsePokerDigits(cmd); ok {
+ return ClassInstant
+ }
if def, ok := commandRegistry[cmd]; ok {
return def.class
}
@@ -226,6 +260,23 @@ func (g *Game) executeCommand(sess *net.Session, cmd string, args []string, rawI
}
}
+ // Video poker: numeric tokens toggle holds and d draws, so both are
+ // intercepted before the shared registry (where d means "down").
+ _, pokerDigits := casino.ParsePokerDigits(cmd)
+ if p != nil && g.Casino != nil && (cmd == "d" || pokerDigits) {
+ if t, playing := g.Casino.Participation(p.Name); playing && t != nil && t.Config.Game == casino.GameVideoPoker {
+ if cmd == "d" {
+ if len(args) != 0 {
+ sess.WriteLine("Use d or draw.")
+ return
+ }
+ g.executeTableAction(sess, "draw")
+ return
+ }
+ g.executeTableAction(sess, strings.Join(append([]string{cmd}, args...), " "))
+ return
+ }
+ }
if def, ok := commandRegistry[cmd]; ok {
def.handler(g, sess, args, rawInput)
return