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/cmd_cook.go | |
| parent | 5ea082ab4e82409aebc889b496f43e52b003d4f7 (diff) | |
| download | thehouseoficarus-e4400c5f1e84c18d2126f2cb502ae10685977cbb.tar.gz | |
refactor: combined all station crafting
Diffstat (limited to 'internal/game/cmd_cook.go')
| -rw-r--r-- | internal/game/cmd_cook.go | 59 |
1 files changed, 6 insertions, 53 deletions
diff --git a/internal/game/cmd_cook.go b/internal/game/cmd_cook.go index 288afb0..04c98bb 100644 --- a/internal/game/cmd_cook.go +++ b/internal/game/cmd_cook.go @@ -61,28 +61,13 @@ func (g *Game) doCook(sess *net.Session, input string) { } } - if len(recipes) == 0 { - sess.WriteLine("You can't cook that.") - return - } - - if len(recipes) == 1 { - g.promptHowMany(sess, recipes[0].ID) - return - } - - sess.PendingMenu = recipeMenuData(recipeDefIDs(recipes)) - sess.State = net.StateRecipeChoice - var names []string - for _, r := range recipes { - names = append(names, g.recipeName(sess, &r)) - } - g.showMenuTable(sess, fmt.Sprintf("What would you like to cook on the %s?", stationName), names) + title := fmt.Sprintf("What would you like to cook on the %s?", stationName) + g.showRecipeChoice(sess, p, recipes, "You can't cook that.", title, "") } func (g *Game) showCookMenu(sess *net.Session, p *player.Player, allRecipes []action.RecipeDef, stationDefID, stationName string) { seen := make(map[string]bool) - var entries []recipeEntry + var recipes []action.RecipeDef for _, r := range allRecipes { if r.Type != "cooking" { @@ -98,41 +83,9 @@ func (g *Game) showCookMenu(sess *net.Session, p *player.Player, allRecipes []ac continue } seen[r.ID] = true - entries = append(entries, recipeEntry{g.recipeName(sess, &r), r}) - } - - if len(entries) == 0 { - sess.WriteLine("You don't have anything you can cook.") - return + recipes = append(recipes, r) } - if len(entries) == 1 { - if p.OptionBool("cook_all") { - g.startProductionFromRecipe(sess, p, &entries[0].Recipe, 0) - return - } - g.promptHowMany(sess, entries[0].Recipe.ID) - return - } - - sess.State = net.StateRecipeChoice - var names []string - for _, e := range entries { - names = append(names, e.ItemName) - } - g.showMenuTable(sess, fmt.Sprintf("What would you like to cook on the %s?", stationName), names) - ids := make([]string, len(entries)) - for i, e := range entries { - ids[i] = e.Recipe.ID - } - sess.PendingMenu = recipeMenuData(ids) -} - -func (g *Game) recipeName(sess *net.Session, r *action.RecipeDef) string { - if r.Output != "" { - if def, err := g.ItemStore.Load(r.Output); err == nil { - return g.itemColorize(sess, def, def.Name) - } - } - return r.DisplayName() + title := fmt.Sprintf("What would you like to cook on the %s?", stationName) + g.showRecipeChoice(sess, p, recipes, "You don't have anything you can cook.", title, "cook_all") } |
