aboutsummaryrefslogtreecommitdiff
path: root/internal/game/game.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-12 18:59:22 -0400
committerhistoria <[not public]>2026-06-12 18:59:22 -0400
commitf3a6ae488bbd2128af8356b0da016699c5abb70e (patch)
tree76965c30baa5d6ab92d1fa9c371d7ca3f08349ba /internal/game/game.go
parentd6ab0e93a64525ce34f89e26d5272efbac513c32 (diff)
downloadthehouseoficarus-f3a6ae488bbd2128af8356b0da016699c5abb70e.tar.gz
feat: commands automatically target if unambiguous, depleted node improvements
Diffstat (limited to 'internal/game/game.go')
-rw-r--r--internal/game/game.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/internal/game/game.go b/internal/game/game.go
index 8151877..cc187a7 100644
--- a/internal/game/game.go
+++ b/internal/game/game.go
@@ -100,7 +100,8 @@ func (g *Game) handleGameCommand(sess *net.Session, input string) {
return
}
- if p, ok := sess.Player.(*player.Player); ok {
+ p, _ := sess.Player.(*player.Player)
+ if p != nil {
g.cancelRest(p.Name)
}
@@ -153,7 +154,13 @@ func (g *Game) handleGameCommand(sess *net.Session, input string) {
}
case "attack", "kill":
if len(args) == 0 {
- sess.WriteLine("Attack what?")
+ target := g.resolveDefaultMob(p.RoomID)
+ if target == "" {
+ sess.WriteLine("Attack what?")
+ break
+ }
+ g.doAttack(sess, target)
+ return
} else {
g.doAttack(sess, strings.Join(args, " "))
return
@@ -209,7 +216,13 @@ func (g *Game) handleGameCommand(sess *net.Session, input string) {
}
case "mine", "chop", "fish", "cut", "use", "pull", "push":
if len(args) == 0 {
- sess.WriteLine(fmt.Sprintf("%s what?", cmd))
+ target := g.resolveDefaultTarget(p.RoomID, cmd)
+ if target == "" {
+ sess.WriteLine(fmt.Sprintf("%s what?", cmd))
+ break
+ }
+ g.StartAction(sess, cmd, target)
+ return
} else {
g.StartAction(sess, cmd, strings.Join(args, " "))
return