1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
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
}
}
|