gear

package
v0.7.85 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 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 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
}

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"`
}

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

Jump to

Keyboard shortcuts

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