stats

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CardInnerWidth = 30
	CardHeight     = 9
)
View Source
const (
	CardFullWidth = CardInnerWidth + 4
)

Variables

This section is empty.

Functions

func ComputeCategoryXP

func ComputeCategoryXP(weights Weights, gameType string, modeStats []store.ModeStat) int

ComputeCategoryXP calculates total XP for a game category by summing XP across all modes. Daily victories earn 2x XP.

func ComputeDailyStreak

func ComputeDailyStreak(dates []time.Time, now time.Time) int

ComputeDailyStreak calculates the length of the current daily completion streak. The streak is "alive" if the most recent completion is today or yesterday (giving the player until end of day to extend it).

func ContentWidth

func ContentWidth(termWidth int) int

func LevelFromXP

func LevelFromXP(xp int) int

LevelFromXP returns the level for the given total XP. Uses the inverse of XPForLevel: level = floor((xp / 5) ^ (1/1.6))

func StaticHeight

func StaticHeight(cards []Card) int

func TruncateToDate

func TruncateToDate(t time.Time) time.Time

TruncateToDate strips the time component, returning midnight local time.

func ViewportHeight

func ViewportHeight(availableHeight int) int

func XPForLevel

func XPForLevel(level int) int

XPForLevel returns the total XP required to reach the given level. Formula: ceil(5 * level^1.6)

Types

type Card

type Card struct {
	GameType      string
	Level         int
	PreferredMode string
	Victories     int
	Attempts      int
	DailyPlayed   int
	CurrentXP     int
	NextLevelXP   int
}

Card holds the computed stats for a single game category.

func BuildCards

func BuildCards(weights Weights, catStats []store.CategoryStat, modeStats []store.ModeStat) []Card

BuildCards constructs a Card for each category the player has interacted with. Categories with zero attempts are excluded.

type ModeKey

type ModeKey struct {
	GameType string
	Mode     string
}

ModeKey identifies a specific mode within a game category.

type ProfileBanner

type ProfileBanner struct {
	ProfileLevel         int
	DailyStreak          int
	TotalDailies         int
	CurrentDaily         bool
	WeekliesCompleted    int
	ThisWeekHighestIndex int
}

ProfileBanner holds the summary data shown above the card grid.

func BuildProfileBanner

func BuildProfileBanner(
	catStats []store.CategoryStat,
	modeStats []store.ModeStat,
	weights Weights,
	streakDates []time.Time,
	currentDaily bool,
	weekliesCompleted int,
	thisWeekHighestIndex int,
) ProfileBanner

BuildProfileBanner constructs the summary banner shown above the card grid.

type Weights added in v1.8.0

type Weights map[ModeKey]int

func WeightsFromDefinitions added in v1.8.0

func WeightsFromDefinitions(definitions []puzzle.Definition) Weights

Jump to

Keyboard shortcuts

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