diff options
| author | historia <[not public]> | 2026-06-18 20:26:03 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-18 20:26:03 -0400 |
| commit | 97a1a908b9e6e6d3516628c139c9b64262b4fe08 (patch) | |
| tree | d82953974edbfb4051dff1a48f1b264b9c264d28 /internal/game/cmd_use.go | |
| parent | 17e7725f252c7f5d3be2e9c37d62751c631f196f (diff) | |
| download | thehouseoficarus-97a1a908b9e6e6d3516628c139c9b64262b4fe08.tar.gz | |
feat: crafting roughly implemented (leather, gems, gold, clay, spinning).
Diffstat (limited to 'internal/game/cmd_use.go')
| -rw-r--r-- | internal/game/cmd_use.go | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/internal/game/cmd_use.go b/internal/game/cmd_use.go index 8b8f43e..4d4ce88 100644 --- a/internal/game/cmd_use.go +++ b/internal/game/cmd_use.go @@ -86,7 +86,7 @@ func (g *Game) doUseItemOnTarget(sess *net.Session, p *player.Player, itemAName, if !r.HasAllItemsQty(p.CountItem) { continue } - skillLevel := p.Level(player.SkillName(r.Skill)) + skillLevel := p.Level(player.SkillName(r.EffectiveSkill())) if skillLevel < r.Level { continue } @@ -171,7 +171,53 @@ func (g *Game) doUseItemOnTarget(sess *net.Session, p *player.Player, itemAName, itemBID := matchesB[0].ID + craftRecipes := g.findCraftRecipesForItems(p, itemAID, itemBID) fletchRecipes := g.findFletchRecipesForItems(p, itemAID, itemBID) + + if len(craftRecipes) > 0 && len(fletchRecipes) > 0 { + var menu []map[string]string + var names []string + for _, r := range craftRecipes { + menu = append(menu, map[string]string{"recipe_id": r.ID}) + outDef, _ := g.ItemStore.Load(r.Output) + name := r.Output + if outDef != nil { + name = outDef.Name + } + names = append(names, fmt.Sprintf("%s (Crafting)", name)) + } + for _, r := range fletchRecipes { + menu = append(menu, map[string]string{"fletch_recipe_id": r.ID}) + outDef, _ := g.ItemStore.Load(r.Output) + name := r.Output + if outDef != nil { + name = outDef.Name + } + names = append(names, fmt.Sprintf("%s (Fletching)", name)) + } + sess.PendingMenu = menu + sess.State = net.StateRecipeChoice + g.showMenuTable(sess, "What would you like to make?", names) + return + } + + if len(craftRecipes) > 0 { + var available []action.RecipeDef + for _, r := range craftRecipes { + if g.canDoCraftRecipe(p, &r) { + available = append(available, r) + } + } + if len(available) == 1 { + g.startCraftRecipe(sess, p, &available[0], 0) + return + } + if len(available) > 1 { + g.showProductionTable(sess, p, available, "Crafting", "crafting", "last_craft", "Craft", false) + return + } + } + if len(fletchRecipes) > 0 { var available []action.RecipeDef for _, r := range fletchRecipes { @@ -184,7 +230,7 @@ func (g *Game) doUseItemOnTarget(sess *net.Session, p *player.Player, itemAName, return } if len(available) > 1 { - g.showFletchTable(sess, p, available) + g.showProductionTable(sess, p, available, "Fletching", "fletching", "last_fletch", "Fletch", true) return } } |
