items

package
v0.9.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown ItemType = ""

	// Equipment
	Weapon  ItemType = "weapon"
	Offhand ItemType = "offhand"
	Head    ItemType = "head"
	Neck    ItemType = "neck"
	Body    ItemType = "body"
	Belt    ItemType = "belt"
	Gloves  ItemType = "gloves"
	Ring    ItemType = "ring"
	Legs    ItemType = "legs"
	Feet    ItemType = "feet"
	// Consumables
	Potion  ItemType = "potion"
	Food    ItemType = "food"
	Drink   ItemType = "drink"
	Scroll  ItemType = "scroll"
	Grenade ItemType = "grenade" // Expected to be thrown
	Junk    ItemType = "junk"

	// Other
	Readable  ItemType = "readable"  // Something with writing to reveal when read
	Key       ItemType = "key"       // A key for a door
	Object    ItemType = "object"    // A mundane object
	Gemstone  ItemType = "gemstone"  // A gem
	Lockpicks ItemType = "lockpicks" // Used for lockpicking
	Botanical ItemType = "botanical" // A plant, herb, etc.
	Service   ItemType = "service"   // Possibly a ticket,action, or favor being purchased

	// Subtypes for wearables
	Wearable  ItemSubType = "wearable"
	Drinkable ItemSubType = "drinkable"
	Edible    ItemSubType = "edible"
	Usable    ItemSubType = "usable"
	Throwable ItemSubType = "throwable" // If dropped/thrown, triggers buff effects on room and is lost
	Mundane   ItemSubType = "mundane"

	// Subtypes for weapons, chooses attack messages.
	Generic     ItemSubType = "generic"
	Bludgeoning ItemSubType = "bludgeoning"
	Cleaving    ItemSubType = "cleaving"
	Stabbing    ItemSubType = "stabbing"
	Slashing    ItemSubType = "slashing"
	Shooting    ItemSubType = "shooting" // bows, crossbows, guns, etc.
	Claws       ItemSubType = "claws"
	Whipping    ItemSubType = "whipping"

	BlobContent ItemSubType = "blobcontent"

	OneHanded WeaponHands = 1
	TwoHanded WeaponHands = 2

	Fire        Element = "fire"
	Water       Element = "water"
	Ice         Element = "ice"
	Electricity Element = "electricity"
	Acid        Element = "acid"
	Life        Element = "life"
	Death       Element = "death"

	// Intensity of the attack
	Prepare  Intensity = "prepare"
	Wait     Intensity = "wait"
	Miss     Intensity = "miss"
	Weak     Intensity = "weak"
	Normal   Intensity = "normal"
	Heavy    Intensity = "heavy"
	Critical Intensity = "critical"

	// Tokens
	TokenItemName     TokenName = "{itemname}"
	TokenSource       TokenName = "{source}"
	TokenSourceType   TokenName = "{sourcetype}" // will be 'user' or 'mob'
	TokenTarget       TokenName = "{target}"
	TokenTargetType   TokenName = "{targettype}" // will be 'user' or 'mob'
	TokenUsesLeft     TokenName = "{usesleft}"
	TokenDamage       TokenName = "{damage}"
	TokenEntranceName TokenName = "{entrancename}"
	TokenExitName     TokenName = "{exitname}"

	POVUser  = 0
	POVOther = 1
)
View Source
const (
	// TODO: Centralize these types somewhere, eventually?
	UUIDItem = uuid.IDType(0b00000001)
)

Variables

View Source
var (
	ItemDisabledSlot = Item{ItemId: -1}
)

Functions

func CanBackstab

func CanBackstab(iSubType ItemSubType) bool

func CreateNewItemFile

func CreateNewItemFile(newItemInfo ItemSpec) (int, error)

func FindItem

func FindItem(nameOrId string) int

func FindItemByName

func FindItemByName(name string) int

func FindKeyByLockId

func FindKeyByLockId(lockId string) int

func FindMatchIn

func FindMatchIn(itemName string, items ...Item) (pMatch Item, fMatch Item)

Provided a name and a list of items, find the first item that matches the name Will first provide a pair of starts-width and exact matches, and if not found then a contains.

func GetAllItemNames

func GetAllItemNames() []string

func GetMemoryUsage

func GetMemoryUsage() map[string]util.MemoryResult

func LoadDataFiles

func LoadDataFiles()

file self loads due to init()

Types

type AttackEffects

type AttackEffects map[Intensity]AttackMessageOptions

type AttackMessageOptions

type AttackMessageOptions []ItemMessage

Attack messages

type AttackMessages

type AttackMessages map[ItemSubType]AttackEffects

type AttackOptions

type AttackOptions struct {
	Together TogetherMessages `yaml:"together"`
	Separate SeparateMessages `yaml:"separate"`
}

func GetAttackMessage

func GetAttackMessage(subType ItemSubType, pctDamage int) AttackOptions

func GetPreAttackMessage

func GetPreAttackMessage(subType ItemSubType, messageType Intensity) AttackOptions

type AttackTypes

type AttackTypes map[Intensity]AttackOptions

