diff options
| author | historia <[not public]> | 2026-06-20 03:20:01 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-20 03:20:01 -0400 |
| commit | e4400c5f1e84c18d2126f2cb502ae10685977cbb (patch) | |
| tree | 0523e9d68f1cfdc6f81b862e3068fe12c1a85054 /internal/game/action_gather.go | |
| parent | 5ea082ab4e82409aebc889b496f43e52b003d4f7 (diff) | |
| download | thehouseoficarus-e4400c5f1e84c18d2126f2cb502ae10685977cbb.tar.gz | |
refactor: combined all station crafting
Diffstat (limited to 'internal/game/action_gather.go')
| -rw-r--r-- | internal/game/action_gather.go | 78 |
1 files changed, 5 insertions, 73 deletions
diff --git a/internal/game/action_gather.go b/internal/game/action_gather.go index e169beb..9b47de2 100644 --- a/internal/game/action_gather.go +++ b/internal/game/action_gather.go @@ -53,42 +53,11 @@ func (g *Game) startGather(sess *net.Session, p *player.Player, obj *object.Obje } wait := cfg.BaseWait + var toolName string if len(cfg.Tools) > 0 { - var toolSpeed float64 = -1 - if itemID, ok := p.Equipment[object.SlotMainHand]; ok { - def, err := g.ItemStore.Load(itemID) - if err == nil { - for _, t := range cfg.Tools { - if def.ToolType == t { - toolSpeed = def.ToolSpeed - break - } - } - } - } - if toolSpeed < 0 { - for i := 0; i < 28; i++ { - slot := p.InvSlot(i) - if slot == nil { - continue - } - def, err := g.ItemStore.Load(slot.ItemID) - if err != nil { - continue - } - for _, t := range cfg.Tools { - if def.ToolType == t { - toolSpeed = def.ToolSpeed - break - } - } - if toolSpeed >= 0 { - break - } - } - } - if toolSpeed < 0 { + toolSpeed, name, found := g.findTool(p, cfg.Tools) + if !found { names := make([]string, len(cfg.Tools)) for i, t := range cfg.Tools { names[i] = strings.ReplaceAll(t, "_", " ") @@ -97,6 +66,7 @@ func (g *Game) startGather(sess *net.Session, p *player.Player, obj *object.Obje sess.WriteLine(fmt.Sprintf("You need a %s to do that.", toolList)) return } + toolName = name wait = cfg.BaseWait - toolSpeed if wait < 1 { wait = 1 @@ -118,38 +88,6 @@ func (g *Game) startGather(sess *net.Session, p *player.Player, obj *object.Obje sess.WriteLine("Your inventory is too full!") return } - - toolName := "" - if itemID, ok := p.Equipment[object.SlotMainHand]; ok { - if def, err := g.ItemStore.Load(itemID); err == nil { - for _, t := range cfg.Tools { - if def.ToolType == t { - toolName = def.Name - break - } - } - } - } - if toolName == "" { - for _, slot := range p.Inventory { - if slot == nil || slot.Quantity <= 0 { - continue - } - def, err := g.ItemStore.Load(slot.ItemID) - if err != nil { - continue - } - for _, t := range cfg.Tools { - if def.ToolType == t { - toolName = def.Name - break - } - } - if toolName != "" { - break - } - } - } verb := cfg.Skill switch cfg.Skill { case "woodcutting": @@ -157,13 +95,7 @@ func (g *Game) startGather(sess *net.Session, p *player.Player, obj *object.Obje } p.ActionState = &ActionState{Type: ActionGathering, TargetName: obj.Name, ToolName: toolName, Verb: verb} - if g.Hub != nil { - for _, other := range g.Hub.PlayersInRoom(p.RoomID) { - if other != sess && other.Player != nil { - other.WriteLine(g.colorize(other, "broadcast", fmt.Sprintf("\n%s starts %s the %s.", p.Name, verb, obj.Name))) - } - } - } + g.broadcastAction(sess, "\n%s starts %s the %s.", p.Name, verb, obj.Name) data := map[string]any{ "obj_def_id": obj.ID, |
