models

package
v0.0.0-...-f589a8a Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const RollLogSeparator = "[ ~~~ ROLL LOG SEPARATOR ~~~]"
View Source
const RollResultSeparator = "[ ~~~ ROLL RESULT SEPARATOR ~~~]"

Variables

This section is empty.

Functions

func GenerateAPIKey

func GenerateAPIKey() (string, string, error)

func GenerateID

func GenerateID() string

func GetAbility

func GetAbility(char Character, ability string) int

func GetFortitude

func GetFortitude(char Character) int

func GetReflexes

func GetReflexes(char Character) int

func GetWill

func GetWill(char Character) int

func IsIDUnique

func IsIDUnique(tx *gorm.DB, model interface{}, id string) bool

func IsValidAbility

func IsValidAbility(ability string) bool

func SetVerificationCode

func SetVerificationCode(email *Email)

func UniqueIDBeforeCreate

func UniqueIDBeforeCreate(tx *gorm.DB, model interface{}, id *string) error

Types

type Campaign

type Campaign struct {
	gorm.Model
	Slug        string      `json:"slug"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	GMs         []User      `gorm:"many2many:campaign_gms;" json:"gms"`
	PCs         []Character `gorm:"many2many:campaign_pcs;" json:"pcs"`
	Public      bool        `json:"public"`
	WorldID     uint        `json:"world_id"`
	World       World       `gorm:"foreignKey:WorldID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"world"`
}

type Character

type Character struct {
	ID string `gorm:"primaryKey" json:"id"`
	gorm.Model
	Name        string `json:"name"`
	Description string `json:"description"`
	Str         int    `json:"strength"`
	Dex         int    `json:"dexterity"`
	Con         int    `json:"constitution"`
	Int         int    `json:"intelligence"`
	Wis         int    `json:"wisdom"`
	Cha         int    `json:"charisma"`
	Notes       string `json:"notes"`
	PC          bool   `json:"pc"`
	Public      bool   `json:"public"`
	PlayerID    uint   `json:"player_id"`
	Player      User   `gorm:"foreignKey:PlayerID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"player"`
}

func (*Character) BeforeCreate

func (char *Character) BeforeCreate(tx *gorm.DB) (err error)

type Email

type Email struct {
	gorm.Model
	Address  string `json:"address"`
	Code     string `json:"code"`
	Verified bool   `json:"verified"`
	UserID   uint   `json:"user_id"`
	User     User   `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"user"`
}

type Key

type Key struct {
	gorm.Model
	Label     string `json:"label"`
	Token     string `gorm:"uniqueIndex" json:"-"`
	Secret    string `json:"-"`
	Ephemeral bool   `json:"ephemeral"`
	UserID    uint   `json:"user_id"`
	User      User   `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"user"`
}

type Level

type Level struct {
	gorm.Model
	Order       int    `json:"order"`
	Name        string `json:"name"`
	Description string `json:"description"`
	ScaleID     uint   `json:"scale_id"`
}

type Roll

type Roll struct {
	ID string `gorm:"primaryKey" json:"id"`
	gorm.Model
	Note        *string    `json:"note"`
	TableID     uint       `json:"table_id"`
	Table       Table      `gorm:"foreignKey:TableID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"table"`
	RollerID    *uint      `json:"roller_id,omitempty"`
	Roller      *User      `gorm:"foreignKey:RollerID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"roller,omitempty"`
	CharacterID *string    `json:"character_id,omitempty"`
	Character   *Character `gorm:"foreignKey:CharacterID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"character,omitempty"`
	Ability     *string    `json:"ability,omitempty"`
	CampaignID  *uint      `json:"campaign_id,omitempty"`
	Campaign    *Campaign  `gorm:"foreignKey:CampaignID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"campaign,omitempty"`
	Modifier    int        `json:"modifier"`
	Log         string     `json:"log"`
	Results     string     `json:"result"`
}

func (*Roll) BeforeCreate

