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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
package item
import (
"strings"
"thehouseoficarus/internal/behavior"
)
type EquipSlot string
const (
SlotHead EquipSlot = "head"
SlotNeck EquipSlot = "neck"
SlotTorso EquipSlot = "torso"
SlotLegs EquipSlot = "legs"
SlotHands EquipSlot = "hands"
SlotFeet EquipSlot = "feet"
SlotBack EquipSlot = "back"
SlotAmmo EquipSlot = "ammo"
SlotMainHand EquipSlot = "main_hand"
SlotOffHand EquipSlot = "off_hand"
SlotRing EquipSlot = "ring"
)
type EquipmentType string
const (
EquipMeleeWeapon EquipmentType = "melee_weapon"
EquipRangedWeapon EquipmentType = "ranged_weapon"
EquipScienceWeapon EquipmentType = "tech_weapon"
EquipArmor EquipmentType = "armor"
EquipTool EquipmentType = "tool"
EquipAmmo EquipmentType = "ammo"
)
func (et EquipmentType) IsWeapon() bool {
return et == EquipMeleeWeapon || et == EquipRangedWeapon || et == EquipScienceWeapon
}
type AttackBonuses struct {
Stab int `yaml:"stab,omitempty"`
Slash int `yaml:"slash,omitempty"`
Crush int `yaml:"crush,omitempty"`
Ranged int `yaml:"ranged,omitempty"`
Science int `yaml:"science,omitempty"`
}
type DefenseBonuses struct {
Stab int `yaml:"stab,omitempty"`
Slash int `yaml:"slash,omitempty"`
Crush int `yaml:"crush,omitempty"`
Ranged int `yaml:"ranged,omitempty"`
Science int `yaml:"science,omitempty"`
}
type OtherBonuses struct {
Strength int `yaml:"strength,omitempty"`
RangedStrength int `yaml:"ranged_strength,omitempty"`
Science int `yaml:"science,omitempty"`
Technology int `yaml:"technology,omitempty"`
}
type EquipmentDef struct {
Type EquipmentType `yaml:"type"`
Slot EquipSlot `yaml:"slot,omitempty"`
AttackType string `yaml:"attack_type,omitempty"`
Speed float64 `yaml:"speed,omitempty"`
Junk string `yaml:"junk,omitempty"`
Attack *AttackBonuses `yaml:"attack,omitempty"`
Defense *DefenseBonuses `yaml:"defense,omitempty"`
Other *OtherBonuses `yaml:"other,omitempty"`
}
type ToolDef struct {
Type string `yaml:"type"`
Speed float64 `yaml:"speed,omitempty"`
}
type ItemDef struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Color string `yaml:"color"`
Description string `yaml:"description"`
Value int `yaml:"value"`
Stackable bool `yaml:"stackable"`
Recoverable bool `yaml:"recoverable"`
Equipment *EquipmentDef `yaml:"equipment,omitempty"`
Tool *ToolDef `yaml:"tool,omitempty"`
Requirements map[string]int `yaml:"requirements,omitempty"`
MaxQuality int `yaml:"max_quality"`
Craft CraftList `yaml:"craft,omitempty"`
Search []behavior.Trigger `yaml:"search,omitempty"`
HealValue int `yaml:"heal_value"`
EatMessage string `yaml:"eat_message"`
FarmPatchType string `yaml:"farm_patch_type"`
FarmLevel int `yaml:"farm_level"`
FarmPlantXP int `yaml:"farm_plant_xp"`
FarmHarvestXP int `yaml:"farm_harvest_xp"`
FarmStages int `yaml:"farm_stages"`
FarmProduct string `yaml:"farm_product"`
FarmMinYield int `yaml:"farm_min_yield"`
FarmMaxYield int `yaml:"farm_max_yield"`
PotionEffect string `yaml:"potion_effect"`
PotionBonus int `yaml:"potion_bonus"`
PotionDuration float64 `yaml:"potion_duration"`
BurnTicks float64 `yaml:"burn_ticks"`
FireLevel int `yaml:"fire_level"`
FireXP int `yaml:"fire_xp"`
}
func (d *ItemDef) EquipmentType() EquipmentType {
if d.Equipment != nil {
return d.Equipment.Type
}
return ""
}
func (d *ItemDef) EquipSlot() EquipSlot {
if d.Equipment != nil {
return d.Equipment.Slot
}
return ""
}
func (d *ItemDef) Speed() float64 {
if d.Equipment != nil {
return d.Equipment.Speed
}
return 0
}
func (d *ItemDef) AttackType() string {
if d.Equipment != nil {
return d.Equipment.AttackType
}
return ""
}
func (d *ItemDef) ToolType() string {
if d.Tool != nil {
return d.Tool.Type
}
return ""
}
func (d *ItemDef) ToolSpeed() float64 {
if d.Tool != nil {
return d.Tool.Speed
}
return 0
}
func (d *ItemDef) ProvidesJunk() string {
if d.Equipment != nil {
return d.Equipment.Junk
}
return ""
}
type ItemStats struct {
StabAttack int
SlashAttack int
CrushAttack int
ScienceAttack int
RangedAttack int
StabDefense int
SlashDefense int
CrushDefense int
ScienceDefense int
RangedDefense int
StrengthBonus int
RangedStrength int
ScienceDamage int
TechnologyBonus int
}
func (d *ItemDef) Stats() ItemStats {
var s ItemStats
if d.Equipment != nil {
if d.Equipment.Attack != nil {
s.StabAttack = d.Equipment.Attack.Stab
s.SlashAttack = d.Equipment.Attack.Slash
s.CrushAttack = d.Equipment.Attack.Crush
s.RangedAttack = d.Equipment.Attack.Ranged
s.ScienceAttack = d.Equipment.Attack.Science
}
if d.Equipment.Defense != nil {
s.StabDefense = d.Equipment.Defense.Stab
s.SlashDefense = d.Equipment.Defense.Slash
s.CrushDefense = d.Equipment.Defense.Crush
s.RangedDefense = d.Equipment.Defense.Ranged
s.ScienceDefense = d.Equipment.Defense.Science
}
if d.Equipment.Other != nil {
s.StrengthBonus = d.Equipment.Other.Strength
s.RangedStrength = d.Equipment.Other.RangedStrength
s.ScienceDamage = d.Equipment.Other.Science
s.TechnologyBonus = d.Equipment.Other.Technology
}
}
return s
}
type CraftList []CraftDef
func (d *ItemDef) FirstCraft() *CraftDef {
if len(d.Craft) == 0 {
return nil
}
return &d.Craft[0]
}
func (d *ItemDef) FindCraft(fn func(CraftDef) bool) *CraftDef {
for i := range d.Craft {
if fn(d.Craft[i]) {
return &d.Craft[i]
}
}
return nil
}
func (d *ItemDef) MatchingCrafts(fn func(CraftDef) bool) []*CraftDef {
var result []*CraftDef
for i := range d.Craft {
if fn(d.Craft[i]) {
result = append(result, &d.Craft[i])
}
}
return result
}
type IngredientEntry struct {
Items []string `yaml:"items"`
Quantity int `yaml:"quantity"`
Byproducts []string `yaml:"byproducts"`
}
type CraftStep struct {
Delay float64 `yaml:"delay"`
Message string `yaml:"message"`
}
type SuccessFormula struct {
Base float64 `yaml:"base"`
PerLevel float64 `yaml:"per_level"`
Cap float64 `yaml:"cap"`
}
type CraftDef struct {
Type string `yaml:"type"`
Subtype string `yaml:"subtype,omitempty"`
Level int `yaml:"level"`
XP int `yaml:"xp"`
TicksPerCycle float64 `yaml:"ticks_per_cycle"`
Station []string `yaml:"station"`
Tool string `yaml:"tool"`
Ingredients []IngredientEntry `yaml:"ingredients"`
OutputQty int `yaml:"output_qty"`
Fail string `yaml:"fail"`
SuccessMessage string `yaml:"success_message"`
FailMessage string `yaml:"fail_message"`
StartMessage string `yaml:"start_message"`
EndMessage string `yaml:"end_message"`
Steps []CraftStep `yaml:"steps"`
Success *SuccessFormula `yaml:"success"`
}
func (c *CraftDef) EffectiveSkill() string {
return c.Type
}
func (d *ItemDef) MatchesName(input string) bool {
lower := strings.ToLower(strings.TrimSpace(input))
if lower == "" {
return false
}
if strings.ToLower(d.Name) == lower {
return true
}
return behavior.WordPrefixMatch(lower, d.Name)
}
|