type Damage

type Damage struct {
	Attacks     int    `yaml:"attacks,omitempty"` // How many attacks this weapon gets (usually 1)
	DiceRoll    string // 1d6, etc.
	CritBuffIds []int  `yaml:"critbuffids,omitempty"` // If this damage is a crit, what buffs does it apply?
	DiceCount   int    `yaml:"dicecount,omitempty"`   // how many dice to roll for this weapons damage
	SideCount   int    `yaml:"sidecount,omitempty"`   // how many sides per dice roll
	BonusDamage int    `yaml:"bonusdamage,omitempty"` // flat damage bonus, so for example 1d6+1
}

func (*Damage) FormatDiceRoll

func (d *Damage) FormatDiceRoll() string

func (*Damage) InitDiceRoll

func (d *Damage) InitDiceRoll(dRoll string)

func (*Damage) String

func (d *Damage) String() string

type Element

type Element string

func (Element) String

func (i Element) String() string

type Intensity

type Intensity string

type Item

type Item struct {
	ItemId        int       `yaml:"itemid,omitempty"`
	UUID          uuid.UUID `yaml:"-"`                       // `yaml:"uuid,omitempty"`
	Blob          string    `yaml:"blob,omitempty"`          // Does this item have a blob? Should be base64 encoded.
	Uses          int       `yaml:"uses,omitempty"`          // How many uses it has left
	LastUsedRound uint64    `yaml:"lastusedround,omitempty"` // Last round this item was used
	Spec          *ItemSpec `yaml:"overrides,omitempty"`
	Uncursed      bool      `yaml:"uncursed,omitempty"`     // Is this item uncursed?
	Enchantments  uint8     `yaml:"enchantments,omitempty"` // Is this item enchanted?
	Adjectives    []string  `yaml:"adjectives,omitempty"`   // Decorative text for the name of the item (e.g. "exploding")
	StashedBy     int       `yaml:"stashedby,omitempty"`    // userid of whoever stashed this item
	// contains filtered or unexported fields
}

Instance properties that may change

func New

func New(itemId int) Item

func (*Item) AddWornBuff

func (i *Item) AddWornBuff(buffId int)

func (*Item) AttrString

func (i *Item) AttrString() string

func (*Item) BreakTest

func (i *Item) BreakTest(increaseChance ...int) bool

performs a break test and returns true if the item breaks Pass a uint8 to increase the chance of breaking.

func (*Item) DisplayName

func (i *Item) DisplayName() string

func (*Item) Enchant

func (i *Item) Enchant(damageBonus int, defenseBonus int, statBonus map[string]int, cursed bool)

enchantmentLevel is 0-100. If 0(zero) remove any enchantments.

func (*Item) Equals

func (i *Item) Equals(b Item) bool

func (*Item) GetBlob

func (i *Item) GetBlob() string

func (*Item) GetDamage

func (i *Item) GetDamage() Damage

func (*Item) GetDefense

func (i *Item) GetDefense() int

Returns a random number up to the total possible reduction for this item.

func (*Item) GetDiceRoll

func (i *Item) GetDiceRoll() (attacks int, dCount int, dSides int, bonus int, buffOnCrit []int)

Gets the specifics of the item damage Considers overrides

func (*Item) GetLongDescription

func (i *Item) GetLongDescription() string

func (*Item) GetScript

func (i *Item) GetScript() string

func (*Item) GetSpec

func (i *Item) GetSpec() ItemSpec

func (*Item) GetTempData

func (i *Item) GetTempData(key string) any

func (*Item) HasAdjective

func (i *Item) HasAdjective(adj string) bool

func (*Item) IsBetterThan

func (i *Item) IsBetterThan(otherItm Item) bool

func (*Item) IsCursed

func (i *Item) IsCursed() bool

func (Item) IsDisabled

func (i Item) IsDisabled() bool

func (*Item) IsEnchanted

func (i *Item) IsEnchanted() bool

func (*Item) IsSpecial

func (i *Item) IsSpecial() bool

func (*Item) IsValid

func (i *Item) IsValid() bool

func (*Item) Name

func (i *Item) Name() string

func (*Item) NameComplex

func (i *Item) NameComplex() string

func (*Item) NameMatch

func (i *Item) NameMatch(input string, allowContains bool) (partialMatch bool, fullMatch bool)

func (*Item) NameSimple

func (i *Item) NameSimple() string

func (*Item) Redescribe

func (i *Item) Redescribe(newDescription string)

func (*Item) Rename

func (i *Item) Rename(newName string, displayNameOrStyle ...string)

func (*Item) SetAdjective

func (i *Item) SetAdjective(adj string, addToList bool)

func (*Item) SetBlob

func (i *Item) SetBlob(blob string)

func (*Item) SetTempData

func (i *Item) SetTempData(key string, value any)

func (*Item) ShorthandId

func (i *Item) ShorthandId() string

func (*Item) StatMod

func (i *Item) StatMod(statName ...string) int

func (*Item) UnEnchant

func (i *Item) UnEnchant()

