session

package
v0.0.0-...-6fa8ed0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(r *gin.RouterGroup, service *SessionService)

Types

type CreateSessionRequest

type CreateSessionRequest struct {
	ServerId int `json:"server_id" binding:"required"`
	MapId    int `json:"map_id" binding:"required"`

	Mode       models.GameMode       `json:"mode" binding:"required"`
	Length     int                   `json:"length" binding:"required"`
	Difficulty models.GameDifficulty `json:"diff" binding:"required"`
}

type CreateSessionResponse

type CreateSessionResponse struct {
	Id int `json:"id"`
}

type PlayerLiveData

type PlayerLiveData struct {
	AuthId   string          `json:"auth_id"`
	AuthType models.AuthType `json:"auth_type"`
	Name     string          `json:"name"`

	Perk     models.Perk `json:"perk"`
	Level    int         `json:"level"`
	Prestige int         `json:"prestige"`

	Health int `json:"health"`
	Armor  int `json:"armor"`

	IsSpectator bool `json:"is_spectator"`
}

type Session

type Session struct {
	Id       int `json:"id"`
	ServerId int `json:"server_id"`
	MapId    int `json:"map_id"`

	Mode       models.GameMode       `json:"mode"`
	Length     int                   `json:"length"`
	Difficulty models.GameDifficulty `json:"diff"`

	Status models.GameStatus `json:"status"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	StartedAt   *time.Time `json:"started_at"`
	CompletedAt *time.Time `json:"completed_at"`
}

type SessionService

type SessionService struct {
	// contains filtered or unexported fields
}

func NewSessionService

func NewSessionService(db *sql.DB) *SessionService

func (*SessionService) Create

func (s *SessionService) Create(req CreateSessionRequest) (int, error)

func (*SessionService) GetById

func (s *SessionService) GetById(id int) (*Session, error)

func (*SessionService) GetCDData

func (s *SessionService) GetCDData(id int) (*models.CDGameData, error)

func (*SessionService) GetGameData

func (s *SessionService) GetGameData(id int) (*models.GameData, error)

func (*SessionService) UpdateGameData

func (s *SessionService) UpdateGameData(data UpdateGameDataRequest) error

func (*SessionService) UpdateStatus

func (s *SessionService) UpdateStatus(data UpdateStatusRequest) error

type UpdateGameDataRequest

type UpdateGameDataRequest struct {
	SessionId int `json:"session_id"`

	GameData models.GameData    `json:"game_data"`
	CDData   *models.CDGameData `json:"cd_data"`

	Players []PlayerLiveData `json:"players"`
}

type UpdateStatusRequest

type UpdateStatusRequest struct {
	Id     int `json:"id" binding:"required"`
	Status int `json:"status" binding:"required"`
}

Jump to

Keyboard shortcuts

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