character

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

View Source
const DBVariable = "ForeverScribeDB"

DBVariable is the one global the addon writes.

View Source
const NearFraction = 0.75

NearFraction is the share of objectives done at which an open quest counts as nearly complete.

View Source
const RecentGiver = 7 * 24 * time.Hour

RecentGiver is how recently a giver must have been met to be flagged as a recent interaction.

Variables

This section is empty.

Functions

This section is empty.

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

	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 and Plan are 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
	Plan    *TalentPlan
}

func LoadCharacter

func LoadCharacter(key string, rec lua.Table) Character

func (Character) GiverLines added in v0.5.0

func (c Character) GiverLines(now time.Time, max int) []string

GiverLines renders up to max nearby givers, one line each; none when there are none.

func (Character) LastKnownPosition added in v0.5.0

func (c Character) LastKnownPosition() *Position

LastKnownPosition is nil when neither a located save nor any NPC sighting exists.

func (Character) NearbyGivers added in v0.5.0

func (c Character) NearbyGivers(now time.Time) []Giver

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 Client

type Client struct {
	Version string
	Build   string
	TOC     string
}

Client is the game client that wrote the capture.

func (Client) Empty

func (c Client) Empty() bool

type EquippedItem

type EquippedItem struct {
	Slot          string
	ItemID        *int
	Enchant       *int
	Link          string
	Name          string
	ItemLevel     *int
	Quality       *int
	Durability    *int
	DurabilityMax *int
}

type File

type File struct {
	Addon      string
	Schema     *int
	Client     Client
	Characters []Character
}

File is everything one SavedVariables file holds.

func Load

func Load(vars map[string]any) (File, error)

Load builds models from parsed variables (the result of lua.Parse).

func LoadFile

func LoadFile(path string) (File, error)

LoadFile reads and parses a ForeverScribe.lua file. A malformed file is a *lua.ParseError.

func (File) CapturedAt

func (f File) CapturedAt() *int64

CapturedAt is the newest capture time over all characters.

func (File) ClientOf

func (f File) ClientOf(c Character) Client

ClientOf is the client block of one character, falling back to the file's.

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 ItemStack

type ItemStack struct {
	ItemID int
	Count  int
	Name   string
	Link   string
}

type Location added in v0.4.0

type Location struct {
	Zone    string
	Subzone string
	MapName string
	MapID   *int
	X, Y    *float64
}

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 Objective

type Objective struct {
	Text string
	Have *int
	Need *int
	Done *bool
	Type string
}

func (Objective) Label added in v0.7.2

func (o Objective) Label() string

Label is the objective's text without its have/need count: "Windsong Crawler Meat".

type PlanPick added in v0.7.0

type PlanPick struct {
	Node string `json:"node"`
	Rank int    `json:"rank"`
}

PlanPick is one entry of a talent plan: a captured node's name and the rank to reach.

type Position added in v0.5.0

type Position struct {
	Zone, Subzone string
	MapID         *int
	X, Y          float64
	Approximate   bool
}

Position is the character's last known place: the saved location when it has coordinates, else (Approximate) where the most recent NPC interaction happened.

func (Position) InZone added in v0.5.0

func (p Position) InZone(zone string) bool

InZone reports whether a quest's zone name matches the position's zone or subzone.

func (Position) Label added in v0.5.0

func (p Position) Label() string

Label describes the position, marking an approximate one.

type Profile added in v0.7.0

type Profile struct {
	Role     string `json:"role"`
	Focus    string `json:"focus"`
	Spec     string `json:"spec,omitempty"`
	GuideURL string `json:"guide_url,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, and optionally a guide page.

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

func (q Quest) Fraction() (float64, bool)

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

func (q Quest) NearlyDone() bool

NearlyDone reports a quest that is complete or has at least NearFraction of its objectives done.

func (Quest) ObjectiveProgress added in v0.5.0

func (q Quest) ObjectiveProgress() string

ObjectiveProgress is ProgressText without the quest name: "3/8 Crab Claws; 1/1 Boss".

func (Quest) ProgressText added in v0.5.0

func (q Quest) ProgressText() string

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 Reputation struct {
	FactionID int
	Name      string
	Standing  *int
	Value     *int
	Min       *int
	Max       *int
	AtWar     *bool
	Group     string
}

type Skill

type Skill struct {
	Name    string
	SkillID *int
	Rank    *int
	Max     *int
	Group   string
}

type Spot added in v0.5.0

type Spot struct {
	X, Y *float64
	T    *int64
	N    *int
}

Spot is one place an NPC was seen (map percent) and when.

type Talent

type Talent struct {
	Name    string
	Group   string
	Rank    int
	MaxRank *int
	NodeID  *int
	SpellID *int
	Type    string // node type as captured, "" when absent
	CanBuy  *bool  // nil when the capture does not say
}

type TalentGroup

type TalentGroup struct {
	Name  string
	Order *int
	Spent int
}

TalentGroup is one named branch of a tree (for example "Discipline") and its spent points.

type TalentPlan added in v0.7.0

type TalentPlan struct {
	Spec     string     `json:"spec"`
	GuideURL string     `json:"guide_url"`
	Date     string     `json:"date"` // YYYY-MM-DD the plan was built
	Picks    []PlanPick `json:"picks"`
}

TalentPlan is an ordered list of talent nodes with target ranks, from the player's chosen guide. It holds node names and ranks only, never guide text.

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

func (t *Talents) ProfessionUnspent() int

ProfessionUnspent is the unspent points over the profession trees; 0 when there are none.

Jump to

Keyboard shortcuts

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