Documentation
¶
Overview ¶
Package gear finds equipment upgrades for a captured character from the dataset's items and loot_sources tables. The rules are in docs/gear.md.
The dataset records which stat types an item has, not their sizes. With stat types known, an item is scored from its item level scaled by how much the spec's weights value those types; otherwise from item level and quality alone, and the answer says so.
Index ¶
- Constants
- func ArmorTypeWord(classID, subclass int) string
- func CanUse(class string, level int, row store.Row) (usable, known bool)
- func EstimateRequiredLevel(itemLevel int) int
- func Fits(c character.Character, ds store.DataStore, itemID int64) bool
- func FromEverloot(v any) bool
- func Render(c character.Character, r Result) string
- func Upgrades(c character.Character, ds store.DataStore, group string) (map[string][]Candidate, error)
- func Weights(class, group string) (spec string, w map[int64]float64, rationale string, ok bool)
- type BagUpgrade
- type Candidate
- type Craft
- type Item
- type Options
- type Result
- type Source
Constants ¶
const ( CraftNow = "can_make" // the character knows the recipe, or a trainer teaches it at their skill CraftNeedSkill = "needs_skill" // a trainer teaches it, but only at a higher skill CraftNeedItem = "needs_recipe" // taught by a recipe item the character does not have CraftNoProf = "not_profession" // the character has no such profession )
Craft statuses of a candidate that a profession makes.
const ( SourceBelow = 5 SourceAbove = 3 )
Source level window: a creature is "in range" when its levels reach into [level-SourceBelow, level+SourceAbove].
const ( BasisStats = "stats" BasisItemLevel = "item level" )
Basis of a candidate's score.
const EquipWindow = 2
EquipWindow is how many levels above the character an item may require (known or estimated).
const EstimateGap = 20
EstimateGap is how far the estimate may exceed a known required level before the known one is distrusted: the dataset holds required level 1 for about 80 equippable items of item level 30 to 70 (scaling and event items), which are no use to a level-5 character. Real level-60 gear stays within it (item level 83 needs 60).
const EstimateOffset = 5
EstimateOffset is how far below its item level an item's required level is estimated to sit when the dataset holds 0 (unknown) for it: required level ~ max(1, item level - EstimateOffset).
const MaxSources = 3
MaxSources is how many sources a candidate lists.
Variables ¶
This section is empty.
Functions ¶
func ArmorTypeWord ¶ added in v0.7.11
ArmorTypeWord is an armor subclass as a player says it ("mail"); "" for anything else, a weapon or a shield included.
func CanUse ¶ added in v0.7.44
CanUse reports whether a character of the class token at level can wear or wield the dataset item row, by armor type, weapon type, shield and class restriction. known is false for an unsupported class, an item that is not worn gear, or a row the dataset gives no type for.
func EstimateRequiredLevel ¶
EstimateRequiredLevel is the required level assumed for an item whose dataset value is unknown.
func Fits ¶ added in v0.7.40
Fits reports whether the item suits the character's build at all: a shield never does for a two-hand or dual-wield damage build. An item that does not fit is left out of the advice entirely.
func FromEverloot ¶
FromEverloot is true when an npcs.name_source value (nil on a client row) says Everloot named the creature.
Types ¶
type BagUpgrade ¶ added in v0.7.73
type BagUpgrade struct {
Slot string
Item Item
// Name is the item's name with its random suffix ("of the Tiger") when the capture has one.
Name string
// Likely is true when the item is better only by quality, item level and required level, not
// by weighed stats: the advice says "likely better" and gives no number.
Likely bool
Empty bool // the slot is empty
Delta float64
// Replaces is the worn item's name; empty for an empty slot.
Replaces string
}
BagUpgrade is an item already in the character's bags that beats what they wear in a slot: free, and usable now.
func BagUpgrades ¶ added in v0.7.73
BagUpgrades lists the items in the character's bags that beat what they wear, best first by slot order. group is the top talent group name; empty when unknown. Items the dataset does not know count only when the addon recorded their quality, level, required level and slot. A character whose bags were not captured, or a class without rules, has none.
func (BagUpgrade) Line ¶ added in v0.7.73
func (u BagUpgrade) Line() string
Line is the upgrade in a sentence: "Feet: Copper Chain Boots, in your bags; equip it now (replaces Hiking Boots; likely better)".
type Candidate ¶
type Candidate struct {
Item Item
Slot string
Score float64
Delta float64 // score minus the equipped item's; the full score for an empty slot
Basis string // BasisStats or BasisItemLevel
Empty bool // the slot is empty
Soon bool // the item's ReqLevel is above the character's level (within EquipWindow)
Sources []Source
// Vendor is the cheapest vendor that sells the item, from Everloot's vendor offers; nil when none.
Vendor *vendors.Offer `json:"vendor,omitempty"`
// Craft is whether the character's skill can make the item; nil when no recipe makes it.
Craft *Craft `json:"craft,omitempty"`
}
Candidate is an item that beats what the character wears in a slot.
type Craft ¶ added in v0.7.70
type Craft struct {
Profession string `json:"profession"`
Need int `json:"need_skill"`
Status string `json:"status" jsonschema:"can_make, needs_skill, needs_recipe or not_profession"`
}
Craft says whether the character's own skill can make a candidate. Absent when no profession makes it.
type Item ¶
type Item struct {
ID int64
Name string
ItemLevel int
RequiredLevel int // the dataset's; 0 is unknown
ReqLevel int // what the search used: RequiredLevel, or an estimate when that is 0
Estimated bool
Quality int
Slot int
Bonding int
StatTypes []int64
// Stats is the amount of each stat (type id to amount) from the dataset's stat values; nil when the
// dataset has types only.
Stats map[int64]int `json:"-"`
StatsKnown bool
}
Item is the part of an items row the advisor uses.
type Options ¶
type Options struct {
Slot string // one capture slot name; empty for all
Limit int // most candidates per slot, best first; 0 for all
// NoSources skips the per-candidate source lookup, for a caller that finds its own.
NoSources bool
}
Options narrows a search. The zero value searches every slot and keeps every candidate.
type Result ¶
type Result struct {
Slots map[string][]Candidate
// ItemLevelOnly is true when no candidate was scored from stats.
ItemLevelOnly bool
Spec string // spec the weights are for; empty when none apply
Rationale string
Reason string // why scoring fell back to item level, when it did
// Bags are the items already in the bags that beat what is worn: free, so they come first.
Bags []BagUpgrade `json:"bags,omitempty"`
}
Result is what a search found.
type Source ¶
type Source struct {
Kind string // creature, object, quest reward
ID int64
Name string // empty when the dataset has no name for it
// Everloot is true when the name comes from Everloot's drop rows (npcs.name_source).
Everloot bool
MinLevel *int
MaxLevel *int
Chance *float64 // percent, from drops / kills
InRange bool // a creature whose levels reach the character's level range
}
Source is one place an item drops or is rewarded. Level and chance fields are nil when unknown.