gear

package
v0.7.92 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const (
	SourceBelow = 5
	SourceAbove = 3
)

Source level window: a creature is "in range" when its levels reach into [level-SourceBelow, level+SourceAbove].

View Source
const (
	BasisStats     = "stats"
	BasisItemLevel = "item level"
)

Basis of a candidate's score.

View Source
const EquipWindow = 2

EquipWindow is how many levels above the character an item may require (known or estimated).

View Source
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).

View Source
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).

View Source
const MaxSources = 3

MaxSources is how many sources a candidate lists.

Variables

This section is empty.

Functions

func ArmorTypeWord added in v0.7.11

func ArmorTypeWord(classID, subclass int) string

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

func CanUse(class string, level int, row store.Row) (usable, known bool)

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

func CostText(copper int64) string

CostText is a price in copper in plain words: "10s", "1g", "1g 50s".

func EstimateRequiredLevel

func EstimateRequiredLevel(itemLevel int) int

EstimateRequiredLevel is the required level assumed for an item whose dataset value is unknown.

func Fits added in v0.7.40

func Fits(c character.Character, ds store.DataStore, itemID int64) bool

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

func FromEverloot(v any) bool

FromEverloot is true when an npcs.name_source value (nil on a client row) says Everloot named the creature.

func Render

func Render(c character.Character, r Result) string

Render is the plain-text answer. Slots are listed in the capture's slot order.

func SkillOfItem added in v0.7.87

func SkillOfItem(subclass int) int64

SkillOfItem is the skill line a weapon of the subclass needs; 0 for anything else.

func Upgrades

func Upgrades(c character.Character, ds store.DataStore, group string) (map[string][]Candidate, error)

Upgrades returns, per capture slot, the items the character can use that beat what they wear, best first. group is the character's top talent group name; empty when unknown.

func Weights

func Weights(class, group string) (spec string, w map[int64]float64, rationale string, ok bool)

Weights returns the advisor's default weights for a class token ("PRIEST") and a talent group name ("Test Discipline" matches "Discipline"); ok is false when none apply.

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
	// 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

func BagUpgrades(c character.Character, ds store.DataStore, group string) []BagUpgrade

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"`
	// 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.

func (Candidate) Describe

func (c Candidate) Describe() string

Describe is the one-line text of a candidate.

func (Candidate) LevelText

func (c Candidate) LevelText() string

LevelText is how soon the character can equip the candidate: "requires level N" when they can now, "at level N" when they must reach it first, and "(estimated)" when N is a guess from item level because the dataset holds no required level.

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.

func (Craft) Line added in v0.7.70

func (c Craft) Line() string

Line is the craft in words for a candidate's description.

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
	// 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.

func (Item) HasStat added in v0.7.12

func (it Item) HasStat(stat string) bool

HasStat reports whether the item carries the named stat (a name of the stats package).

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.

func (Master) Where added in v0.7.87

func (m Master) Where() string

Where is "Orgrimmar, Valley of Honor" (the city alone when no district is known).

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.

func Find

func Find(c character.Character, ds store.DataStore, group string, opt Options) (Result, error)

Find is Upgrades with options and the basis of the answer.

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.

func (SkillNeed) Line added in v0.7.87

func (n SkillNeed) Line() string

Line is "Needs the Staves skill: train it at Hanashi in Orgrimmar, Valley of Honor (10s)".

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.

func (Source) String

func (s Source) String() string

type Taught added in v0.7.87

type Taught struct {
	Master   Master
	Cost     int64
	MinLevel int
}

Taught is a master's offer of one skill.

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.

Jump to

Keyboard shortcuts

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