func (*Item) Uncurse

func (i *Item) Uncurse()

func (*Item) Validate

func (i *Item) Validate()

type ItemMessage

type ItemMessage string

func (ItemMessage) SetTokenValue

func (am ItemMessage) SetTokenValue(tokenName TokenName, tokenValue string) ItemMessage

type ItemSpec

type ItemSpec struct {
	ItemId          int
	Value           int
	Uses            int         `yaml:"uses,omitempty"`            // How many uses it starts with
	BuffIds         []int       `yaml:"buffids,omitempty"`         // What buffs it can apply (if used)
	WornBuffIds     []int       `yaml:"wornbuffids,omitempty"`     // BuffId's that are applied while worn, and expired when removed.
	DamageReduction int         `yaml:"damagereduction,omitempty"` // % of damage it reduces when it blocks attacks
	WaitRounds      int         `yaml:"waitrounds,omitempty"`      // How many extra rounds each combat requires
	Hands           WeaponHands `yaml:"hands"`                     // How many hands it takes to wield
	Name            string
	DisplayName     string `yaml:"displayname,omitempty"` // Name that is typically displayed to the user
	NameSimple      string // A simpler name for the item, for example "Golden Battleaxe" should be "Battleaxe" or "Axe" for simple
	Description     string
	QuestToken      string `yaml:"questtoken,omitempty"` // Grants this quest if given/picked up
	Type            ItemType
	Subtype         ItemSubType
	Damage          Damage
	Element         Element           `yaml:"element,omitempty"`
	StatMods        statmods.StatMods `yaml:"statmods,omitempty"`    // What stats it modifies when equipped
	BreakChance     uint8             `yaml:"breakchance,omitempty"` // Chance in 100 that the item will break when used, or when the character is hit with it equipped, or if it is in the characters inventory during an explosion, etc.
	Cursed          bool              `yaml:"cursed,omitempty"`      // Can't be removed once equipped
	KeyLockId       string            `yaml:"keylockid,omitempty"`   // Example: `778-north` - If it's a key, what lock does it open? roomid-exitname etc.
}

The blueprint for an item

func GetAllItemSpecs

func GetAllItemSpecs() []ItemSpec

func GetItemSpec

func GetItemSpec(itemId int) *ItemSpec

func (*ItemSpec) AutoCalculateValue

func (i *ItemSpec) AutoCalculateValue()

func (*ItemSpec) Filename

func (i *ItemSpec) Filename() string

func (*ItemSpec) Filepath

func (i *ItemSpec) Filepath() string

func (ItemSpec) GetScript

func (i ItemSpec) GetScript() string

func (*ItemSpec) GetScriptPath

func (i *ItemSpec) GetScriptPath() string

func (*ItemSpec) Id

func (i *ItemSpec) Id() int

Presumably to ensure the datafile hasn't messed something up.

func (*ItemSpec) ItemFolder

func (i *ItemSpec) ItemFolder(baseonly ...bool) string

func (*ItemSpec) Validate

func (i *ItemSpec) Validate() error

Presumably to ensure the datafile hasn't messed something up.

type ItemSubType

type ItemSubType string

func (ItemSubType) String

func (i ItemSubType) String() string

type ItemType

type ItemType string

func (ItemType) String

func (i ItemType) String() string

type ItemTypeInfo

type ItemTypeInfo struct {
	Type        string
	Description string
	Count       int
	MinItemId   int
	MaxItemId   int
}

func ItemSubtypes

func ItemSubtypes() []ItemTypeInfo

Returns key=subtype and value=description

func ItemTypes

func ItemTypes() []ItemTypeInfo

Returns key=type and value=description

type MessageOptions

type MessageOptions []ItemMessage

func (MessageOptions) Get

func (mo MessageOptions) Get(seedNum ...int) ItemMessage

type SeparateMessages

type SeparateMessages struct {
	ToAttacker     MessageOptions `yaml:"toattacker"`
	ToDefender     MessageOptions `yaml:"todefender"`
	ToAttackerRoom MessageOptions `yaml:"toattackerroom"`
	ToDefenderRoom MessageOptions `yaml:"todefenderroom"`
}

type TogetherMessages

type TogetherMessages struct {
	ToAttacker MessageOptions `yaml:"toattacker"`
	ToDefender MessageOptions `yaml:"todefender"`
	ToRoom     MessageOptions `yaml:"toroom"`
}

type TokenName

type TokenName string

type WeaponAttackMessageGroup

type WeaponAttackMessageGroup struct {
	OptionId ItemSubType `yaml:"optionid"`
	Options  AttackTypes `yaml:"options"`
}

func (*WeaponAttackMessageGroup) Filepath

func (w *WeaponAttackMessageGroup) Filepath() string

func (*WeaponAttackMessageGroup) Id

Presumably to ensure the datafile hasn't messed something up.

func (*WeaponAttackMessageGroup) Validate

func (w *WeaponAttackMessageGroup) Validate() error

Presumably to ensure the datafile hasn't messed something up.

type WeaponHands

type WeaponHands = int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL