achievements

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 7 Imported by: 0

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

View Source
var All = generate()

All is every achievement, generated once.

View Source
var ByTrigger = groupByTrigger(All)

ByTrigger groups them for matching, so a killmail does not rescan the whole list per attacker.

Functions

func Process

func Process(ctx context.Context, pool *pgxpool.Pool, km Killmail) (int64, error)

Process applies one killmail's achievement increments.

Types

type Attacker

type Attacker struct {
	CharacterID int32
	ShipGroupID int32
	FinalBlow   bool
}

Attacker is one participant, reduced to what achievements care about.

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 Rarity

type Rarity string

Rarity is the badge tier, escalating with the threshold.

const (
	Common    Rarity = "common"
	Uncommon  Rarity = "uncommon"
	Rare      Rarity = "rare"
	Epic      Rarity = "epic"
	Legendary Rarity = "legendary"
)

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.

type Trigger

type Trigger string

Trigger is what a definition counts.

const (
	TriggerFinalBlows      Trigger = "final_blows"
	TriggerSoloKills       Trigger = "solo_kills"
	TriggerKillsByValue    Trigger = "kills_by_value"
	TriggerKillsBySecurity Trigger = "kills_by_security"
	TriggerShipKills       Trigger = "ship_kills"
	TriggerShipLosses      Trigger = "ship_losses"
)

Jump to

Keyboard shortcuts

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