package game import ( "thehouseoficarus/internal/behavior" "thehouseoficarus/internal/item" "thehouseoficarus/internal/player" ) func (g *Game) findTool(p *player.Player, toolTypes []string) (toolSpeed float64, toolName string, toolType string, found bool) { toolSpeed = -1 if itemID, ok := p.Equipment[item.SlotMainHand]; ok { if def, err := g.ItemStore.Load(itemID); err == nil { for _, t := range toolTypes { if def.ToolType() == t { return def.ToolSpeed(), def.Name, t, true } } } } for i := 0; i < 28; i++ { slot := p.InvSlot(i) if slot == nil { continue } def, err := g.ItemStore.Load(slot.ItemID) if err != nil { continue } for _, t := range toolTypes { if def.ToolType() == t { return def.ToolSpeed(), def.Name, t, true } } } return -1, "", "", false } func (g *Game) hasToolType(p *player.Player, toolType string) bool { _, _, _, found := g.findTool(p, []string{toolType}) return found } type productionTypeInfo struct { ActionType behavior.ActionType DisplayVerb string StartMessage string SuccessMessage string EndMessage string FailMessage string } var productionTypes = map[string]productionTypeInfo{ "cooking": { ActionType: behavior.TypeCook, DisplayVerb: "cooking", StartMessage: "You start cooking %i1.", SuccessMessage: "Cooked to perfection. %n looks great!", EndMessage: "You've finished cooking.", FailMessage: "You accidentally burn the %i1.", }, "smelting": { ActionType: behavior.TypeSmelt, DisplayVerb: "smelting", StartMessage: "You place the %i1 into the furnace.", SuccessMessage: "You remove a white hot %n!", EndMessage: "You've finished smelting.", FailMessage: "The %i1 is consumed by the flames.", }, "smithing": { ActionType: behavior.TypeSmith, DisplayVerb: "smithing", StartMessage: "You begin smithing %i1.", SuccessMessage: "You smith a %n.", EndMessage: "You've finished smithing.", }, "crafting": { ActionType: behavior.TypeCraft, DisplayVerb: "crafting", StartMessage: "You begin crafting %i1.", SuccessMessage: "You craft a %n.", EndMessage: "You've finished crafting.", }, "fletching": { ActionType: behavior.TypeFletch, DisplayVerb: "fletching", StartMessage: "You begin fletching %i1.", SuccessMessage: "You fletch a %n.", EndMessage: "You've finished fletching.", }, "pharmacy": { ActionType: behavior.TypeMix, DisplayVerb: "mixing", StartMessage: "You start mixing %i1.", SuccessMessage: "You mix a %n.", EndMessage: "You've finished mixing.", }, "construction": { ActionType: behavior.TypeConstruct, DisplayVerb: "constructing", StartMessage: "You begin constructing %i1.", SuccessMessage: "You construct a %n.", EndMessage: "You've finished constructing.", }, } var productionActionTypes map[string]bool func init() { productionActionTypes = make(map[string]bool) for _, pt := range productionTypes { productionActionTypes[string(pt.ActionType)] = true } }