Documentation
¶
Overview ¶
Package digest builds the in-game digest the WoWCompanion_Digest slot addon shows (schema 2.0, one 1.2 entry per character, see docs/digest.md). It adds no advice logic of its own: quests come from advice.WhatsNext, gear from gear.Find, and the rest is read from the capture.
Index ¶
- Constants
- func CheckInstalled(digestPath string) error
- func ClockOf(c character.Character, fallback time.Time) time.Time
- func DigestPath(savedVariables string) (string, error)
- func GainWord(cd gear.Candidate) string
- func PlanNPCs(steps []advice.Step) map[string]bool
- func PlanQuests(steps []advice.Step) map[int]bool
- func Quote(s string) string
- func Same(path string, d Envelope) bool
- func SameAsk(a, b string) bool
- func SameText(path, text string) bool
- func SameTextSince(path, text string, capturedAt int64) bool
- func Select(chars []character.Character) (kept, skipped []character.Character)
- func SiblingPath(path, file string) string
- func SlotCheck(src string) error
- func SlotPath(savedVariables, addon, file string) (path string, ok bool)
- func UpgradeQuests(c character.Character, ds store.DataStore, qx *questie.Index) map[int]string
- func Write(path string, d Envelope) error
- func WriteFile(path, text string) error
- type AskRef
- type Digest
- type DungeonLine
- type Envelope
- type Giver
- type Line
- type Objective
- type Options
- type Section
- type StatsEntry
- type Subject
- type TalentLine
- type TrainSpell
Constants ¶
const ( MaxAsks = 3 MaxAskLength = 90 )
Schema 1.5: every entry carries 1-3 short questions in the player's voice (Asks) and a stable subject reference (Ref) the advisor expands itself. Neither is built from clipped text.
const ( Schema = "1.10" EnvelopeSchema = "2.0" )
Schema is the version of one character's entry; EnvelopeSchema is the file's.
const ( NextQuests = "next_quests" Upgrades = "upgrades" KeepMaterials = "keep_materials" Notes = "notes" )
Section ids the panel knows.
const ( MaxQuests = 8 MaxUpgrades = 8 MaxMaterials = 10 MaxNotes = 6 MaxDungeons = 3 MaxTalents = 3 MaxText = 110 )
Caps: the most lines a section holds, and the longest line, in characters. The panel is narrow.
const ( KindPickup = "pickup" KindTurnIn = "turnin" KindProgress = "progress" KindTalent = "talent" KindNote = "note" KindGiver = "giver" )
Line kinds, for a Line's Kind.
const ( MaxPrompt = 500 // the in-game ask cap, in characters MaxDetails = 4 MaxTrainSpells = 8 )
Caps for the per-entry context (schema 1.4).
const ( StateAvailable = "available" StateBlocked = "blocked" StateLater = "later" )
Offer states of a training spell (schema 1.10).
const ( BigGain = 10.0 SolidGain = 5.0 )
Gain thresholds, in score points (item level plus quality, or the stat-weighted equivalent): a candidate that gains BigGain or more, or fills an empty slot, is a "Big upgrade"; SolidGain or more is "Solid"; anything else is "Small".
const KindTraining = "training"
KindTraining is the Kind of a class-training entry in next_quests (schema 1.4).
const MaxCharacters = 30
MaxCharacters is the most characters one file holds.
const MaxHow = 90
MaxHow is the longest "how" line: one line, never a paragraph.
const MaxTrainAhead = 8
MaxTrainAhead caps the blocked and later offers of a training entry.
const MaxWhy = 70
MaxWhy is the longest "why" line, in characters (schema 1.6).
const NoDataText = "Game data not downloaded yet; see Setup"
NoDataText is what NEXT says when no game dataset has downloaded.
const PathBags = "bags"
PathBags is the path kind of an upgrade that is already in the bags.
const SlotAddon = "WoWCompanion_Digest"
SlotAddon is the data-only addon the digest is written into.
Variables ¶
This section is empty.
Functions ¶
func CheckInstalled ¶
CheckInstalled is an error when the slot addon's folder is not there. Nothing is created.
func DigestPath ¶
DigestPath derives the digest file from a SavedVariables path: <game>/WTF/Account/<acct>/SavedVariables/<file> gives <game>/Interface/AddOns/WoWCompanion_Digest/Digest.lua. Both Windows and Unix paths are accepted, and the result keeps the input's separator.
func PlanNPCs ¶ added in v0.7.7
PlanNPCs is the givers the plan's pick-up steps name (a turn-in NPC is not a giver).
func PlanQuests ¶ added in v0.7.7
PlanQuests is the quest ids of the plan's steps.
func Quote ¶
Quote renders s as a Lua string literal: backslash, quote and control bytes are escaped, so the result holds no raw newline and nothing that could end the literal early.
func Same ¶ added in v0.3.0
Same reports whether the file at path already holds the envelope, ignoring the generated times (they change on every build, so a rebuild of the same advice would never match byte for byte).
func SameAsk ¶ added in v0.7.7
SameAsk reports whether two questions are the same ignoring case and punctuation.
func SameText ¶ added in v0.6.0
SameText is Same for any data-only Lua text carrying a `generated = N,` line.
func SameTextSince ¶ added in v0.7.1
SameTextSince is SameText that also requires the file's generated time to be no older than capturedAt (the newest capture the advice was built from, unix seconds; 0 for none). A file left from before a newer capture is stale even when its advice is identical, so it must be rewritten.
func Select ¶
Select picks the characters a file holds: the most recently captured first, at most MaxCharacters, one per name (the first wins). The rest come back as skipped.
func SiblingPath ¶ added in v0.6.0
SiblingPath is the file named file in the folder of the digest file at path, keeping its separator.
func SlotCheck ¶
SlotCheck is the addon repo's tests/slotcheck.lua (WoW-Companion/addon) ported to Go, rule for rule: after comments are dropped and every string replaced by 0, the file must be one `WoWCompanionDigest = {...}` assignment with no parentheses (calls), no bare identifiers as values, no call or index on a name, and no `..`, `:` or `#` operators.
func SlotPath ¶
SlotPath derives <game>/Interface/AddOns/<addon>/<file> from a SavedVariables path; ok is false when the path is not <game>/WTF/Account/<account>/SavedVariables/<file>.
func UpgradeQuests ¶ added in v0.7.46
UpgradeQuests are the quests whose reward is a gear upgrade for the character, by quest id, each with the plain reason; empty when the dataset is missing or there is none.
Types ¶
type AskRef ¶ added in v0.7.7
type AskRef struct {
Ask, Ref string
}
AskRef is one suggested question and the subject it is about.
type Digest ¶
type Digest struct {
Schema string
Generated int64
Build string
Character string
Sections []Section
Dungeons []DungeonLine // optional, at most MaxDungeons
Talents []TalentLine // optional, at most MaxTalents
Stats *StatsEntry // optional: present only for a character with a play style
}
Digest is the whole file.
func Build ¶
Build computes the digest for c. ds may be nil (no dataset); sections with nothing to say are left out.
func (Digest) Lua ¶
Lua renders the digest as a one-character entry body: the `{ ... }` table, without its key.
type DungeonLine ¶
type DungeonLine struct {
Name string
Line string
Item int
Details []string
Asks []string
Ref string
Why string
}
DungeonLine is one dungeons entry: the dungeon, its level fit and top upgrade; Item is zero when absent.
type Envelope ¶
type Envelope struct {
Generated int64
Characters []Digest // in file order; each Character is its key
}
Envelope is the whole file, schema 2.0: one entry per captured character, keyed by the name as captured.
type Giver ¶ added in v0.7.7
Giver is a quest giver worth a note: an NPC with a quest the character can pick up now that is not already a plan step.
func FindGiver ¶ added in v0.7.7
func FindGiver(c character.Character, qx *questie.Index, planned map[int]bool, planNPCs map[string]bool) (Giver, bool)
FindGiver is the one giver the character has a quest to pick up from, or false. It uses the player's own Questie data, which names each quest's giver; nothing is shown without it. A quest that is already a plan step, or whose giver already has a quest in the plan, gives no note, and an NPC who is only the turn-in of an open quest is never a giver. planned is the plan's quest ids; planNPCs the NPC names the plan sends the player to.
type Line ¶
type Line struct {
Text string
Item int
Quest int
Kind string // one of the Kind constants
Title string // the full quest title
Level int // the quest's level
Class bool // a class quest
Elite bool // an elite or group quest
NPC string // the giver of a pick-up, or the turn-in NPC
Zone string
Objectives []Objective
Points int // unspent talent points, for the talent line
Slot string // upgrades: the slot
ILvl int // upgrades: the item's level (not shown to players)
AtLevel int // upgrades: the character level the item needs, when not yet wearable
// Schema 1.4. Details is 1-4 short context lines, set on every entry. The legacy prompt field
// was removed in schema 1.8: the companion builds its own question from the entry's ref.
Details []string
// Schema 1.5. Asks is 1-3 short natural questions for this entry, Ref the stable subject the
// advisor expands (never shown to players).
Asks []string
Ref string
// Schema 1.6. Why is one short, factual reason (at most MaxWhy characters), left out when no fact fits.
Why string
// Schema 1.7, upgrades: Wear is "Wear now", "From level N" or "After you train" (a weapon skill to learn first), Gain "Big upgrade", "Solid upgrade" or
// "Small upgrade", Replaces the worn item's name alone ("" for an empty slot; schema 1.9), How the best path's
// one line and PathKind its kind (quest, craft, auction, dungeon or creature), for the icon.
Wear, Gain, Replaces, How, PathKind string
// Train is the weapon skill the upgrade needs and the character can learn, "" when none.
Train string
// Unlocks is on a turn-in line: the follow-ups turning it in unlocks (not written to Digest.lua).
Unlocks []string
// Trip is a turn-in that is a journey: the quest asks for nothing and is handed in elsewhere, at
// Finisher in FinisherPlace, inside the dungeon Instance when there is one (InstanceZone is its zone).
Trip bool
Finisher, FinisherPlace, Instance, InstanceZone string
Spells []TrainSpell // training: the abilities and ranks
// Schema 1.10, training: Ahead is the blocked and later offers (State, Requires, RequiresQuest, Level), Map the
// trainer's uiMapID with X, Y its map percent, when HasXY.
Ahead []TrainSpell
Map int
X, Y float64 // training: the trainer's map percent, when HasXY
HasXY bool
// contains filtered or unexported fields
}
Line is one digest line; Item and Quest are zero when absent. Text is clipped to MaxText for older addons; every field after Quest is optional, never clipped, and left out when empty.
type Objective ¶ added in v0.7.2
Objective is one objective of a quest: its text without the count, and the count when known.
type Options ¶
type Options struct {
Now time.Time
Client character.Client // the game client that wrote the capture
DatasetBuild string // the dataset's game build; empty when none
Questie *questie.Index // the player's own QuestieDB; nil when they have none
// PrevLevel is the character's level at the last capture, 0 when unknown. Training then covers
// the levels after it; with 0 it covers the character's own level only.
PrevLevel int
// Unlocks is, per turn-in quest id, the follow-ups the plan says it unlocks, as "Quest (from NPC,
// here)"; a turn-in entry then says "Unlocks: ..." and its prompt names the first.
Unlocks map[int][]string
// Order is the quest ids in route order; Next quests follows it, so the panel and the route agree.
Order []int
}
Options is what Build needs besides the capture and the dataset.
type Section ¶
type Section struct {
ID string
Lines []Line
// Summary is the section's one line count, such as "3 upgrades you can get" (schema 1.7).
Summary string
}
Section is an ordered group of lines.
type StatsEntry ¶ added in v0.7.12
type StatsEntry struct {
Insights []string // 1-3 sentences, each at most stats.MaxInsight characters
Profile string // for example "Fury · leveling"
Asks []string
}
StatsEntry is the optional stats entry (schema 1.7): the stat check in plain words.
type Subject ¶ added in v0.7.7
type Subject struct {
Ref, Kind, Text string
Details []string
Place, Of int // the 1-based position in the next-quests plan, and its length
// Line is the entry itself when it is a section line (not a dungeon or talent line): its ids,
// giver, zone, level, class flag, why and objectives.
Line *Line
}
Subject is what the advisor expands a ref into: the entry's own text and details, and where the plan puts it (Place is 0 when the entry is not a plan step).
type TalentLine ¶
type TalentLine struct {
Line string
Spell int
Details []string
Asks []string
Ref string
Why string
}
TalentLine is one talents entry: the next point to spend; Spell is zero when the dataset has none.
type TrainSpell ¶ added in v0.7.4
type TrainSpell struct {
ID int
Name string
Rank int // 0 when the ability has no rank
New bool // false when it upgrades a known rank
Cost int64 // copper; 0 when not known
// Schema 1.10. State is "available", "blocked" (the trainer will not teach it until Requires is
// learned) or "later" (above the character's level). Requires is the prerequisite spell id and
// RequiresQuest the quest that teaches it, 0 when none; Level is the level it is taught at.
State string
Requires int
RequiresQuest int
Level int
}
TrainSpell is one trainer-taught ability or rank of a training entry.