models

package
v0.0.0-...-afdb705 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePacket

func CreatePacket(command string, v any) []byte

Types

type Answer

type Answer struct {
	Artist   string `json:"artist"`
	Song     string `json:"song"`
	AnswerID int    `json:"answerId"`
}

type Competitor

type Competitor struct {
	Id    int `gorm:"primaryKey" json:"id"`
	Score int `gorm:"not null" json:"score"`
}

type GameState

type GameState int
const (
	Waiting  GameState = iota // 0
	Guessing                  // 1
	Results                   // 2
	Finish                    // 3
)

func (GameState) String

func (g GameState) String() string

type Leaderboard

type Leaderboard struct {
	Scores []ScoreEntry `json:"scores"`
}

type Lobbies

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

func (*Lobbies) Add

func (l *Lobbies) Add(lo *Lobby)

func (*Lobbies) Exists

func (l *Lobbies) Exists(id string) bool

func (*Lobbies) Get

func (l *Lobbies) Get(id string) *Lobby

func (*Lobbies) RemoveLobby

func (l *Lobbies) RemoveLobby(lo *Lobby)

type Lobby

type Lobby struct {
	Host       string         `json:"-"`
	LobbyId    string         `json:"lobbyId"`
	PlayerList []*Player      `json:"players"`
	Points     map[string]int `json:"points"`
	State      GameState      `json:"-"`
	Guesses    map[string]int `json:"-"` // Index
	Questions  []Question     `json:"-"`
	Round      int            `json:"-"`
	Timer      *time.Timer    `json:"-"`
	// contains filtered or unexported fields
}

func (*Lobby) AddPlayer

func (l *Lobby) AddPlayer(p *Player)

func (*Lobby) BroadcastToAllPlayers

func (l *Lobby) BroadcastToAllPlayers(m []byte)

func (*Lobby) CreateLeaderboard

func (l *Lobby) CreateLeaderboard() Leaderboard

func (*Lobby) GenerateQuiz

func (l *Lobby) GenerateQuiz(length int) []Question

ONLY CALL THIS ONCE SPOTIFY API SLOW

func (*Lobby) GenerateQuizSongs

func (l *Lobby) GenerateQuizSongs(length int) ([]spotify.FullTrack, []spotify.FullTrack)

func (*Lobby) HasPlayer

func (l *Lobby) HasPlayer(p *Player) bool

func (*Lobby) RemovePlayer

func (l *Lobby) RemovePlayer(p *Player)

type Packet

type Packet struct {
	Command string `json:"command"`
	Body    any    `json:"body"`
}

type Player

type Player struct {
	*User       `json:"-"`
	Client      *spotify.Client `json:"-"`
	DisplayName string          `json:"displayName"`
	IconURL     string          `json:"iconURL"`
	Carousel    []string        `json:"carousel"`
	Conn        *websocket.Conn `json:"-"`
}

type Question

type Question struct {
	Question string   `json:"question"`
	Answers  []Answer `json:"answers"`
	Correct  int      `json:"correct"`
}

type ScoreEntry

type ScoreEntry struct {
	PlayerName string `json:"playerName"`
	IconURL    string `json:"iconURL"`
	Score      int    `json:"score"`
}

type User

type User struct {
	UUID  string
	Token *oauth2.Token
}

type Users

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

func (*Users) Add

func (u *Users) Add(n *User)

func (*Users) Exists

func (u *Users) Exists(uuid string) bool

func (*Users) Get

func (u *Users) Get(uuid string) *User

Jump to

Keyboard shortcuts

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