diff options
| author | historia <[not public]> | 2026-06-25 15:40:48 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-25 15:40:48 -0400 |
| commit | abd612c15799f604e671e83dc7c410ed2b44185f (patch) | |
| tree | 0597ca92350de73aac2a7cf26b2f2d6595dac0cc /internal/game/cmd_fletch.go | |
| parent | 2725e2927a1595c7b100d942d1f14146252adeb7 (diff) | |
| download | thehouseoficarus-abd612c15799f604e671e83dc7c410ed2b44185f.tar.gz | |
slop refactor
Diffstat (limited to 'internal/game/cmd_fletch.go')
| -rw-r--r-- | internal/game/cmd_fletch.go | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/internal/game/cmd_fletch.go b/internal/game/cmd_fletch.go index 9cf50bc..0da8129 100644 --- a/internal/game/cmd_fletch.go +++ b/internal/game/cmd_fletch.go @@ -3,9 +3,9 @@ package game import ( "strings" - "thehouseoficarus/internal/combat" + "thehouseoficarus/internal/behavior" + "thehouseoficarus/internal/item" "thehouseoficarus/internal/net" - "thehouseoficarus/internal/object" "thehouseoficarus/internal/player" ) @@ -23,15 +23,15 @@ var fletchGemItems = map[string]bool{ "uncut_ruby": true, "uncut_diamond": true, } -func fletchNeedsKnife(item *object.ItemDef) bool { - return item.FindCraft(func(c object.CraftDef) bool { +func fletchNeedsKnife(def *item.ItemDef) bool { + return def.FindCraft(func(c item.CraftDef) bool { if c.Tool == "knife" { return true } for _, e := range c.Consume { for _, id := range e.Items { if fletchLogItems[id] { - if strings.Contains(item.ID, "shaft") || strings.Contains(item.ID, "bow") { + if strings.Contains(def.ID, "shaft") || strings.Contains(def.ID, "bow") { return true } } @@ -41,8 +41,8 @@ func fletchNeedsKnife(item *object.ItemDef) bool { }) != nil } -func fletchNeedsChisel(item *object.ItemDef) bool { - return item.FindCraft(func(c object.CraftDef) bool { +func fletchNeedsChisel(def *item.ItemDef) bool { + return def.FindCraft(func(c item.CraftDef) bool { if c.Tool == "chisel" { return true } @@ -60,7 +60,7 @@ func fletchNeedsChisel(item *object.ItemDef) bool { func (g *Game) doFletch(sess *net.Session, input string) { p := sess.Player - if combat.GetCombat(p.Name) != nil { + if g.Combat.Get(p.Name) != nil { sess.WriteLine("You can't do that during combat!") return } @@ -103,13 +103,13 @@ func (g *Game) doFletch(sess *net.Session, input string) { g.showProductionTable(sess, p, available, "Fletching", "fletching", "last_fletch", "Fletch", true) } -func (g *Game) doFletchWithInput(sess *net.Session, p *player.Player, items []*object.ItemDef, input string) { +func (g *Game) doFletchWithInput(sess *net.Session, p *player.Player, items []*item.ItemDef, input string) { qty, productName := parseQty(input) productName = strings.TrimSpace(productName) - var matched []*object.ItemDef + var matched []*item.ItemDef for _, item := range items { - if object.WordPrefixMatch(productName, item.Name) { + if behavior.WordPrefixMatch(productName, item.Name) { matched = append(matched, item) } } @@ -119,7 +119,7 @@ func (g *Game) doFletchWithInput(sess *net.Session, p *player.Player, items []*o return } - var available []*object.ItemDef + var available []*item.ItemDef for _, item := range matched { if g.canDoFletchItem(p, item) { available = append(available, item) @@ -139,7 +139,7 @@ func (g *Game) doFletchWithInput(sess *net.Session, p *player.Player, items []*o g.showProductionTable(sess, p, available, "Fletching", "fletching", "last_fletch", "Fletch", true) } -func (g *Game) hasFletchTools(p *player.Player, item *object.ItemDef) bool { +func (g *Game) hasFletchTools(p *player.Player, item *item.ItemDef) bool { c := item.FirstCraft() if c.Tool != "" { return g.hasToolType(p, c.Tool) @@ -153,27 +153,27 @@ func (g *Game) hasFletchTools(p *player.Player, item *object.ItemDef) bool { return true } -func (g *Game) canDoFletchItem(p *player.Player, item *object.ItemDef) bool { - return item.FindCraft(func(c object.CraftDef) bool { +func (g *Game) canDoFletchItem(p *player.Player, def *item.ItemDef) bool { + return def.FindCraft(func(c item.CraftDef) bool { return p.Level(player.Fletching) >= c.Level && craftHasAllItemsQty(&c, p.CountItem) - }) != nil && g.hasFletchTools(p, item) + }) != nil && g.hasFletchTools(p, def) } -func (g *Game) availableFletchItems(p *player.Player, allItems []*object.ItemDef) []*object.ItemDef { - var result []*object.ItemDef - for _, item := range allItems { - match := item.FindCraft(func(c object.CraftDef) bool { +func (g *Game) availableFletchItems(p *player.Player, allItems []*item.ItemDef) []*item.ItemDef { + var result []*item.ItemDef + for _, def := range allItems { + match := def.FindCraft(func(c item.CraftDef) bool { return craftHasAllItemsQty(&c, p.CountItem) }) - if match != nil && g.hasFletchTools(p, item) { - result = append(result, item) + if match != nil && g.hasFletchTools(p, def) { + result = append(result, def) } } return result } -func (g *Game) findFletchItems(p *player.Player, itemAID, itemBID string) []*object.ItemDef { +func (g *Game) findFletchItems(p *player.Player, itemAID, itemBID string) []*item.ItemDef { items := g.CraftIndex.ByType("fletching") toolTypeA := "" @@ -187,7 +187,7 @@ func (g *Game) findFletchItems(p *player.Player, itemAID, itemBID string) []*obj isToolA := toolTypeA == "knife" || toolTypeA == "chisel" isToolB := toolTypeB == "knife" || toolTypeB == "chisel" - var matched []*object.ItemDef + var matched []*item.ItemDef for _, item := range items { c := item.FirstCraft() |
