models

package
v0.0.0-...-09b6cf2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DIAMOND GenType = "diamond"
	GOLD    GenType = "gold"
	IRON    GenType = "iron"

	MIDDLE     GenLocation = "middle"
	SEMIMIDDLE GenLocation = "semimiddle"
	BASE       GenLocation = "base"
)
View Source
const HOLDER_KEY string = "holder"
View Source
const LEADERBOARD_SIZE int = 200

Variables

This section is empty.

Functions

This section is empty.

Types

type ChestLocation

type ChestLocation struct {
	Season Season `json:"season_name"`
	X      int    `json:"x"`
	Y      int    `json:"y"`
	Z      int    `json:"z"`
}

type DatabaseProvider

type DatabaseProvider interface {
	GetBackingDB() *sql.DB

	// GetSeasons returns all seasons if active is true, otherwise it returns all seasons
	GetSeasons(active bool) ([]Season, error)
	// GetCurrentChestLocations returns all chest locations for the current season
	GetCurrentChestLocations() ([]ChestLocation, error)
	// GetChestLocations returns all chest locations for the given season
	GetChestLocations(season string) ([]ChestLocation, error)

	// GetEggWarsMaps returns all egg wars maps
	GetEggWarsMaps() ([]EggWarsMap, error)
	// GetEggWarsMap returns the egg wars map with the given unique name
	GetEggWarsMap(uniqueName string) (*EggWarsMap, error)

	// GetGames returns all games if active is true, otherwise it returns all games
	GetGames(active bool) ([]Game, error)

	// GetLeaderboard returns the top 200 players for the given game. This may be the UniqueName, DisplayName or an Alias
	GetLeaderboard(game string) ([]LeaderboardRow, error)
	// GetLeaderboardBounded returns the top players for the given game between the start and end
	GetLeaderboardBounded(game string, start int, end int) ([]LeaderboardRow, error)
	// GetLeaderboardForPlayer returns the leaderboard for the given player
	GetLeaderboardForPlayer(player string) ([]LeaderboardRow, error)

	// SubmitLeaderboard submits the given leaderboard submission to the database
	SubmitLeaderboard(submission LeaderboardSubmission) error
}

type EggWarsMap

type EggWarsMap struct {
	UniqueName string      `json:"unique_name"`
	MapName    string      `json:"map_name"`
	TeamSize   int         `json:"team_size"`
	Layout     MapLayout   `json:"layout"`
	Colours    string      `json:"colours"`
	BuildLimit int         `json:"build_limit"`
	Generators []Generator `json:"generators"`
}

type Game

type Game struct {
	Game        string   `json:"game"`
	DisplayName string   `json:"display_name"`
	Aliases     []string `json:"aliases"`
	Active      bool     `json:"active"`
	ScoreType   string   `json:"score_type"`
}

type GamesProvider

type GamesProvider interface {
	GetGame(game string) *Game
	GetGameDisplayName(s string) string
}

type GenLocation

type GenLocation string

type GenType

type GenType string

type Generator

type Generator struct {
	UniqueName string      `json:"unique_name"`
	Ordering   int         `json:"ordering"`
	Type       GenType     `json:"gen_type"`
	Location   GenLocation `json:"gen_location"`
	Level      int         `json:"level"`
	Count      int         `json:"count"`
}

type Holder

type Holder interface {
	GetDatabaseProvider() DatabaseProvider
	GetGamesProvider() GamesProvider
	GetPlayerLocationProvider() PlayerLocationProvider
}

type LeaderboardRow

type LeaderboardRow struct {
	Game          string `json:"game" validate:"nonzero,regexp=[a-zA-Z0-9_ ]"`
	Player        string `json:"player" validate:"nonzero,regexp=[a-zA-Z0-9_]{3\\,16}"`
	Position      int    `json:"position" validate:"nonzero,min=1,max=200"`
	Score         int    `json:"score" validate:"nonzero"`
	UnixTimeStamp int    `json:"unix_time_stamp"`
}

func (*LeaderboardRow) Value

func (row *LeaderboardRow) Value() (driver.Value, error)

type LeaderboardSubmission

type LeaderboardSubmission struct {
	Uuid          string           `json:"uuid" validate:"nonzero,regexp=^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"`
	UnixTimeStamp uint64           `json:"unix_time_stamp" validate:"nonzero"`
	Game          string           `json:"game" validate:"nonzero,regexp=[a-zA-Z0-9_ ]"`
	Entries       []LeaderboardRow `json:"entries" validate:"nonzero,len=200"`
}

type Location

type Location struct {
	Current    string `json:"current"`
	Previous   string `json:"previous"`
	InPreLobby bool   `json:"inPreLobby"`
}

type MapLayout

type MapLayout string
const (
	DOUBLE_CROSS MapLayout = "double_cross"
	TRIAGLE      MapLayout = "triangle"
	SQUARE       MapLayout = "square"
	CROSS        MapLayout = "cross"
)

type PlayerLocationProvider

type PlayerLocationProvider interface {
	// GetPlayerLocation returns the location of the player with the given UUID.
	GetPlayerLocation(uuid string) (*Location, error)

	// SetPlayerLocation sets the location of the player with the given UUID.
	SetPlayerLocation(uuid string, location Location) error

	// RemovePlayerLocation removes the location of the player with the given UUID.
	RemovePlayerLocation(uuid string) error

	// GetSharedPlayers returns the UUIDs of all players who have shared their location with the player with the given UUID.
	GetSharedPlayers(uuid string) ([]string, error)
}

type Season

type Season string

type Submission

type Submission struct {
	Uuid          string `json:"uuid"`
	UnixTimeStamp int    `json:"unix_time_stamp"`
	Game          string `json:"game"`
	Valid         bool   `json:"valid"`
}

Jump to

Keyboard shortcuts

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