package object import "strings" 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" WeaponTechnology WeaponType = "technology" ) type ItemDef struct { ID string `yaml:"id"` Name string `yaml:"name"` Aliases []string `yaml:"aliases"` Description string `yaml:"description"` Value int `yaml:"value"` // credits Stackable bool `yaml:"stackable"` EquipSlot EquipSlot `yaml:"equip_slot"` WeaponType WeaponType `yaml:"weapon_type"` Stats ItemStats `yaml:"stats"` Speed int `yaml:"speed"` // ticks between attacks Toolbelt bool `yaml:"toolbelt"` // can go on toolbelt } type ItemStats struct { AttackBonus int `yaml:"attack_bonus"` StrengthBonus int `yaml:"strength_bonus"` DefenseBonus int `yaml:"defense_bonus"` ScienceBonus int `yaml:"science_bonus"` TechnologyBonus int `yaml:"technology_bonus"` } func (d *ItemDef) MatchesName(input string) bool { lower := strings.ToLower(input) if strings.ToLower(d.Name) == lower { return true } for _, word := range strings.Fields(d.Name) { if strings.HasPrefix(strings.ToLower(word), lower) { return true } } return false }