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 CostText(copper int64) string
- 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 SkillOfItem(subclass int) int64
- 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 Master
- type Options
- type Result
- type SkillNeed
- type Source
- type Taught
- type WeaponSkillFacts
- func (f WeaponSkillFacts) ItemSkill(c character.Character, classID, subclass int) (usable bool, need *SkillNeed)
- func (f WeaponSkillFacts) Known(c character.Character, skill int64) (known, captured bool)
- func (f WeaponSkillFacts) Lacking(c character.Character) []int64
- func (f WeaponSkillFacts) MastersFor(skill int64) []Taught
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 CostText ¶ added in v0.7.87
CostText is a price in copper in plain words: "10s", "1g", "1g 50s".
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.
func SkillOfItem ¶ added in v0.7.87
SkillOfItem is the skill line a weapon of the subclass needs; 0 for anything else.
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 item level (quality breaks a tie), not by
// weighed stats: the advice says "likely better (item level N vs M)" and gives no number.
Likely bool
Empty bool // the slot is empty
Delta float64
// ReplacesILvl is the worn item's item level; 0 for an empty slot.
ReplacesILvl int
// Notes are debug lines, such as an enchant left out of the weighing.
Notes []string `json:"-"`
// Replaces is the worn item's name; empty for an empty slot.
Replaces string
// Need is the weapon skill the item needs and the character can learn but has not; nil otherwise.
Need *SkillNeed
}
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) LikelyWording ¶ added in v0.7.94
func (u BagUpgrade) LikelyWording() string
LikelyWording is "likely better (item level 40 vs 36)": the claim without a stat basis, with the numbers it rests on.
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"`
// Need is the weapon skill the item needs and the character can learn but has not; nil otherwise.
Need *SkillNeed `json:"need,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
Class int // the items table's class_id and subclass_id (2 is a weapon)
Subclass int
Bonding int
StatTypes []int64
// Armor is the item's armor, the dataset's `armor` column (item level, armor type, quality and slot decide
// it); 0 when there is none.
Armor int
// 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
// Captured is the item's own stats by name (agility, stamina, armor, ...) as the addon recorded
// them, enchants not included; nil when none were captured.
Captured map[string]float64 `json:"-"`
// Enchant is the enchant id on the item, 0 for none or unknown.
Enchant int `json:"-"`
}
Item is the part of an items row the advisor uses.
type Master ¶ added in v0.7.87
type Master struct {
ID int64
Name string
Faction string
City string
Place string
X, Y float64
Skills []int64
Cost []int64 // copper, aligned with Skills
MinLevel []int64 // aligned with Skills
}
Master is a Weapon Master and what they teach, for the player's faction.
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 SkillNeed ¶ added in v0.7.87
type SkillNeed struct {
Skill string
SkillID int64
Master string // the nearest master; "" when the dataset names none
Where string // "Orgrimmar, Valley of Honor"
City string
Cost int64
MinLevel int
}
SkillNeed says an item needs a weapon skill the character can learn but has not.
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.
type WeaponSkillFacts ¶ added in v0.7.87
type WeaponSkillFacts struct {
// Have is false when the dataset lacks the weapon-skill tables: nothing else is set.
Have bool
Names map[int64]string // skill line id -> dataset name, for every skill the tables list
Learnable map[int64]bool // the class's learnable skills
MinLevel map[int64]int
Masters []Master // masters of the character's faction
// Pos is the zone the character was last known to be in, "" when unknown.
Pos string
}
WeaponSkillFacts is what the dataset says about the class's weapon skills.
func LoadWeaponSkills ¶ added in v0.7.87
func LoadWeaponSkills(c character.Character, ds store.DataStore) WeaponSkillFacts
LoadWeaponSkills reads the class's weapon skills and the faction's masters; Have is false when the dataset has no weapon_skills table, or the class is unknown.
func (WeaponSkillFacts) ItemSkill ¶ added in v0.7.87
func (f WeaponSkillFacts) ItemSkill(c character.Character, classID, subclass int) (usable bool, need *SkillNeed)
ItemSkill checks a weapon of the dataset's item row (class and subclass) against the character's weapon skills. usable is false when the dataset says the class can never learn the skill (the item is never suggested); need is set when the class can learn it and the character has not. Without the weapon-skill tables, or for anything but a weapon, it says usable with no need.
func (WeaponSkillFacts) Known ¶ added in v0.7.87
func (f WeaponSkillFacts) Known(c character.Character, skill int64) (known, captured bool)
Known reports whether the character's capture lists the skill (by id, else by name). captured is false when the capture holds no skills at all: then nothing is known either way.
func (WeaponSkillFacts) Lacking ¶ added in v0.7.87
func (f WeaponSkillFacts) Lacking(c character.Character) []int64
Lacking is the class's learnable skills the character has not learned, by skill id; nil when the capture holds no skills.
func (WeaponSkillFacts) MastersFor ¶ added in v0.7.87
func (f WeaponSkillFacts) MastersFor(skill int64) []Taught
MastersFor lists the faction's masters of the skill, the nearest first: the one in the zone the character stands in, then by city and name so the order is stable.