players

package
v0.0.0-...-9af3b72 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthUser

func AuthUser(username string, password string) bool

func DeleteByUUID

func DeleteByUUID(uuid uuid.UUID) bool

func NotifyUser

func NotifyUser(name, email, subject, message string)

func OLDcreateUUIDs

func OLDcreateUUIDs(number int) []uuid.UUID

func StartEventProcessor

func StartEventProcessor() error

Types

type Complaint

type Complaint struct {
	From    *Player `json:"from"`
	Content string  `json:"content"`
}

A complaint from another player for harassment or similar

type Debt

type Debt struct {
	UUID        uuid.UUID `json:"uuid"`
	Debitor     uuid.UUID `json:"debitor"`
	Creditor    uuid.UUID `json:"creditor"`
	Description string    `json:"description"`
	Amount      int       `json:"amount"`
	Created     time.Time `json:"created"`
	Settled     time.Time `json:"settled"`
}

A debt to another player (hte creditor)

type DummyPlayerStorage

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

func NewDummyPlayerStorage

func NewDummyPlayerStorage() *DummyPlayerStorage

func (*DummyPlayerStorage) Delete

func (dps *DummyPlayerStorage) Delete(uuid uuid.UUID) error

func (*DummyPlayerStorage) Load

func (dps *DummyPlayerStorage) Load(uuid uuid.UUID) (*Player, error)

func (*DummyPlayerStorage) LoadAll

func (dps *DummyPlayerStorage) LoadAll() ([]*Player, error)

func (*DummyPlayerStorage) LoadUser

func (dps *DummyPlayerStorage) LoadUser(username string) (*User, error)

func (*DummyPlayerStorage) Store

func (dps *DummyPlayerStorage) Store(p *Player) error

type Player

type Player struct {
	UUID    uuid.UUID `json:"uuid"`
	Profile Profile   `json:"profile"`
	Nick    string    `json:"nick"`
	User    User      `json:"user"`
	Active  bool      `json:"active"`
	// Quotes are just strings set by other players
	Quotes []string `json:"quotes"`
	// Gossip is one string from each
	// of the other players, indexed by uuid as string
	Gossip     map[string]string `json:"gossip"`
	Complaints []Complaint       `json:"complaints"`
	Votes      Votes             `json:"votes"`
	// Debts where this player is the debitor
	Debts []Debt `json:"debts"`
}

A Player is a player in CKPT, current or former.o// It also contains a User.

func AllPlayers

func AllPlayers() ([]*Player, error)

func NewPlayer

func NewPlayer(nick string, profile Profile) (*Player, error)

Create a player

func PlayerByUUID

func PlayerByUUID(uuid uuid.UUID) (*Player, error)

func PlayerByUserToken

func PlayerByUserToken(token string) (*Player, error)

func (*Player) AddDebt

func (p *Player) AddDebt(d Debt) error

func (*Player) AddQuote

func (p *Player) AddQuote(q string) error

func (*Player) Credits

func (creditor *Player) Credits() ([]Debt, error)

func (*Player) DebtByUUID

func (p *Player) DebtByUUID(uuid uuid.UUID) (*Debt, error)

func (*Player) ResetDebt

func (p *Player) ResetDebt() error

func (*Player) ResetGossip

func (p *Player) ResetGossip() error

func (*Player) SetActive

func (p *Player) SetActive(active bool) error

func (*Player) SetGossip

func (p *Player) SetGossip(g map[string]string) error

func (*Player) SetNick

func (p *Player) SetNick(nick string) error

func (*Player) SetProfile

func (p *Player) SetProfile(profile Profile) error

func (*Player) SetUser

func (p *Player) SetUser(user User) error

func (*Player) SetUserAdmin

func (p *Player) SetUserAdmin(adminStatus bool) error

func (*Player) SetUserPassword

func (p *Player) SetUserPassword(password string) error

func (*Player) SetUserSettings

func (p *Player) SetUserSettings(settings UserSettings) error

func (*Player) SetVotes

func (p *Player) SetVotes(v Votes) error

func (*Player) SettleDebt

func (p *Player) SettleDebt(debtuuid uuid.UUID) error

type PlayerStorage

type PlayerStorage interface {
	Store(*Player) error
	Delete(uuid.UUID) error
	Load(uuid.UUID) (*Player, error)
	LoadAll() ([]*Player, error)
	LoadUser(username string) (*User, error)
}

A storage interface for Players

type Profile

type Profile struct {
	Name        string    `json:"name"`
	Picture     []byte    `json:"picture"`
	Birthday    time.Time `json:"birthday"`
	Email       string    `json:"email"`
	Description string    `json:"description"`
	Allergies   string    `json:"allergies"`
}

The basic profile of the player

type RedisPlayerStorage

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

func NewRedisPlayerStorage

func NewRedisPlayerStorage() *RedisPlayerStorage

func (*RedisPlayerStorage) Delete

func (rps *RedisPlayerStorage) Delete(uuid uuid.UUID) error

func (*RedisPlayerStorage) Load

func (rps *RedisPlayerStorage) Load(uuid uuid.UUID) (*Player, error)

func (*RedisPlayerStorage) LoadAll

func (rps *RedisPlayerStorage) LoadAll() ([]*Player, error)

func (*RedisPlayerStorage) LoadUser

func (rps *RedisPlayerStorage) LoadUser(username string) (*User, error)

func (*RedisPlayerStorage) Store

func (rps *RedisPlayerStorage) Store(p *Player) error

type User

type User struct {
	Username string `json:"username"`

	Apikey   string       `json:"apikey"`
	Admin    bool         `json:"admin"`
	Locked   bool         `json:"locked"`
	Settings UserSettings `json:"settings"`
	// contains filtered or unexported fields
}

The user associated with a player

func NewUser

func NewUser(player uuid.UUID, userdata *User) (*User, error)

Create a user

func UserByName

func UserByName(username string) (*User, error)

func (*User) SubscribedTo

func (u *User) SubscribedTo(et string) bool

type UserSettings

type UserSettings struct {
	Notifications map[string]bool `json:"notifications"`
}

The user preferences/settings of the user

type Votes

type Votes struct {
	Winner uuid.UUID `json:"winner"`
	Loser  uuid.UUID `json:"loser"`
}

Jump to

Keyboard shortcuts

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