Documentation
¶
Overview ¶
Package character reads characters captured by ForeverScribe (https://github.com/MattMaximo/foreverscribe, MIT) into a typed model.
Fields ForeverScribe did not capture are nil (or an empty string for text), never invented.
Index ¶
- Constants
- func ParseAddon(text, key, name string) (*Totals, *Observed)
- func SeenAgo(t int64, now time.Time) string
- func SeenNote(t int64, now time.Time) string
- func Siblings(path string) (fsPath, wowcPath string)
- func Stale(t int64, now time.Time) bool
- type Character
- type Client
- type EquippedItem
- type File
- type Giver
- type ItemStack
- type Location
- type NPC
- type Objective
- type Observed
- func (o *Observed) Empty() bool
- func (o *Observed) FlightsFor(faction string) []SeenFlight
- func (o *Observed) GiverOf(questID int) (SeenGiver, bool)
- func (o *Observed) TrainersFor(faction string) []SeenTrainer
- func (o *Observed) VendorsOf(item int64, faction string) (vs []SeenVendor, stock []SeenStock)
- type Position
- type Profile
- type Quest
- type Reputation
- type SeenFlight
- type SeenGather
- type SeenGiver
- type SeenOffer
- type SeenRecipe
- type SeenRecipes
- type SeenStock
- type SeenTrainer
- type SeenVendor
- type Skill
- type Spot
- type Talent
- type TalentGroup
- type TalentTree
- type Talents
- type Totals
Constants ¶
const ( SourceWoWC = "WoW Companion addon" SourceFS = "ForeverScribe" )
Source names for Character.Source.
const ( FSFile = "ForeverScribe.lua" WoWCFile = "WoWCompanion.lua" )
File names beside each other in one SavedVariables folder.
const DBVariable = "ForeverScribeDB"
DBVariable is the one global the addon writes.
const NearFraction = 0.75
NearFraction is the share of objectives done at which an open quest counts as nearly complete.
const RecentGiver = 7 * 24 * time.Hour
RecentGiver is how recently a giver must have been met to be flagged as a recent interaction.
const SeenByYou = "seen by you"
SeenByYou is the mark on a fact that came from what the player saw in game (WoWCompanionDB.observed, docs/observed-format.md of the addon).
const StaleAfter = 30 * 24 * time.Hour
StaleAfter is how old an observation may be and still count as current price data.
const WoWCVariable = "WoWCompanionDB"
WoWCVariable is the global the WoW Companion addon writes; its characters sit in `characters` (docs/capture-format.md of the addon).
Variables ¶
This section is empty.
Functions ¶
func ParseAddon ¶ added in v0.7.47
ParseAddon reads the addon's SavedVariables text: the stat totals of one character and what the player saw.
func SeenAgo ¶ added in v0.7.53
SeenAgo says when something was seen, in plain words ("seen 3 days ago"); "" when t is unknown.
func SeenNote ¶ added in v0.7.53
SeenNote is the freshness phrase for an observation: "seen 3 days ago", with "; prices may have changed" added once it is older than StaleAfter.
Types ¶
type Character ¶
type Character struct {
Key string // "Realm:Name"; the name alone when the realm is empty
Name string
Realm string
Level *int
Class string
Race string
Faction string
Money *int
XP *int
XPMax *int
RestedXP *int // experience points (GetXPExhaustion), not a percentage
CapturedAt *int64
Addon string
Client Client
Location *Location // nil when the capture holds none
Hearth string // the hearthstone's bind location name
// Source says which capture the character came from: SourceWoWC, SourceFS or both joined.
Source string
Equipment map[string]EquippedItem // nil when not captured
Bags []ItemStack
BagsCaptured bool
Bank []ItemStack
BankCaptured bool // false until the player has opened the bank with ForeverScribe running
NPCs []NPC // nil when the capture holds no npcs table
Quests []Quest
QuestsCaptured bool
CompletedQuests []int
Talents *Talents
Skills []Skill
SkillsCaptured bool
Professions []Skill // each profession once
Reputations []Reputation
// Profile is the player's own, kept locally (internal/profile) and attached after the
// capture is read; nil when the player has set none. They are never part of a capture.
Profile *Profile
// KnownSpells are the spell ids the character knows (a recipe's spell id included), when a capture
// lists them; nil when it does not.
KnownSpells map[int64]bool
// Recipes are the recipes the client's own trade skill window listed, by profession (lower-case);
// nil when none were recorded. A recipe listed here is known.
Recipes map[string]SeenRecipes
// Totals are the stat totals the addon records (WoWCompanionDB.stats), attached with AttachTotals;
// nil when none.
Totals *Totals
// Seen is what the player saw in game (WoWCompanionDB.observed): trainers, vendors, gathering and
// quest givers; nil when nothing was recorded. These "seen by you" facts come before the dataset.
Seen *Observed
}
func AttachAddon ¶ added in v0.7.47
AttachAddon returns c with what the addon recorded in its SavedVariables file: the stat totals and the observations ("seen by you"). Nothing is attached when the file is missing or unreadable.
func AttachTotals ¶ added in v0.7.12
AttachTotals returns c with what the addon recorded in its SavedVariables file: its stat totals and what the player saw (Seen). c is unchanged when the file is unreadable or holds none.
func LoadWoWCharacter ¶ added in v0.7.47
LoadWoWCharacter builds one character from a WoWCompanionDB.characters record.
func MergeCharacters ¶ added in v0.7.47
MergeCharacters returns the newer capture, with each part it lacks filled from the other.
func (Character) LastKnownPosition ¶ added in v0.5.0
LastKnownPosition is nil when neither a located save nor any NPC sighting exists.
func (Character) NearbyGivers ¶ added in v0.5.0
NearbyGivers lists kind "quest" NPCs in the position's zone (same map when both ids are known), nearest first. A giver sighted at several spots is listed once.
type EquippedItem ¶
type File ¶
type File struct {
Addon string
Schema *int
Client Client
Characters []Character
// HasWoWC and HasFS say which capture files were read (WoWCompanionDB.characters, ForeverScribeDB).
HasWoWC, HasFS bool
}
File is everything one SavedVariables file holds.
func LoadFile ¶
LoadFile reads the character captures beside path: the WoW Companion addon's (WoWCompanionDB.characters in WoWCompanion.lua) and ForeverScribe's. A character in both is merged: the newer capture leads and the other fills the parts it lacks. A file that is missing or unreadable is skipped when the other gives characters; otherwise the error is the one for path. A malformed file is a *lua.ParseError.
func LoadWoWC ¶ added in v0.7.47
LoadWoWC builds models from parsed variables holding WoWCompanionDB.characters. The result has no characters (and HasWoWC false upstream) when the table is absent.
func (File) CapturedAt ¶
CapturedAt is the newest capture time over all characters.
type Giver ¶ added in v0.5.0
type Giver struct {
NPC
Distance float64 // straight line in map percent
Recent bool // met within RecentGiver
}
Giver is a quest-giver NPC the character has met, with its distance from the position.
type Location ¶ added in v0.4.0
Location is where the character stood at the last save (ForeverScribe snapshot.location). X and Y are percent of the map (0 to 100) and nil when the client gave no position.
type NPC ¶ added in v0.5.0
type NPC struct {
ID int
Name string
MapID *int
Zone string
Subzone string
X, Y *float64
Kind string
First *int64
Seen *int64 // t: last interaction, epoch seconds
Count *int // n: interactions
Spots []Spot
}
NPC is one NPC sighting (ForeverScribe npcs["<npcID>:<uiMapID>"]). Kind is "quest" or "gossip".
type Observed ¶ added in v0.7.47
type Observed struct {
Trainers []SeenTrainer
Vendors []SeenVendor
Gather []SeenGather
Givers []SeenGiver
// Flights are the flight masters the player opened.
Flights []SeenFlight
}
Observed is what the player saw, read from the addon's SavedVariables. Every list may be empty.
func ParseObserved ¶ added in v0.7.47
ParseObserved reads WoWCompanionDB.observed out of parsed variables: trainers, vendors, gathering and the quest givers of accepted events (the newest sighting of each quest wins). It is tolerant: a missing section or field is empty.
func (*Observed) FlightsFor ¶ added in v0.7.53
func (o *Observed) FlightsFor(faction string) []SeenFlight
FlightsFor lists the seen flight masters open to the faction, newest first.
func (*Observed) TrainersFor ¶ added in v0.7.47
func (o *Observed) TrainersFor(faction string) []SeenTrainer
TrainersFor lists the seen trainers open to the character's faction, newest first.
type Position ¶ added in v0.5.0
Position is the character's last known place: the saved location when it has coordinates, else (Approximate) where the most recent NPC interaction happened.
type Profile ¶ added in v0.7.0
type Profile struct {
Role string `json:"role"`
Focus string `json:"focus"`
Spec string `json:"spec,omitempty"`
// StatPref is the optional stat preference: balanced, damage or survival ("" is balanced).
StatPref string `json:"stat_pref,omitempty"`
}
Profile is a character's play style: role (tank, healer, damage or balanced), focus (leveling, dungeons, pvp or mixed), the spec tree the player chose.
type Quest ¶
type Quest struct {
QuestID int
Title string
Level *int
Zone string
Complete *bool
Failed *bool
Objectives []Objective
// Observed marks a quest the addon saw accepted after the capture: it is in the log, but its
// objectives are not in the capture.
Observed bool
}
func (Quest) Fraction ¶ added in v0.5.0
Fraction is the share of the quest's objectives that are done, and whether it is known. A complete quest is 1; a quest with no readable objectives is unknown.
func (Quest) NearlyDone ¶ added in v0.5.0
NearlyDone reports a quest that is complete or has at least NearFraction of its objectives done.
func (Quest) ObjectiveProgress ¶ added in v0.5.0
ObjectiveProgress is ProgressText without the quest name: "3/8 Crab Claws; 1/1 Boss".
func (Quest) ProgressText ¶ added in v0.5.0
ProgressText is the quest's objective progress, such as "Crab Season: 3/8 Crab Claws; 1/1 Boss". It is empty when the quest has no objective with a count.
type Reputation ¶
type SeenFlight ¶ added in v0.7.53
SeenFlight is one flight master the player opened: a known flight point.
type SeenGather ¶ added in v0.7.47
type SeenGather struct {
Kind string // herb, mine, skin or fish
Source string
Map int
CX, CY int // the cell: floor(percent / 5)
N int
T int64
SkillMin, SkillMax int
Items map[int64]int // item id -> total looted
}
SeenGather is one aggregated gathering or fishing row: where, what and how much.
type SeenGiver ¶ added in v0.7.47
SeenGiver is where the player saw a quest's giver, from an accepted event.
type SeenOffer ¶ added in v0.7.47
type SeenOffer struct {
Name string
Rank string
State string // available, unavailable or used (already known)
Cost int64 // copper
Level int // the character level it needs, 0 when none shown
Skill string // the skill gate's profession, "" when none
SkillLevel int
Spell int64
}
SeenOffer is one thing a trainer teaches, as the trainer window showed it.
type SeenRecipe ¶ added in v0.7.53
type SeenRecipe struct {
Name string
ID int64 // the spell or item id in the recipe's link, 0 when none
Difficulty string // orange, yellow, green or grey at the skill the window was opened at
Makes int64 // item id, 0 when none
MakesCount int
Reagents []ItemStack
}
SeenRecipe is one recipe the player's own trade skill window listed.
type SeenRecipes ¶ added in v0.7.53
type SeenRecipes struct {
SeenAt int64
Entries []SeenRecipe
}
SeenRecipes is one profession's recipes and when the window was read.
type SeenTrainer ¶ added in v0.7.47
type SeenTrainer struct {
NPC int64
Name string
Map int
X, Y float64
Faction string
T int64
Offers []SeenOffer
}
SeenTrainer is one trainer the player opened.
type SeenVendor ¶ added in v0.7.47
type SeenVendor struct {
NPC int64
Name string
Map int
X, Y float64
Faction string
T int64
Items []SeenStock
}
SeenVendor is one vendor the player opened.
type TalentGroup ¶
TalentGroup is one named branch of a tree (for example "Discipline") and its spent points.
type TalentTree ¶
type TalentTree struct {
Name string
Key string // "professions" for a profession tree; "" for a class tree
Points *int // points spent in the tree
Unspent *int // currency.unspent
MaxPoints *int // currency.max
MaxAvail *int // currency.maxAvailable
Groups []TalentGroup
Talents []Talent
}
func (TalentTree) IsProfession ¶ added in v0.7.0
func (t TalentTree) IsProfession() bool
IsProfession reports whether the tree is a profession talent tree, not a class tree.
type Talents ¶
type Talents struct {
System string
Loadout string
Unspent *int // class talent points (class tree currencies, else the top-level field)
Trees []TalentTree
}
func (*Talents) ProfessionUnspent ¶ added in v0.7.0
ProfessionUnspent is the unspent points over the profession trees; 0 when there are none.
type Totals ¶ added in v0.7.12
type Totals struct {
At *int64
Level *int
Str, Agi, Sta, Int, Spi *float64
Armor, AP, Crit, Dodge, Parry, Block *float64
}
Totals are a character's stat totals as the WoW Companion addon records them read-only in WoWCompanionDB.stats[<character key>] (every field optional; nil when the addon wrote none).
func ParseTotals ¶ added in v0.7.12
ParseTotals reads WoWCompanionDB.stats[key] out of the addon's SavedVariables text, tolerantly: a missing table, entry or field gives nil or a nil field. The key is matched as captured, then case-insensitively, then by character name alone.