domain

package
v0.0.0-...-addc432 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAPIKey          = errors.New("invalid API key")
	ErrPlayerNotFound         = errors.New("player not found")
	ErrTemporarilyUnavailable = errors.New("temporarily unavailable")
	ErrUserNotFound           = errors.New("user not found")
	ErrUsernameNotFound       = errors.New("username not found")
)
View Source
var ErrAuthSessionExpired = errors.New("auth session expired")

ErrAuthSessionExpired is returned by app-layer validation when the session is past its expiry (still potentially refreshable).

View Source
var ErrAuthSessionNotFound = errors.New("auth session not found")

ErrAuthSessionNotFound is returned when a session id is unknown to the repo.

View Source
var ErrAuthSessionRefreshExpired = errors.New("auth session refresh window expired")

ErrAuthSessionRefreshExpired is returned when the session is past the refresh window or its 24h hard max-age.

View Source
var ErrAuthSessionRevoked = errors.New("auth session revoked")

ErrAuthSessionRevoked is returned when an operation is attempted on a session that has been explicitly ended (replaced, evicted, etc.).

Functions

func ExperienceToStars

func ExperienceToStars(experience int64) float64

func StarsToExperience

func StarsToExperience(stars int) int64

Types

type Account

type Account struct {
	UUID      string
	Username  string
	QueriedAt time.Time
}

type AuthSession

type AuthSession struct {
	ID           string
	IdentityType AuthSessionIdentityType
	IdentityKey  string
	IPHash       string
	CreatedAt    time.Time
	ExpiresAt    time.Time
	RefreshUntil time.Time
	// LifetimeEndsAt is the absolute deadline past which this session
	// can no longer be refreshed, regardless of how many refreshes have
	// happened. Fixed at issue, never extended.
	LifetimeEndsAt time.Time
	LastUsedAt     time.Time
	RevokedAt      *time.Time
}

AuthSession is one row in the auth_sessions table — a server-side bearer session, regardless of tier. The discriminator is IdentityType.

RevokedAt is nil iff the session is still active (which is to say: not explicitly ended; natural expiry past refresh_until is a separate concept and doesn't set this field). The reason a session was revoked is recorded in the DB but not exposed on the typed model — it's audit data, not load-bearing logic.

type AuthSessionIdentityType

type AuthSessionIdentityType string

AuthSessionIdentityType discriminates the tier the session represents. Only the anonymous tier is implemented today; the Microsoft tier will add a value here when it lands.

const AuthSessionIdentityAnonymous AuthSessionIdentityType = "anonymous"

type GameOutcome

type GameOutcome string

GameOutcome names how a single Bedwars game ended for the player. Draws are rare but do happen, so the outcome is a three-state enum rather than a won/lost boolean.

const (
	GameOutcomeWin  GameOutcome = "win"
	GameOutcomeLoss GameOutcome = "loss"
	GameOutcomeDraw GameOutcome = "draw"
)

type GameResult

type GameResult struct {
	Gamemode   Gamemode
	Outcome    GameOutcome
	FinalKills int
	FinalDeath bool
	BedsBroken int
	BedLost    bool
	Kills      int
	Deaths     int
	Experience int64
}

GameResult describes what happened in a single Bedwars game — which gamemode it was played in, how it ended for the player, and the stat deltas that the player accrued during it.

type Gamemode

type Gamemode string

Gamemode names a Bedwars team-size mode. GamemodeOverall is not a real in-game mode — it's the aggregate scope used by stat queries and milestone tracking — but it lives on the same type for parity with the per-mode values.

const (
	GamemodeSolo    Gamemode = "solo"
	GamemodeDoubles Gamemode = "doubles"
	GamemodeThrees  Gamemode = "threes"
	GamemodeFours   Gamemode = "fours"
	GamemodeFourv4  Gamemode = "4v4"
	GamemodeOverall Gamemode = "overall"
)

type GamemodeStatsPIT

type GamemodeStatsPIT struct {
	// Winstreak is nil when hidden via Hypixel API settings. Usually all
	// gamemodes are set or all nil, but they vary independently: a gamemode
	// can be nil while others are set, and Overall can be nil while individual
	// gamemodes are set. Do not assume presence is consistent across gamemodes.
	Winstreak   *int
	GamesPlayed int
	Wins        int
	Losses      int
	BedsBroken  int
	BedsLost    int
	FinalKills  int
	FinalDeaths int
	Kills       int
	Deaths      int
}

type MilestoneAchievement

type MilestoneAchievement struct {
	Milestone int64                      // The milestone value that was reached
	After     *MilestoneAchievementStats // First stats after the milestone was reached
}

MilestoneAchievement represents when a milestone was reached

type MilestoneAchievementStats

type MilestoneAchievementStats struct {
	Player PlayerPIT
	Value  int64
}

type PlayerPIT

type PlayerPIT struct {
	DBID *string

	QueriedAt time.Time

	UUID string

	Displayname *string
	LastLogin   *time.Time
	LastLogout  *time.Time

	// TODO: Remove? -> Can be derived from checking gamesplayed == 0
	MissingBedwarsStats bool

	Experience int64
	Solo       GamemodeStatsPIT
	Doubles    GamemodeStatsPIT
	Threes     GamemodeStatsPIT
	Fours      GamemodeStatsPIT
	Fourv4     GamemodeStatsPIT
	Overall    GamemodeStatsPIT
}

func (*PlayerPIT) Stars

func (p *PlayerPIT) Stars() float64

Stars calculates the player's stars based on their experience

type Session

type Session struct {
	Start       PlayerPIT
	End         PlayerPIT
	Consecutive bool
	// Ongoing is true iff this session could be extended.
	Ongoing bool
}

type Stat

type Stat string

Stat represents different statistical measures

const (
	StatStars      Stat = "stars"
	StatExperience Stat = "experience"
)

type TagSeverity

type TagSeverity int
const (
	TagSeverityNone TagSeverity = iota
	TagSeverityMedium
	TagSeverityHigh
)

func (TagSeverity) String

func (ts TagSeverity) String() string

type Tags

type Tags struct {
	Cheating TagSeverity
	Sniping  TagSeverity
}

func (Tags) AddCheating

func (t Tags) AddCheating(severity TagSeverity) Tags

func (Tags) AddSniping

func (t Tags) AddSniping(severity TagSeverity) Tags

type User

type User struct {
	UserID        string
	FirstSeenAt   time.Time
	LastSeenAt    time.Time
	LastIPHash    string
	LastUserAgent string
	SeenCount     int64
}

Jump to

Keyboard shortcuts

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