aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_cook.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/cmd_cook.go')
-rw-r--r--internal/game/cmd_cook.go59
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")
}