Documentation
¶
Index ¶
- Constants
- func ComputeCategoryXP(weights Weights, gameType string, modeStats []store.ModeStat) int
- func ComputeDailyStreak(dates []time.Time, now time.Time) int
- func ContentWidth(termWidth int) int
- func LevelFromXP(xp int) int
- func StaticHeight(cards []Card) int
- func TruncateToDate(t time.Time) time.Time
- func ViewportHeight(availableHeight int) int
- func XPForLevel(level int) int
- type Card
- type ModeKey
- type ProfileBanner
- type Weights
Constants ¶
const ( CardInnerWidth = 30 CardHeight = 9 )
const (
CardFullWidth = CardInnerWidth + 4
)
Variables ¶
This section is empty.
Functions ¶
func ComputeCategoryXP ¶
ComputeCategoryXP calculates total XP for a game category by summing XP across all modes. Daily victories earn 2x XP.
func ComputeDailyStreak ¶
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 LevelFromXP ¶
LevelFromXP returns the level for the given total XP. Uses the inverse of XPForLevel: level = floor((xp / 5) ^ (1/1.6))
func StaticHeight ¶
func TruncateToDate ¶
TruncateToDate strips the time component, returning midnight local time.
func ViewportHeight ¶
func XPForLevel ¶
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 ¶
BuildCards constructs a Card for each category the player has interacted with. Categories with zero attempts are excluded.
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
func WeightsFromDefinitions ¶ added in v1.8.0
func WeightsFromDefinitions(definitions []puzzle.Definition) Weights