Documentation
¶
Index ¶
- Variables
- func ExperienceToStars(experience int64) float64
- func StarsToExperience(stars int) int64
- type Account
- type AuthSession
- type AuthSessionIdentityType
- type GameOutcome
- type GameResult
- type Gamemode
- type GamemodeStatsPIT
- type MilestoneAchievement
- type MilestoneAchievementStats
- type PlayerPIT
- type Session
- type Stat
- type TagSeverity
- type Tags
- type User
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAPIKey = errors.New("invalid API key") ErrPlayerNotFound = errors.New("player not found") ErrUserNotFound = errors.New("user not found") ErrUsernameNotFound = errors.New("username not found") )
var ErrAuthSessionExpired = errors.New("auth session expired")
ErrAuthSessionExpired is returned by app-layer validation when the session is past its expiry (still potentially refreshable).
var ErrAuthSessionNotFound = errors.New("auth session not found")
ErrAuthSessionNotFound is returned when a session id is unknown to the repo.
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.
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 StarsToExperience ¶
Types ¶
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.
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 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
}
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