Documentation
¶
Index ¶
- Constants
- Variables
- func CanBackstab(iSubType ItemSubType) bool
- func CreateNewItemFile(newItemInfo ItemSpec) (int, error)
- func FindItem(nameOrId string) int
- func FindItemByName(name string) int
- func FindKeyByLockId(lockId string) int
- func FindMatchIn(itemName string, items ...Item) (pMatch Item, fMatch Item)
- func GetAllItemNames() []string
- func GetMemoryUsage() map[string]util.MemoryResult
- func LoadDataFiles()
- type AttackEffects
- type AttackMessageOptions
- type AttackMessages
- type AttackOptions
- type AttackTypes
- type Damage
- type Element
- type Intensity
- type Item
- func (i *Item) AddWornBuff(buffId int)
- func (i *Item) AttrString() string
- func (i *Item) BreakTest(increaseChance ...int) bool
- func (i *Item) DisplayName() string
- func (i *Item) Enchant(damageBonus int, defenseBonus int, statBonus map[string]int, cursed bool)
- func (i *Item) Equals(b Item) bool
- func (i *Item) GetBlob() string
- func (i *Item) GetDamage() Damage
- func (i *Item) GetDefense() int
- func (i *Item) GetDiceRoll() (attacks int, dCount int, dSides int, bonus int, buffOnCrit []int)
- func (i *Item) GetLongDescription() string
- func (i *Item) GetScript() string
- func (i *Item) GetSpec() ItemSpec
- func (i *Item) GetTempData(key string) any
- func (i *Item) HasAdjective(adj string) bool
- func (i *Item) IsBetterThan(otherItm Item) bool
- func (i *Item) IsCursed() bool
- func (i Item) IsDisabled() bool
- func (i *Item) IsEnchanted() bool
- func (i *Item) IsSpecial() bool
- func (i *Item) IsValid() bool
- func (i *Item) Name() string
- func (i *Item) NameComplex() string
- func (i *Item) NameMatch(input string, allowContains bool) (partialMatch bool, fullMatch bool)
- func (i *Item) NameSimple() string
- func (i *Item) Redescribe(newDescription string)
- func (i *Item) Rename(newName string, displayNameOrStyle ...string)
- func (i *Item) SetAdjective(adj string, addToList bool)
- func (i *Item) SetBlob(blob string)
- func (i *Item) SetTempData(key string, value any)
- func (i *Item) ShorthandId() string
- func (i *Item) StatMod(statName ...string) int
- func (i *Item) UnEnchant()
- func (i *Item) Uncurse()
- func (i *Item) Validate()
- type ItemMessage
- type ItemSpec
- func (i *ItemSpec) AutoCalculateValue()
- func (i *ItemSpec) Filename() string
- func (i *ItemSpec) Filepath() string
- func (i ItemSpec) GetScript() string
- func (i *ItemSpec) GetScriptPath() string
- func (i *ItemSpec) Id() int
- func (i *ItemSpec) ItemFolder(baseonly ...bool) string
- func (i *ItemSpec) Validate() error
- type ItemSubType
- type ItemType
- type ItemTypeInfo
- type MessageOptions
- type SeparateMessages
- type TogetherMessages
- type TokenName
- type WeaponAttackMessageGroup
- type WeaponHands
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 FindItemByName ¶
func FindKeyByLockId ¶
func FindMatchIn ¶
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
Types ¶
type AttackEffects ¶
type AttackEffects map[Intensity]AttackMessageOptions
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 (*Damage) InitDiceRoll ¶
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 (*Item) AddWornBuff ¶
func (*Item) AttrString ¶
func (*Item) BreakTest ¶
performs a break test and returns true if the item breaks Pass a uint8 to increase the chance of breaking.
func (*Item) DisplayName ¶
func (*Item) GetDefense ¶
Returns a random number up to the total possible reduction for this item.
func (*Item) GetDiceRoll ¶
Gets the specifics of the item damage Considers overrides
func (*Item) GetLongDescription ¶
func (*Item) GetTempData ¶
func (*Item) HasAdjective ¶
func (*Item) IsBetterThan ¶
func (Item) IsDisabled ¶
func (*Item) IsEnchanted ¶
func (*Item) NameComplex ¶
func (*Item) NameSimple ¶
func (*Item) Redescribe ¶
func (*Item) SetAdjective ¶
func (*Item) SetTempData ¶
func (*Item) ShorthandId ¶
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 (*ItemSpec) AutoCalculateValue ¶
func (i *ItemSpec) AutoCalculateValue()
func (*ItemSpec) GetScriptPath ¶
func (*ItemSpec) ItemFolder ¶
type ItemSubType ¶
type ItemSubType string
func (ItemSubType) String ¶
func (i ItemSubType) String() string
type ItemTypeInfo ¶
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 WeaponAttackMessageGroup ¶
type WeaponAttackMessageGroup struct { OptionId ItemSubType `yaml:"optionid"` Options AttackTypes `yaml:"options"` }
func (*WeaponAttackMessageGroup) Filepath ¶
func (w *WeaponAttackMessageGroup) Filepath() string
func (*WeaponAttackMessageGroup) Id ¶
func (w *WeaponAttackMessageGroup) Id() ItemSubType
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
Click to show internal directories.
Click to hide internal directories.