aboutsummaryrefslogtreecommitdiff
path: root/internal/game/action.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 18:20:26 -0400
committerhistoria <[not public]>2026-06-19 18:20:26 -0400
commit0ea4eec5dd2122c6704216971eb1249276297867 (patch)
tree430fbbef04e837820f1d031c190f52ecd6112e25 /internal/game/action.go
parent3a58125d14bb307f861b38c6c5b0a63babde7e08 (diff)
downloadthehouseoficarus-0ea4eec5dd2122c6704216971eb1249276297867.tar.gz
shop fixes, 'toggle' completely removed, movement speed increased
Diffstat (limited to 'internal/game/action.go')
-rw-r--r--internal/game/action.go56
1 files changed, 24 insertions, 32 deletions
diff --git a/internal/game/action.go b/internal/game/action.go
index dc21927..f25cabc 100644
--- a/internal/game/action.go
+++ b/internal/game/action.go
@@ -23,8 +23,6 @@ var verbAliases = map[string]string{
"talk": "talk",
"speak": "talk",
"ask": "talk",
- "pull": "toggle",
- "push": "toggle",
"steal": "steal",
"thieve": "steal",
}
@@ -46,8 +44,8 @@ func normalizeVerb(v string) string {
return v
}
-func (g *Game) StartAction(sess *net.Session, verb, target string) {
- p := sess.Player.(*player.Player)
+func (g *Game) startAction(sess *net.Session, verb, target string) {
+ p := sess.Player
verb = normalizeVerb(verb)
@@ -57,9 +55,9 @@ func (g *Game) StartAction(sess *net.Session, verb, target string) {
}
if p.Action != nil {
- g.CancelAction(p)
+ g.cancelAction(p)
}
- g.CancelBackgroundAction(p)
+ g.cancelBackgroundAction(p)
lower := strings.ToLower(target)
instanceIdx := -1
@@ -77,7 +75,6 @@ func (g *Game) StartAction(sess *net.Session, verb, target string) {
var obj *object.ObjectDef
var mob *world.MobInstance
- var behaviorID string
if len(instances) > 0 {
uniqueDefs := make(map[string]bool)
@@ -109,16 +106,15 @@ func (g *Game) StartAction(sess *net.Session, verb, target string) {
}
var err error
obj, err = g.ObjectStore.Load(chosen.DefID)
- if err != nil || obj.BehaviorID == "" {
+ if err != nil || !obj.IsInteractable() {
sess.WriteLine(fmt.Sprintf("You can't %s the %s.", verb, obj.Name))
return
}
- behaviorID = obj.BehaviorID
} else {
mobs := g.MobStore.MobsInRoom(p.RoomID)
var candidates []*world.MobInstance
for _, m := range mobs {
- if m.BehaviorID == "" {
+ if !m.IsTalkable() {
continue
}
if q := m.MatchQuality(lower); q >= world.MatchPrefix {
@@ -140,17 +136,6 @@ func (g *Game) StartAction(sess *net.Session, verb, target string) {
sess.WriteLine("Which one?")
return
}
- behaviorID = mob.BehaviorID
- }
-
- bh, err := g.BehaviorStore.Load(behaviorID)
- if err != nil {
- if obj != nil {
- sess.WriteLine(fmt.Sprintf("Something is wrong with the %s.", obj.Name))
- } else {
- sess.WriteLine("Something is wrong with that.")
- }
- return
}
if obj != nil && obj.ID == "estate_directory" {
@@ -158,7 +143,16 @@ func (g *Game) StartAction(sess *net.Session, verb, target string) {
return
}
- if bh.Type != verb {
+ bhType := ""
+ if obj != nil {
+ bhType = obj.BehaviorType()
+ } else if mob != nil {
+ if mob.IsTalkable() {
+ bhType = "talk"
+ }
+ }
+
+ if bhType != verb {
if obj != nil {
sess.WriteLine(fmt.Sprintf("You can't %s the %s.", verb, obj.Name))
} else {
@@ -167,7 +161,7 @@ func (g *Game) StartAction(sess *net.Session, verb, target string) {
return
}
- switch bh.Type {
+ switch bhType {
case "gather":
if obj == nil {
sess.WriteLine(fmt.Sprintf("You can't %s that.", verb))
@@ -200,21 +194,19 @@ func (g *Game) StartAction(sess *net.Session, verb, target string) {
}
case "use":
g.startUse(sess, p, obj)
- case "toggle":
- g.startToggle(sess, p, obj)
default:
sess.WriteLine(fmt.Sprintf("You can't %s that.", verb))
}
}
-func (g *Game) CancelAction(p *player.Player) {
+func (g *Game) cancelAction(p *player.Player) {
p.Action = nil
p.ActionState = nil
p.WalkSequence = nil
p.ClearMoveState()
}
-func (g *Game) CancelBackgroundAction(p *player.Player) {
+func (g *Game) cancelBackgroundAction(p *player.Player) {
p.BackgroundAction = nil
p.BackgroundActionState = nil
}
@@ -224,8 +216,8 @@ func (g *Game) AdvanceActions() {
return
}
for _, sess := range g.Hub.AllSessions() {
- p, ok := sess.Player.(*player.Player)
- if !ok || p.Action == nil {
+ p := sess.Player
+ if p == nil || p.Action == nil {
continue
}
if !p.Action.Advance() {
@@ -269,8 +261,8 @@ func (g *Game) AdvanceActions() {
}
for _, sess := range g.Hub.AllSessions() {
- p, ok := sess.Player.(*player.Player)
- if !ok || p.BackgroundAction == nil {
+ p := sess.Player
+ if p == nil || p.BackgroundAction == nil {
continue
}
if !p.BackgroundAction.Advance() {
@@ -289,7 +281,7 @@ func (g *Game) AdvanceActions() {
}
func (g *Game) checkCondition(sess *net.Session, c *action.Condition) bool {
- p, _ := sess.Player.(*player.Player)
+ p := sess.Player
if c.AllOf != nil {
for _, sub := range c.AllOf {