Documentation
¶
Index ¶
- Variables
- func Configure(database *gorm.DB) (*gorm.DB, error)
- func LoadFromConfig() (*gorm.DB, error)
- func UserExistById(db *gorm.DB, id uint) (bool, error)
- func UserExistByUsername(db *gorm.DB, username string) (bool, error)
- type Claims
- type Player
- type PlayerState
- type Profile
- type Role
- type Room
- func (r *Room) Attribute() *sync.Map
- func (r *Room) CreateByHost(db *gorm.DB, host *Player) error
- func (r *Room) Do(f func())
- func (r *Room) DoAndWait(f func())
- func (r *Room) EventHostId() string
- func (r *Room) Exit(db *gorm.DB, p *Player) error
- func (r *Room) FindByID(db *gorm.DB, id uint) error
- func (r *Room) FindByUserID(db *gorm.DB, id uint) error
- func (r *Room) FindHost() *Player
- func (r *Room) FindPlayer(f func(p *Player) bool) (*Player, bool)
- func (r *Room) FindPlayerBySeat(seat uint) (*Player, bool)
- func (r *Room) FindSeatByPlayer(userId uint) int
- func (r *Room) GetNextSeat() (uint, bool)
- func (r *Room) IsAllReady() bool
- func (r *Room) Join(db *gorm.DB, p *Player) error
- func (r *Room) Listen() space.Subscription
- func (r *Room) RemovePlayer(userId uint)
- func (r *Room) SendEvent(e space.Message)
- func (r *Room) SwapSeat(db *gorm.DB, a, b uint) error
- type RowBound
- type Sex
- type StringMap
- type User
- func (user *User) ChangePassword(db *gorm.DB, old, new string) error
- func (user *User) CreateAccount(db *gorm.DB) error
- func (user *User) FindByID(db *gorm.DB, id uint) error
- func (user *User) FindByUsername(db *gorm.DB, username string) error
- func (user *User) GenerateToken(key string) (string, error)
- func (user *User) GetRoleStrings() []string
- func (user *User) MatchPassword(pwd string) bool
- func (user *User) SetRoles(roles []string)
Constants ¶
This section is empty.
Variables ¶
View Source
var Unbound = RowBound{math.MaxInt32, 0}
Functions ¶
func LoadFromConfig ¶
Types ¶
type Player ¶
type Player struct { UserID uint `gorm:"primary_key"` RoomID uint `gorm:"default:0"` Room *Room `gorm:"-"` //gorm can't handle this, need put manually State PlayerState `gorm:"default:0"` Seat uint `gorm:"default:0"` }
type PlayerState ¶
type PlayerState uint
const ( OUT_OF_GAME PlayerState = 0 NOT_READY PlayerState = 1 READY PlayerState = 2 HOST PlayerState = 3 )
func (PlayerState) String ¶
func (s PlayerState) String() string
type Profile ¶
func EmptyProfile ¶
type Room ¶
type Room struct { ID uint `gorm:"primary_key"` GameId string PlayerCount uint RoomName string CreatedTime time.Time Players []*Player Options *StringMap `gorm:"type:json"` }
func FindRoomsByGame ¶
func (*Room) EventHostId ¶
func (*Room) FindSeatByPlayer ¶
func (*Room) GetNextSeat ¶
func (*Room) IsAllReady ¶
func (*Room) Listen ¶
func (r *Room) Listen() space.Subscription
func (*Room) RemovePlayer ¶
type User ¶
type User struct { ID uint `gorm:"primary_key"` Username string `gorm:"unique;not null"` Password string Roles []Role }
func (*User) GetRoleStrings ¶
func (*User) MatchPassword ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.