func (roll *Roll) BeforeCreate(tx *gorm.DB) (err error)

type Scale

type Scale struct {
	gorm.Model
	Name        string  `json:"name"`
	Slug        string  `json:"slug"`
	Description string  `json:"description"`
	Public      bool    `json:"public"`
	Levels      []Level `gorm:"foreignKey:ScaleID" json:"levels"`
	AuthorID    uint    `json:"author_id"`
	Author      User    `gorm:"foreignKey:AuthorID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"author"`
}

type Scroll

type Scroll struct {
	ID string `gorm:"primaryKey" json:"id"`
	gorm.Model
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Seals       uint      `json:"seals"`
	Writers     []User    `gorm:"many2many:scroll_writers;" json:"writers"`
	Readers     []User    `gorm:"many2many:scroll_readers;" json:"readers"`
	Public      bool      `json:"active" json:"public"`
	CampaignID  *uint     `json:"campaign_id"`
	Campaign    *Campaign `gorm:"foreignKey:CampaignID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"campaign"`
}

func (*Scroll) BeforeCreate

func (scroll *Scroll) BeforeCreate(tx *gorm.DB) (err error)

type Society

type Society struct {
	gorm.Model
	Slug        string            `gorm:"unique" json:"slug"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Favored     enums.AbilityPair `gorm:"type:string" json:"favored"`
	Languages   string            `json:"languages"`
	Public      bool              `json:"public"`
	WorldID     uint              `json:"world_id"`
	World       World             `gorm:"foreignKey:WorldID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"world"`
}

func (*Society) BeforeSave

func (society *Society) BeforeSave(tx *gorm.DB) (err error)

func (Society) TableName

func (Society) TableName() string

type Species

type Species struct {
	gorm.Model
	Slug        string            `gorm:"unique" json:"slug"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Affinities  enums.AbilityPair `gorm:"type:string" json:"affinities"`
	Aversion    enums.Ability     `gorm:"type:string" json:"aversion"`
	Stages      []Stage           `gorm:"foreignKey:SpeciesID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"stages"`
	Public      bool              `json:"public"`
	WorldID     uint              `json:"world_id"`
	World       World             `gorm:"foreignKey:WorldID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"world"`
}

func (*Species) BeforeSave

func (species *Species) BeforeSave(tx *gorm.DB) (err error)

type Stage

type Stage struct {
	gorm.Model
	Name       string `json:"name"`
	Procedures string `json:"procedures"`
	MinAge     *uint  `json:"min"`
	MaxAge     *uint  `json:"max"`
	SpeciesID  uint   `json:"species_id"`
}

type Table

type Table struct {
	gorm.Model
	Name        string     `json:"name"`
	Slug        string     `json:"slug"`
	Description string     `json:"description"`
	DiceLabel   string     `json:"dice_label"`
	Formula     string     `json:"formula"`
	Ability     *string    `json:"ability,omitempty"`
	Cumulative  bool       `json:"cumulative"`
	Rows        []TableRow `gorm:"foreignKey:TableID" json:"rows"`
	Public      bool       `json:"public"`
	AuthorID    uint       `json:"author_id"`
	Author      User       `gorm:"foreignKey:AuthorID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"author"`
}

type TableRow

type TableRow struct {
	gorm.Model
	Min     *int    `json:"min"`
	Max     *int    `json:"max"`
	Text    string  `json:"text"`
	Formula *string `json:"formula"`
	TableID uint    `json:"table_id"`
}

type User

type User struct {
	gorm.Model
	Username string `gorm:"uniqueIndex" json:"username"`
	Password string `json:"-"`
	Name     string `json:"name"`
	Bio      string `json:"bio"`
	Active   bool   `json:"active"`
}

type World

type World struct {
	gorm.Model
	Slug        string `gorm:"unique" json:"slug"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Creators    []User `gorm:"many2many:world_creators;" json:"creators"`
	Public      bool   `json:"active" json:"public"`
}

Jump to

Keyboard shortcuts

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