model

package
v0.0.0-...-693af1c Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BonusTilePattern

type BonusTilePattern string
const (
	None    BonusTilePattern = "none"
	Regular BonusTilePattern = "regular"
	Stripe  BonusTilePattern = "stripe"
	Border  BonusTilePattern = "border"
)

type DisplayUser

type DisplayUser struct {
	ID   *uint32 `gorm:"primarykey" json:"id"`
	Name string  `json:"name"`
}

func (*DisplayUser) TableName

func (du *DisplayUser) TableName() string

type GameType

type GameType struct {
	ID   uint32 `gorm:"primarykey" json:"id"`
	Name string `json:"name"`
	// The number of tiles in the bag at the start of the game
	TileBagSize int `gorm:"default:100" json:"tileBagSize"`
	// The size of a player's tile deck
	PlayerDeckSize int `gorm:"default:9" json:"playerDeckSize"`
	// The number of tiles a player gets replenished to at the end of a turn
	PlayerTileCount int `gorm:"default:7" json:"playerTileCount"`
	// If blank tiles are given out
	EnableBlankTiles bool `gorm:"default:true" json:"enableBlankTiles"`
	// The width of the main board
	BoardWidth int `gorm:"default:15" json:"boardWidth"`
	// The height of the main board
	BoardHeight int `gorm:"default:15" json:"boardHeight"`
	// The pattern to generate bonus tiles in
	BonusTilePattern BonusTilePattern `gorm:"default:'regular'" json:"bonusTilePattern"`
	// If the first player has to start in the center
	StartAnywhere bool `gorm:"default:false" json:"startAnywhere"`
	// If the GameType is selectable by others
	Visible bool `gorm:"default:true" json:"-"`
}

type Lobby

type Lobby struct {
	ID *int64 `gorm:"primarykey" json:"-"`
	// Poor JS gets upset with numbers this big, so we need to pass it as a string rather than an int64
	IdStr          string            `gorm:"-" json:"id"`
	Name           string            `json:"name"`
	CreatorID      *uint32           `json:"creatorId"`
	CreatedAt      time.Time         `json:"createdAt"`
	State          entity.LobbyState `json:"state"`
	Private        bool              `json:"private"`
	Joinable       bool              `json:"joinable"`
	CurrentPlayers uint8             `json:"currentPlayers"`
	MaxPlayers     uint8             `json:"maxPlayers"`
	GameTypeID     uint32            `json:"-"`
	PlayerTurnID   *uint32           `json:"playerTurnId"`
	GameType       GameType          `json:"gameType"`
	Members        []LobbyMember     `json:"-" gorm:"constraint:OnDelete:CASCADE;"`
	Messages       []Message         `json:"-" gorm:"constraint:OnDelete:CASCADE;"`
	Creator        DisplayUser       `json:"creator" gorm:"foreignKey:id;references:creator_id"`
	Board          entity.SquareSet  `json:"-"`
	Bag            entity.SquareSet  `json:"-"`
}

type LobbyMember

type LobbyMember struct {
	UserID     uint32              `gorm:"primaryKey;autoIncrement:false" json:"id"`
	LobbyID    int64               `gorm:"primaryKey;autoIncrement:false;constraint:OnDelete:CASCADE;" json:"-"`
	LobbyIDStr string              `gorm:"-" json:"lobbyId"`
	MemberType constant.MemberType `json:"type"`
	User       *DisplayUser        `json:"user,omitempty"`
	Deck       entity.SquareSet    `json:"-"`
	JoinedAt   time.Time           `gorm:"default:CURRENT_TIMESTAMP" json:"joined"`
	Score      int                 `json:"score" gorm:"default:0"`
}

type Message

type Message struct {
	ID        *int64 `gorm:"primarykey" json:"id"`
	AuthorID  *uint32
	LobbyID   *int64
	Message   string
	Timestamp time.Time
	Author    User
}

type User

type User struct {
	ID               *uint32               `gorm:"primarykey" json:"id"`
	Name             string                `json:"name"`
	CreatedAt        time.Time             `json:"createdAt"`
	UpdatedAt        time.Time             `json:"updatedAt"`
	LastActive       time.Time             `gorm:"default:CURRENT_TIMESTAMP" json:"lastActive"`
	Credentials      datatypes.JSON        `gorm:"type:json" gob:"-" json:"-"`
	CredentialsObj   []webauthn.Credential `gorm:"-" gob:"-" json:"-"`
	LobbyMemberships *[]LobbyMember        `json:"memberships" gob:"-"  gorm:"foreignKey:user_id;references:id"`
}

func (*User) Exists

func (u *User) Exists(db *gorm.DB) bool

func (*User) WebAuthnCredentials

func (u *User) WebAuthnCredentials() []webauthn.Credential

func (*User) WebAuthnDisplayName

func (u *User) WebAuthnDisplayName() string

func (*User) WebAuthnID

func (u *User) WebAuthnID() []byte

func (*User) WebAuthnIcon

func (u *User) WebAuthnIcon() string

func (*User) WebAuthnName

func (u *User) WebAuthnName() string

Jump to

Keyboard shortcuts

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