From 94a06fbbe682701ca4d4bd2a70cd74d8df29c932 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Thu, 25 Jun 2026 00:44:47 -0400 Subject: refactor: replaced map[string]any with typed structs for Data --- internal/game/action_use.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'internal/game/action_use.go') 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) { -- cgit v1.2.3