diff options
Diffstat (limited to 'internal/game/cmd_fletch.go')
| -rw-r--r-- | internal/game/cmd_fletch.go | 78 |
1 files changed, 42 insertions, 36 deletions
diff --git a/internal/game/cmd_fletch.go b/internal/game/cmd_fletch.go index af27897..9c147c3 100644 --- a/internal/game/cmd_fletch.go +++ b/internal/game/cmd_fletch.go @@ -189,51 +189,57 @@ func (g *Game) findFletchItems(itemAID, itemBID string) []*item.ItemDef { var matched []*item.ItemDef for _, item := range items { - c := item.FirstCraft() - - if c.Tool != "" { - if c.Tool == toolTypeA && craftMatchesEntry(c, itemBID) { - matched = append(matched, item) - continue - } - if c.Tool == toolTypeB && craftMatchesEntry(c, itemAID) { + for i := range item.Craft { + if fletchCraftMatchesInputs(&item.Craft[i], item, itemAID, itemBID, toolTypeA, toolTypeB, isToolA, isToolB) { matched = append(matched, item) - continue + break } } + } + return matched +} - aMatch := false - bMatch := false - for _, e := range c.Ingredients { - for _, id := range e.Items { - if id == itemAID { - aMatch = true - } - if id == itemBID { - bMatch = true - } - } +// fletchCraftMatchesInputs reports whether one fletching recipe consumes the +// given two inputs (or a tool plus one input). findFletchItems must scan every +// recipe, not just the first, or multi-recipe items are unreachable. +func fletchCraftMatchesInputs(c *item.CraftDef, item *item.ItemDef, itemAID, itemBID, toolTypeA, toolTypeB string, isToolA, isToolB bool) bool { + if c.Tool != "" { + if c.Tool == toolTypeA && craftMatchesEntry(c, itemBID) { + return true } - - if aMatch && bMatch { - matched = append(matched, item) - continue + if c.Tool == toolTypeB && craftMatchesEntry(c, itemAID) { + return true } + } - if isToolA && bMatch { - if (fletchNeedsKnife(item) && toolTypeA == "knife") || - (fletchNeedsChisel(item) && toolTypeA == "chisel") { - matched = append(matched, item) - continue + aMatch := false + bMatch := false + for _, e := range c.Ingredients { + for _, id := range e.Items { + if id == itemAID { + aMatch = true } - } - if isToolB && aMatch { - if (fletchNeedsKnife(item) && toolTypeB == "knife") || - (fletchNeedsChisel(item) && toolTypeB == "chisel") { - matched = append(matched, item) - continue + if id == itemBID { + bMatch = true } } } - return matched + + if aMatch && bMatch { + return true + } + + if isToolA && bMatch { + if (fletchNeedsKnife(item) && toolTypeA == "knife") || + (fletchNeedsChisel(item) && toolTypeA == "chisel") { + return true + } + } + if isToolB && aMatch { + if (fletchNeedsKnife(item) && toolTypeB == "knife") || + (fletchNeedsChisel(item) && toolTypeB == "chisel") { + return true + } + } + return false } |
