blob: 8ec156528f4d11566cbf2e78cb8398778a466684 (
plain)
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
|
package object
import (
"strings"
"thehouseoficarus/internal/action"
)
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 WeaponType string
const (
WeaponMelee WeaponType = "melee"
WeaponRanged WeaponType = "ranged"
WeaponScience WeaponType = "science"
)
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"`
EquipSlot EquipSlot `yaml:"equip_slot"`
WeaponType WeaponType `yaml:"weapon_type"`
AttackType string `yaml:"attack_type"`
Stats ItemStats `yaml:"stats"`
Speed float64 `yaml:"speed"`
Requirements map[string]int `yaml:"requirements,omitempty"`
ToolType string `yaml:"tool_type"`
ToolSpeed float64 `yaml:"tool_speed"`
BurnTicks float64 `yaml:"burn_ticks"`
FireLevel int `yaml:"fire_level"`
FireXP int `yaml:"fire_xp"`
Quality int `yaml:"quality"`
MaxQuality int `yaml:"max_quality"`
SearchTable string `yaml:"search_table"`
SearchMiscTable string `yaml:"search_misc_table"`
SearchTicks float64 `yaml:"search_ticks"`
SearchMessage string `yaml:"search_message"`
HealValue int `yaml:"heal_value"`
EatMessage string `yaml:"eat_message"`
MadeFrom []MadeFromEntry `yaml:"made_from,omitempty"`
Ticks float64 `yaml:"ticks"`
ProvidesJunk string `yaml:"provides_junk,omitempty"`
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"`
}
type MadeFromEntry struct {
Items []string `yaml:"items"`
Quantity int `yaml:"quantity"`
Byproducts []string `yaml:"byproducts"`
}
type ItemStats struct {
StabAttack int `yaml:"stab_attack"`
SlashAttack int `yaml:"slash_attack"`
CrushAttack int `yaml:"crush_attack"`
ScienceAttack int `yaml:"science_attack"`
RangedAttack int `yaml:"ranged_attack"`
StabDefense int `yaml:"stab_defense"`
SlashDefense int `yaml:"slash_defense"`
CrushDefense int `yaml:"crush_defense"`
ScienceDefense int `yaml:"science_defense"`
RangedDefense int `yaml:"ranged_defense"`
StrengthBonus int `yaml:"strength_bonus"`
RangedStrength int `yaml:"ranged_strength"`
ScienceDamage int `yaml:"science_damage"`
TechnologyBonus int `yaml:"technology_bonus"`
}
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 action.WordPrefixMatch(lower, d.Name)
}
|