diff options
Diffstat (limited to 'internal/game/game.go')
| -rw-r--r-- | internal/game/game.go | 19 |
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 |
