Files
oslstats/pkg/slapshotapi/types.go
2026-02-21 14:45:14 +11:00

159 lines
5.9 KiB
Go

package slapshotapi
// Score represents the score for both teams in a match
type Score struct {
Home int `json:"home"`
Away int `json:"away"`
}
// PlayerStats contains all possible player statistics from a match.
// Fields use pointers because not every stat is present in every match response.
type PlayerStats struct {
Goals *float64 `json:"goals,omitempty"`
Assists *float64 `json:"assists,omitempty"`
PrimaryAssists *float64 `json:"primary_assists,omitempty"`
SecondaryAssists *float64 `json:"secondary_assists,omitempty"`
Saves *float64 `json:"saves,omitempty"`
Blocks *float64 `json:"blocks,omitempty"`
Shots *float64 `json:"shots,omitempty"`
Turnovers *float64 `json:"turnovers,omitempty"`
Takeaways *float64 `json:"takeaways,omitempty"`
Passes *float64 `json:"passes,omitempty"`
PossessionTime *float64 `json:"possession_time_sec,omitempty"`
FaceoffsWon *float64 `json:"faceoffs_won,omitempty"`
FaceoffsLost *float64 `json:"faceoffs_lost,omitempty"`
PostHits *float64 `json:"post_hits,omitempty"`
OvertimeGoals *float64 `json:"overtime_goals,omitempty"`
GameWinningGoals *float64 `json:"game_winning_goals,omitempty"`
Score *float64 `json:"score,omitempty"`
ContributedGoals *float64 `json:"contributed_goals,omitempty"`
ConcededGoals *float64 `json:"conceded_goals,omitempty"`
GamesPlayed *float64 `json:"games_played,omitempty"`
Wins *float64 `json:"wins,omitempty"`
Losses *float64 `json:"losses,omitempty"`
OvertimeWins *float64 `json:"overtime_wins,omitempty"`
OvertimeLosses *float64 `json:"overtime_losses,omitempty"`
Ties *float64 `json:"ties,omitempty"`
Shutouts *float64 `json:"shutouts,omitempty"`
ShutsAgainst *float64 `json:"shutouts_against,omitempty"`
HasMercyRuled *float64 `json:"has_mercy_ruled,omitempty"`
WasMercyRuled *float64 `json:"was_mercy_ruled,omitempty"`
PeriodsPlayed *float64 `json:"periods_played,omitempty"`
}
// Player represents a single player's data in a match
type Player struct {
GameUserID string `json:"game_user_id"`
Team string `json:"team"`
Username string `json:"username"`
Stats PlayerStats `json:"stats"`
}
// GameStats contains the in-game statistics and settings for a match.
// This is the core match data returned both by the API and in local match logs.
type GameStats struct {
Type string `json:"type"`
Arena string `json:"arena"`
Score Score `json:"score"`
Winner string `json:"winner"`
EndReason string `json:"end_reason"`
MatchLength string `json:"match_length"`
PeriodsEnabled string `json:"periods_enabled"`
CurrentPeriod string `json:"current_period"`
CustomMercyRule string `json:"custom_mercy_rule"`
Players []Player `json:"players"`
}
// Game represents a full match as returned by the API /games/{id} endpoint
type Game struct {
ID string `json:"id"`
Region string `json:"region"`
MatchType string `json:"match_type"`
Gamemode string `json:"gamemode"`
Created string `json:"created"`
GameStats GameStats `json:"game_stats"`
}
// LobbyPlayer represents a player in a lobby
type LobbyPlayer struct {
ID int `json:"id"`
Username string `json:"username"`
}
// LobbyTeams represents the team assignments in a lobby
type LobbyTeams struct {
Home []LobbyPlayer `json:"home"`
Away []LobbyPlayer `json:"away"`
Spectators []LobbyPlayer `json:"spectators"`
}
// Lobby represents a custom lobby as returned by the API
type Lobby struct {
UUID string `json:"uuid"`
Region string `json:"region"`
Name string `json:"name"`
HasPassword bool `json:"has_password"`
Owner int `json:"owner"`
OwnerName string `json:"owner_name"`
PlayerCount int `json:"player_count"`
MaxPlayers int `json:"max_players"`
InGame bool `json:"in_game"`
Players LobbyTeams `json:"players"`
MercyRule int `json:"mercy_rule"`
Arena string `json:"arena"`
PeriodsEnabled bool `json:"periods_enabled"`
CurrentPeriod int `json:"current_period"`
Score Score `json:"score"`
Starting bool `json:"starting"`
CanStart bool `json:"can_start"`
}
// LobbyCreationRequest contains the parameters for creating a new lobby
type LobbyCreationRequest struct {
Region string `json:"region"`
Name string `json:"name"`
Password string `json:"password"`
CreatorName string `json:"creator_name"`
// Optional fields
IsPeriods *bool `json:"is_periods,omitempty"`
CurrentPeriod *int `json:"current_period,omitempty"`
MatchLength *int `json:"match_length,omitempty"`
MercyRule *int `json:"mercy_rule,omitempty"`
Arena string `json:"arena,omitempty"`
InitialScore *Score `json:"initial_score,omitempty"`
}
// LobbyCreationResponse is returned when a lobby is successfully created
type LobbyCreationResponse struct {
Success bool `json:"success"`
LobbyID string `json:"lobby_id"`
}
// MatchmakingPlayer represents a player in the matchmaking queue
type MatchmakingPlayer struct {
UUID int `json:"uuid"`
Username string `json:"username"`
}
// MatchmakingRegion represents a region in a matchmaking entity
type MatchmakingRegion struct {
Key string `json:"key"`
Name string `json:"name"`
}
// MatchmakingEntity represents a group/party in the matchmaking queue
type MatchmakingEntity struct {
Players []MatchmakingPlayer `json:"players"`
Regions []MatchmakingRegion `json:"regions"`
MMR int `json:"mmr"`
MMROffset int `json:"mmr_offset"`
}
// MatchmakingResponse is the full matchmaking queue response from the API
type MatchmakingResponse struct {
Entities []MatchmakingEntity `json:"entities"`
Playlists PubsQueue `json:"playlists"`
}