package achievement
import "git.teletypegames.org/engines/inkwell/achievement"
Package achievement holds achievements: what the player can be recognised for, declared as content.
An Achievement is a Name a platform knows it by — the Steam API name — a Title and a Text in every language the game speaks, and the inkbase.Condition that earns it: a flag raised, an item in hand, a scene entered. It is registered in a Manager like any other entity and handed to the game as Game.AchievementManager; Game.Validate rejects one with no When.
AchievementManager.Register(&inkwell.Achievement{
Name: "ACH_LADDER",
Title: inkwell.Text{{Lang: "en", Text: "Up and Out"}},
Text: inkwell.Text{{Lang: "en", Text: "Climbed the fire escape."}},
When: inkwell.Flag("on_roof"),
})
The engine evaluates every achievement on each frame the world is showing, a running script included, and hands the ones that have just come true to every Unlocker among the game's extensions. It keeps no record of its own beyond a per-process set that stops a condition that stays true from firing every frame: a platform that has a record, such as Steam, answers a repeated unlock idempotently, and a game without one has nothing to persist. A loaded game whose condition is already met therefore reports it again in the next process, which is what lets an achievement earned offline reach the platform.
Title and Text are what a platform's own listing repeats — the words typed into the Steamworks partner site are these — and what a screen of the game's own would show; nothing in the engine draws them.
Index
Types
type Achievement
type Achievement struct { // Name is the key a platform knows the achievement by — the API name // entered on the Steamworks partner site, for one. Name string // Title and Text are what a screen shows for it, in every language the // game speaks; a platform shows its own copy of the same words. Title inkbase.Text Text inkbase.Text // When earns it. Evaluated on the world stage, every frame. When inkbase.Condition }
Achievement is something the player is recognised for: a name a platform knows it by, a title and a line for a screen that lists it, and the Condition that earns it. The engine evaluates When every frame the world is showing and reports the rising edge — a flag raised, an item picked up, a scene entered — to every extension that can take one (see inkwell.Unlocker). The engine keeps no record of its own: a platform that has one, Steam, answers idempotently, and a game without one has nothing to persist.
func (Achievement) GetName
func (a Achievement) GetName() string
GetName returns the achievement's Name, the key it is registered under.
func (Achievement) TypeLabel
func (a Achievement) TypeLabel() string
TypeLabel returns "achievement", the kind that tells an achievement apart from other entities of the same Name in saved state and in panic messages.
type Manager
type Manager = inkbase.Manager[*Achievement]
Manager is the registry of achievements, keyed by Achievement.Name and kept in registration order; see inkbase.Manager.
func NewManager
func NewManager() *Manager
NewManager returns an empty Manager of achievements.