Documentation
¶
Overview ¶
Package achievements awards the per-character badges the profile pages show.
The definitions are generated rather than listed, because most of them are the same handful of shapes at five escalating thresholds — "destroy 10 frigates", "destroy 50 frigates", and so on. Generating them keeps the thresholds and their point values in one table instead of ninety near-identical literals.
Ids are a stable contract: they are the primary key of entity_achievements and appear in URLs, so a generated id must never change for an existing achievement. That is why the id format is fixed and the categories are keyed by a short slug rather than by their display name.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var All = generate()
All is every achievement, generated once.
var ByTrigger = groupByTrigger(All)
ByTrigger groups them for matching, so a killmail does not rescan the whole list per attacker.
Functions ¶
Types ¶
type Definition ¶
type Definition struct {
ID string
Name string
Description string
Category string
Threshold int32
BasePoints int32
Rarity Rarity
// Negative marks an achievement that subtracts points. Losing ships is
// tracked and celebrated, but it does not make you look better.
Negative bool
Trigger Trigger
// The trigger's parameters. Only the ones its trigger uses are set.
GroupIDs []int32
MinValue float64
MinSec float64
MaxSec float64
}
Definition is one achievement.
func Filter ¶
func Filter(id, category string) []Definition
Filter returns the definitions selected by the CLI's optional id and category filters. Matching categories case-insensitively mirrors the TypeScript command.
func (Definition) MatchesGroup ¶
func (d Definition) MatchesGroup(groupID int32) bool
MatchesGroup reports whether a ship group is one this definition counts.
func (Definition) SignedBasePoints ¶
func (d Definition) SignedBasePoints() int32
SignedBasePoints is the point value with its sign applied.
type Killmail ¶
type Killmail struct {
TotalValue float64
SystemSecurity float64
HasSecurity bool
IsNPC bool
IsSolo bool
VictimShipGroupID int32
VictimCharacterID int32
Attackers []Attacker
}
Killmail is what the processor needs about a kill.
type RebuildResult ¶
type RebuildResult struct {
Definitions int `json:"definitions"`
Rows int64 `json:"rows"`
Removed int64 `json:"removed"`
Characters int64 `json:"characters"`
}
RebuildResult describes an authoritative achievement rebuild.
func Rebuild ¶
func Rebuild(ctx context.Context, pool *pgxpool.Pool, definitions []Definition, syncAll bool) (RebuildResult, error)
Rebuild replaces the counters for the selected definitions with counts derived from the same source tables as the TypeScript command.
This is deliberately not implemented by replaying the live award path. Replays add to existing counters and therefore cannot be safely re-run, whereas an administrative rebuild must converge to the same rows every time.