data

package
v0.0.0-...-b98aa62 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ability

type Ability struct {
	ID           int            `db:"id"`
	Name         string         `db:"name"`
	Description  string         `db:"description"`
	Charges      int            `db:"charges"`
	AnyAbility   bool           `db:"any_ability"`
	RoleSpecific string         `db:"role_specific"`
	Categories   pq.StringArray `db:"categories"`
}

type AbilityModel

type AbilityModel struct {
	*sqlx.DB
}

type ComplexPlayer

type ComplexPlayer struct {
	P Player `db:"players"`
	R Role   `db:"roles"`
}

ComplexPlayer is a player with a role

type ComplexRole

type ComplexRole struct {
	ID        int        `db:"id"`
	Name      string     `db:"name"`
	Alignment string     `db:"alignment"`
	Abilities []*Ability `db:"abilities"`
	Passives  []*Passive `db:"passives"`
}

type Game

type Game struct {
	ID          int    `json:"id" db:"id"`
	GameID      string `json:"game_id" db:"game_id"`
	PlayerCount int    `json:"player_count" db:"player_count"`
	CreatedAt   string `json:"created_at" db:"created_at"`
	UpdatedAt   string `json:"updated_at" db:"updated_at"`
}

type GameModel

type GameModel struct {
	*sqlx.DB
}

func (*GameModel) DeleteGame

func (gm *GameModel) DeleteGame(gID string) error

func (*GameModel) GetAll

func (gm *GameModel) GetAll() ([]Game, error)

func (*GameModel) GetByGameID

func (gm *GameModel) GetByGameID(gID string) (*Game, error)

func (*GameModel) GetByID

func (gm *GameModel) GetByID(id int) (*Game, error)

func (*GameModel) InsertGame

func (gm *GameModel) InsertGame(gameID string, playerCount int) (*Game, error)

func (*GameModel) Update

func (gm *GameModel) Update(game *Game) error

func (*GameModel) UpdatePlayerCount

func (gm *GameModel) UpdatePlayerCount(gID string, playerCount int) error

type Models

type Models struct {
	Games     GameModel
	Players   PlayerModel
	Roles     RoleModel
	Abilities AbilityModel
	Passives  PassiveModel
}

func NewModels

func NewModels(db *sqlx.DB) *Models

type Passive

type Passive struct {
	ID          int    `db:"id"`
	Name        string `db:"name"`
	Description string `db:"description"`
}

type PassiveModel

type PassiveModel struct {
	*sqlx.DB
}

type Player

type Player struct {
	ID           int    `db:"id"`
	Name         string `db:"name"`
	GameID       string `db:"game_id"`
	RoleID       int    `db:"role_id"`
	Alive        bool   `db:"alive"`
	Seat         int    `db:"seat"`
	Luck         int    `db:"luck"`
	LuckModifier int    `db:"luck_modifier"`
	CreatedAt    string `db:"created_at"`
	UpdatedAt    string `db:"updated_at"`
}

type PlayerModel

type PlayerModel struct {
	DB *sqlx.DB
}

func (*PlayerModel) Create

func (m *PlayerModel) Create(player *Player) error

func (*PlayerModel) Delete

func (m *PlayerModel) Delete(id int) error

func (*PlayerModel) GetByGameID

func (m *PlayerModel) GetByGameID(gameID string) ([]*Player, error)

func (*PlayerModel) GetByGameIDAndName

func (m *PlayerModel) GetByGameIDAndName(gameID string, name string) (*Player, error)

func (*PlayerModel) GetByID

func (m *PlayerModel) GetByID(id int) (*Player, error)

func (*PlayerModel) GetByName

func (m *PlayerModel) GetByName(name string) (*Player, error)

func (*PlayerModel) GetComplexByGameID

func (m *PlayerModel) GetComplexByGameID(gameID string) ([]*ComplexPlayer, error)

func (*PlayerModel) GetRole

func (m *PlayerModel) GetRole(roleID int) (*Role, error)

func (*PlayerModel) Update

func (m *PlayerModel) Update(player *Player) error

type Role

type Role struct {
	ID         int           `db:"id"`
	Name       string        `db:"name"`
	Alignment  string        `db:"alignment"`
	AbilityIDs pq.Int32Array `db:"ability_ids"`
	PassiveIDs pq.Int32Array `db:"passive_ids"`
}

type RoleModel

type RoleModel struct {
	*sqlx.DB
}

func (*RoleModel) Get

func (rm *RoleModel) Get(id int) (*Role, error)

func (*RoleModel) GetAll

func (rm *RoleModel) GetAll() ([]*Role, error)

func (*RoleModel) GetByName

func (rm *RoleModel) GetByName(name string) (*Role, error)

func (*RoleModel) GetComplex

func (rm *RoleModel) GetComplex(id int) (*ComplexRole, error)

func (*RoleModel) GetComplexByName

func (rm *RoleModel) GetComplexByName(name string) (*ComplexRole, error)

Jump to

Keyboard shortcuts

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