digest

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 22 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 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

View Source
const (
	Schema         = "1.4"
	EnvelopeSchema = "2.0"
)

Schema is the version of one character's entry; EnvelopeSchema is the file's.

View Source
const (
	NextQuests    = "next_quests"
	Upgrades      = "upgrades"
	KeepMaterials = "keep_materials"
	Notes         = "notes"
)

Section ids the panel knows.

View Source
const (
	MaxQuests    = 8
	MaxUpgrades  = 8
	MaxMaterials = 10
	MaxNotes     = 6
	MaxDungeons  = 3
	MaxTalents   = 3
	MaxText      = 60
)

Caps: the most lines a section holds, and the longest line, in characters. The panel is narrow.

View Source
const (
	KindPickup   = "pickup"
	KindTurnIn   = "turnin"
	KindProgress = "progress"
	KindTalent   = "talent"
	KindNote     = "note"
)

Line kinds, for a Line's Kind.

View Source
const (
	MaxPrompt      = 500 // the in-game ask cap, in characters
	MaxDetails     = 4
	MaxTrainSpells = 8
)

Caps for the per-entry context (schema 1.4).

View Source
const KindTraining = "training"

KindTraining is the Kind of a class-training entry in next_quests (schema 1.4).

View Source
const MaxCharacters = 30

MaxCharacters is the most characters one file holds.

View Source
const NoDataText = "Game data not downloaded yet; see Setup"

NoDataText is what NEXT says when no game dataset has downloaded.

View Source
const SlotAddon = "WoWCompanion_Digest"

SlotAddon is the data-only addon the digest is written into.

Variables

This section is empty.

Functions

func CheckInstalled

func CheckInstalled(digestPath string) error

CheckInstalled is an error when the slot addon's folder is not there. Nothing is created.

func DigestPath

func DigestPath(savedVariables string) (string, error)

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 Quote

func Quote(s string) string

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

func Same(path string, d Envelope) bool

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 SameText added in v0.6.0

func SameText(path, text string) bool

SameText is Same for any data-only Lua text carrying a `generated = N,` line.

func SameTextSince added in v0.7.1

func SameTextSince(path, text string, capturedAt int64) bool

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

func Select(chars []character.Character) (kept, skipped []character.Character)

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

func SiblingPath(path, file string) string

SiblingPath is the file named file in the folder of the digest file at path, keeping its separator.

func SlotCheck

func SlotCheck(src string) error

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

func SlotPath(savedVariables, addon, file string) (path string, ok bool)

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 Write

func Write(path string, d Envelope) error

Write replaces path with the envelope atomically: a temp file in the same folder, then a rename. The folder must exist.

func WriteFile added in v0.6.0

func WriteFile(path, text string) error

WriteFile replaces path with text atomically, as Write does.

Types

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
}

Digest is the whole file.

func Build

func Build(c character.Character, ds store.DataStore, opt Options) Digest

Build computes the digest for c. ds may be nil (no dataset); sections with nothing to say are left out.

func (Digest) Lua

func (d Digest) Lua() string

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

func (Envelope) Lua

func (e Envelope) Lua() string

Lua renders the envelope as the one data-only `WoWCompanionDigest = {...}` assignment.

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
	AtLevel int    // upgrades: the character level the item needs, when not yet wearable

	// Schema 1.4. Details is 1-4 short context lines, Prompt a ready question for the companion's AI
	// (at most MaxPrompt characters); both are set on every entry.
	Details []string
	Prompt  string
	// Unlocks is on a turn-in line: the follow-ups turning it in unlocks (not written to Digest.lua).
	Unlocks []string
	Spells  []TrainSpell // training: the abilities and ranks
	X, Y    float64      // training: the trainer's map percent, when HasXY
	HasXY   bool
}

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

type Objective struct {
	Text       string
	Have, Need int
	HasCount   bool
}

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
}

Options is what Build needs besides the capture and the dataset.

type Section

type Section struct {
	ID    string
	Lines []Line
}

Section is an ordered group of lines.

type TalentLine

type TalentLine struct {
	Line    string
	Spell   int
	Details []string
	Prompt  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
}

TrainSpell is one trainer-taught ability or rank of a training entry.

Jump to

Keyboard shortcuts

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