diff options
| author | historia <[not public]> | 2026-06-25 00:44:47 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-25 00:44:47 -0400 |
| commit | 94a06fbbe682701ca4d4bd2a70cd74d8df29c932 (patch) | |
| tree | eb49fb1893e61092138164d419e863ee3fe0d1e2 /internal/game/action_use.go | |
| parent | 15b7e221b799ef107dec44ecdb294026dfd3d059 (diff) | |
| download | thehouseoficarus-94a06fbbe682701ca4d4bd2a70cd74d8df29c932.tar.gz | |
refactor: replaced map[string]any with typed structs for Data
Diffstat (limited to 'internal/game/action_use.go')
| -rw-r--r-- | internal/game/action_use.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/internal/game/action_use.go b/internal/game/action_use.go index dde838f..4bac96d 100644 --- a/internal/game/action_use.go +++ b/internal/game/action_use.go @@ -34,8 +34,6 @@ func (g *Game) startUse(sess *net.Session, p *player.Player, obj *object.ObjectD return } - p.ActionState = &ActionState{Type: ActionUsing, TargetName: obj.Name} - g.broadcastAction(sess, "\n%s uses the %s.", p.Name, obj.Name) p.Action = &action.Action{ @@ -43,18 +41,19 @@ func (g *Game) startUse(sess *net.Session, p *player.Player, obj *object.ObjectD TargetID: obj.ID, TargetName: obj.Name, WaitLeft: engine.ToTicks(1), - Data: map[string]any{"step": 0, "use_cfg": cfg}, + Data: &action.UseData{Cfg: cfg, Step: 0}, } sess.WriteLine(fmt.Sprintf("%s", cfg.Message)) } func (g *Game) advanceUse(sess *net.Session, p *player.Player) { - cfg, ok := p.Action.Data["use_cfg"].(*action.UseConfig) - if !ok || cfg == nil { + d, ok := p.Action.Data.(*action.UseData) + if !ok || d == nil || d.Cfg == nil { g.cancelAction(p) return } + cfg := d.Cfg for itemID, qty := range cfg.Consume { if !p.HasItem(itemID) { |
