entity

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: AGPL-3.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MaxNameLength is the maximum length that a proto message can be.
	MaxNameLength = 64

	DefaultSerializationProtocol = EvtSerializationProtoWithHeader
)
View Source
const (
	AudGame        EventAudienceType = "game"
	AudGameTV                        = "gametv"
	AudUser                          = "user"
	AudLobby                         = "lobby"
	AudTournament                    = "tournament"
	AudBotCommands                   = "bot.commands"
	// AudChannel is used for a general channel.
	AudChannel = "channel"
)
View Source
const (
	CrosswordGame string = "CrosswordGame"

	LargeTime int = 1000000000
)
View Source
const (
	KnowledgeMistakeType = "knowledge"
	FindingMistakeType   = "finding"
	VisionMistakeType    = "vision"
	TacticsMistakeType   = "tactics"
	StrategyMistakeType  = "strategy"
	TimeMistakeType      = "time"
	EndgameMistakeType   = "endgame"
)
View Source
const (
	LargeMistakeMagnitude  = "large"
	MediumMistakeMagnitude = "medium"
	SmallMistakeMagnitude  = "small"

	SaddestMistakeMagnitude = "saddest"
	SadderMistakeMagnitude  = "sadder"
	SadMistakeMagnitude     = "sad"

	UnspecifiedMistakeMagnitude = "unspecified"
)
View Source
const (
	ALL_TRIPLE_LETTERS_COVERED_STAT        string = "All Triple Letter Squares Covered"
	ALL_TRIPLE_WORDS_COVERED_STAT          string = "All Triple Word Squares Covered"
	BINGOS_STAT                            string = "Bingos"
	CHALLENGED_PHONIES_STAT                string = "Challenged Phonies"
	CHALLENGES_LOST_STAT                   string = "Challenges Lost"
	CHALLENGES_WON_STAT                    string = "Challenges Won"
	COMMENTS_STAT                          string = "Comments"
	DRAWS_STAT                             string = "Draws"
	EXCHANGES_STAT                         string = "Exchanges"
	FIRSTS_STAT                            string = "Firsts"
	GAMES_STAT                             string = "Games"
	HIGH_GAME_STAT                         string = "High Game"
	HIGH_TURN_STAT                         string = "High Turn"
	LOSSES_STAT                            string = "Losses"
	LOW_GAME_STAT                          string = "Low Game"
	NO_BINGOS_STAT                         string = "Games with no Bingos"
	MANY_DOUBLE_LETTERS_COVERED_STAT       string = "Many Double Letter Squares Covered"
	MANY_DOUBLE_WORDS_COVERED_STAT         string = "Many Double Word Squares Covered"
	MISTAKES_STAT                          string = "Mistakes"
	SCORE_STAT                             string = "Score"
	RATINGS_STAT                           string = "Ratings"
	TILES_PLAYED_STAT                      string = "Tiles Played"
	TIME_STAT                              string = "Time Taken"
	TRIPLE_TRIPLES_STAT                    string = "Triple Triples"
	TURNS_STAT                             string = "Turns"
	TURNS_WITH_BLANK_STAT                  string = "Turns With Blank"
	UNCHALLENGED_PHONIES_STAT              string = "Unchallenged Phonies"
	VALID_PLAYS_THAT_WERE_CHALLENGED_STAT  string = "Valid Plays That Were Challenged"
	VERTICAL_OPENINGS_STAT                 string = "Vertical Openings"
	WINS_STAT                              string = "Wins"
	NO_BLANKS_PLAYED_STAT                  string = "No Blanks Played"
	HIGH_SCORING_STAT                      string = "High Scoring"
	COMBINED_HIGH_SCORING_STAT             string = "Combined High Scoring"
	COMBINED_LOW_SCORING_STAT              string = "Combined Low Scoring"
	ONE_PLAYER_PLAYS_EVERY_POWER_TILE_STAT string = "One Player Plays Every Power Tile"
	ONE_PLAYER_PLAYS_EVERY_E_STAT          string = "One Player Plays Every E"
	MANY_CHALLENGES_STAT                   string = "Many Challenges"
	FOUR_OR_MORE_CONSECUTIVE_BINGOS_STAT   string = "Four or More Consecutive Bingos"
)
View Source
const (
	// TypeStandard is a standard tournament
	TypeStandard CompetitionType = "tournament"
	// TypeClub is a club/clubhouse
	TypeClub = "club"
	// TypeChild is spawned from a club or tournament
	TypeChild = "child"
	// TypeLegacy is a tournament, but in club/clubhouse mode. The only different
	// from a clubhouse is that it can have a /tournament URL.
	TypeLegacy = "legacy"
)
View Source
const (
	ByeScore     int = 50
	ForfeitScore int = -50
)
View Source
const (
	AuthMethodCookie = "cookie"
	AuthMethodAPIKey = "apikey"
)
View Source
const (
	TCRegular    TimeControl = "regular"    // > 14/0
	TCRapid                  = "rapid"      // 6/0 to <= 14/0
	TCBlitz                  = "blitz"      // > 2/0 to < 6/0
	TCUltraBlitz             = "ultrablitz" // 2/0 and under
	TCCorres                 = "corres"
)
View Source
const (
	// Cutoffs in seconds for different time controls.
	CutoffUltraBlitz = 2 * 60
	CutoffBlitz      = 6 * 60
	CutoffRapid      = 14 * 60
)
View Source
const DifferencePenalty = 1

These constants control the swiss weighing function

View Source
const DifferencePenaltyMargin = 2
View Source
const MaxNotableInt = 1000000000
View Source
const MaxRelativeWeight int = 100
View Source
const ProhibitiveWeight int64 = 1 << 52
View Source
const PuzzleVariant = "puzzle"
View Source
const RatingDeviationConfidence = float64(glicko.MinimumRatingDeviation + 30)

If the RD is <= this number, the rating is "known"

View Source
const (
	// SessionExpiration - Expire a session after this much time.
	SessionExpiration = time.Hour * 24 * 30
)
View Source
const WinWeightScaling int64 = 1 << 22
View Source
const WooglesErrorDelimiter = ";"

Variables

View Source
var AllowedNewGameLexica []string

Functions

func InferChildStatus

func InferChildStatus(dob string, now time.Time) pb.ChildStatus

func IsAdult

func IsAdult(dob string, now time.Time) bool

func LastOutstandingMetaRequest

func LastOutstandingMetaRequest(evts []*pb.GameMetaEvent, uid string, now int64) *pb.GameMetaEvent

LastOutstandingMetaRequest returns the last meta request that has not yet been responded to. If a user ID is passed in, it only returns that user's last request, if it exists. If no such event exists, it returns nil.

func RelevantRating

func RelevantRating(ratings Ratings, ratingKey VariantKey) string

RelevantRating returns the rating from a Ratings object given a rating key.

func TotalTimeEstimate

func TotalTimeEstimate(gamereq *pb.GameRequest) int32

TotalTimeEstimate estimates the amount of time this game will take, per side.

func ValidateGameRequest

func ValidateGameRequest(ctx context.Context, req *pb.GameRequest) error

ValidateGameRequest validates a generic game request.

Types

type Actions

type Actions struct {
	Current map[string]*ms.ModAction
	History []*ms.ModAction
}

DEPRECATED: use db actions

type AuthMethod

type AuthMethod string

type CompetitionType

type CompetitionType string

type DivisionManager

type DivisionManager interface {
	SubmitResult(int, string, string, int, int, pb.TournamentGameResult,
		pb.TournamentGameResult, pb.GameEndReason, bool, int, string) (*pb.DivisionPairingsResponse, error)
	PairRound(int, bool) (*pb.DivisionPairingsResponse, error)
	DeletePairings(int) error
	GetStandings(int) (*pb.RoundStandings, int, error)
	GetCurrentRound() int
	GetPlayers() *pb.TournamentPersons
	SetPairing(string, string, int, pb.TournamentGameResult) (*pb.DivisionPairingsResponse, error)
	SetSingleRoundControls(int, *pb.RoundControl) (*pb.RoundControl, error)
	SetRoundControls([]*pb.RoundControl) (*pb.DivisionPairingsResponse, []*pb.RoundControl, error)
	SetDivisionControls(*pb.DivisionControls) (*pb.DivisionControls, map[int32]*pb.RoundStandings, error)
	GetDivisionControls() *pb.DivisionControls
	AddPlayers(*pb.TournamentPersons) (*pb.DivisionPairingsResponse, error)
	RemovePlayers(*pb.TournamentPersons) (*pb.DivisionPairingsResponse, error)
	IsRoundReady(int) error
	IsRoundComplete(int) (bool, error)
	IsStarted() bool
	IsFinished() (bool, error)
	StartRound(bool) error
	IsRoundStartable() error
	GetXHRResponse() (*pb.TournamentDivisionDataResponse, error)
	SetReadyForGame(userID, connID string, round, gameIndex int, unready bool) ([]string, bool, error)
	ClearReadyStates(userID string, round, gameIndex int) ([]*pb.Pairing, error)
	ResetToBeginning() error
	ChangeName(string)
}

type EventAudienceType

type EventAudienceType string

type EventWrapper

type EventWrapper struct {
	Type pb.MessageType
	// The actual event should therefore be a proto object
	Event proto.Message
	// contains filtered or unexported fields
}

An EventWrapper is a real-time update, whether it is a played move, a challenged move, or the game ending, a seek beginning, etc.

func EventFromByteArray

func EventFromByteArray(arr []byte) (*EventWrapper, error)

EventFromByteArray takes in a serialized event and deserializes it. The event must have been serialized with an extra header.

func WrapEvent

func WrapEvent(event proto.Message, messageType pb.MessageType) *EventWrapper

WrapEvent wraps a protobuf event.

func (*EventWrapper) AddAudience

func (e *EventWrapper) AddAudience(audType EventAudienceType, suffix string)

AddAudience sets the audience(s) for this event. It is in the form of a NATS channel name. This is not required to be set in order to deliver a message, but certain functions will use it in the gameplay/entity module.

func (*EventWrapper) AddExcludedUsers

func (e *EventWrapper) AddExcludedUsers(ids []string)

AddExcludedUsers excludes the given users from receiving this message

func (*EventWrapper) Audience

func (e *EventWrapper) Audience() []string

Audience gets the audience(s) for this event, in the form of NATS channel names.

func (*EventWrapper) Serialize

func (e *EventWrapper) Serialize() ([]byte, error)

Serialize serializes the event to a byte array. Our encoding inserts a two byte big-endian number indicating the length of the coming bytes, then a byte representing the message type to the start of the event.

func (*EventWrapper) SetAudience

func (e *EventWrapper) SetAudience(a string)

SetAudience sets a single audience in string format.

func (*EventWrapper) SetSerializationProtocol

func (e *EventWrapper) SetSerializationProtocol(protocol SerializationProtocol)

SetSerializationProtocol sets the serialization protocol of the protobuf object.

type FakeNower

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

FakeNower uses a fake timer. It is used for tests so we don't actually sleep.

func NewFakeNower

func NewFakeNower(f int64) *FakeNower

func (FakeNower) Now

func (f FakeNower) Now() int64

Now returns now's value

func (*FakeNower) Sleep

func (f *FakeNower) Sleep(t int64)

Sleep simulates a sleep.

type Game

type Game struct {
	sync.RWMutex
	game.Game

	DBID        uint
	Type        pb.GameType
	PlayerDBIDs [2]uint // needed to associate the games to the player IDs in the db.

	GameReq *pb.GameRequest
	// started is set when the game actually starts (when the game timers start).
	// Note that the internal game.Game may have started a few seconds before,
	// but there should be no information about it given until _this_ started
	// is true.
	Started bool
	Timers  Timers

	GameEndReason pb.GameEndReason
	// if 0 or 1, that player won
	// if -1, it was a tie!
	WinnerIdx int
	LoserIdx  int

	Stats *Stats

	ChangeHook chan<- *EventWrapper

	Quickdata      *Quickdata
	TournamentData *TournamentData
	MetaEvents     *MetaEventData
	CreatedAt      time.Time
	// contains filtered or unexported fields
}

A Game should be saved to the database or store. It wraps a macondo.Game, and we should save most of the included fields here, especially the macondo.game.History (which can be exported as GCG, etc in the future)

func NewGame

func NewGame(mcg *game.Game, req *pb.GameRequest) *Game

NewGame takes in a Macondo game that was just "started". Note that Macondo games when they start do not log any time, they just deal tiles. The time of start must be logged later, when both players are in the table and ready.

func (*Game) CachedTimeRemaining

func (g *Game) CachedTimeRemaining(idx int) int

func (*Game) ChallengeRule

func (g *Game) ChallengeRule() macondopb.ChallengeRule

func (*Game) CreationRequest

func (g *Game) CreationRequest() *pb.GameRequest

func (*Game) GameID

func (g *Game) GameID() string

func (*Game) GetWinnerIdx

func (g *Game) GetWinnerIdx() int

func (*Game) HistoryRefresherEvent

func (g *Game) HistoryRefresherEvent() *pb.GameHistoryRefresher

func (*Game) NewActiveGameEntry

func (g *Game) NewActiveGameEntry(gameStillActive bool) *EventWrapper

func (*Game) RatingKey

func (g *Game) RatingKey() (VariantKey, error)

func (*Game) RatingMode

func (g *Game) RatingMode() pb.RatingMode

func (*Game) RecordTimeOfMove

func (g *Game) RecordTimeOfMove(idx int)

func (*Game) RegisterChangeHook

func (g *Game) RegisterChangeHook(eventChan chan<- *EventWrapper) error

RegisterChangeHook registers a channel with the game. Events will be sent down this channel.

func (*Game) ResetTimersAndStart

func (g *Game) ResetTimersAndStart()

Reset timers to _now_. The game is actually starting.

func (*Game) SendChange

func (g *Game) SendChange(e *EventWrapper)

SendChange sends an event via the registered hook.

func (*Game) SetGameEndReason

func (g *Game) SetGameEndReason(r pb.GameEndReason)

func (*Game) SetLoserIdx

func (g *Game) SetLoserIdx(pidx int)

func (*Game) SetTimerModule

func (g *Game) SetTimerModule(n Nower)

SetTimerModule sets the timer for a game to the given Nower.

func (*Game) SetWinnerIdx

func (g *Game) SetWinnerIdx(pidx int)

func (*Game) TimeRanOut

func (g *Game) TimeRanOut(idx int) bool

TimeRanOut calculates if time ran out for the given player. Assumes player is on turn, otherwise it always returns false.

func (*Game) TimeRemaining

func (g *Game) TimeRemaining(idx int) int

TimeRemaining calculates the time remaining, but does NOT update it.

func (*Game) TimeStarted

func (g *Game) TimeStarted() int64

func (*Game) TimerModule

func (g *Game) TimerModule() Nower

TimerModule gets the Nower for this game.

func (*Game) WinnerWasSet

func (g *Game) WinnerWasSet() bool

type GameHistory

type GameHistory struct {
	macondopb.GameHistory
}

func (*GameHistory) Scan

func (h *GameHistory) Scan(value interface{}) error

func (*GameHistory) Value

func (h *GameHistory) Value() (driver.Value, error)

type GameRequest

type GameRequest struct {
	pb.GameRequest
}

func (*GameRequest) Scan

func (g *GameRequest) Scan(value interface{}) error

func (*GameRequest) Value

func (g *GameRequest) Value() (driver.Value, error)

type GameTimer

type GameTimer struct{}

GameTimer uses the standard library's `time` package to determine how much time has elapsed in a game.

func (GameTimer) Now

func (g GameTimer) Now() int64

Now returns the current timestamp in milliseconds.

type IncrementType

type IncrementType int
const (
	EventType IncrementType = iota
	GameType
	FinalType
)

type ListDatum

type ListDatum struct {
	// Used for words
	Word        string `json:"w,omitempty"`
	Probability int    `json:"p,omitempty"`
	// Used for words or games:
	Score int `json:"s,omitempty"`

	// Used for comments:
	Comment string `json:"c,omitempty"`

	// Used for mistakes:
	MistakeType int `json:"t,omitempty"`
	MistakeSize int `json:"z,omitempty"`

	// Used for ratings:
	Rating  int    `json:"r,omitempty"`
	Variant string `json:"v,omitempty"`
}

A ListDatum is the individual datum that is stored in a list. It is a sort of "union" of various struct types. Depending on the type of stat, only some of thees fields will be filled in.

func (*ListDatum) Scan

func (ld *ListDatum) Scan(value interface{}) error

Remove these transformation functions once we get rid of Gorm everywhere.

func (*ListDatum) Value

func (ld *ListDatum) Value() (driver.Value, error)

type ListItem

type ListItem struct {
	GameId   string
	PlayerId string
	Time     int64
	Item     ListDatum
}

type MetaEventData

type MetaEventData struct {
	Events []*pb.GameMetaEvent `json:"events"`
}

MetaEventData holds a list of meta events, such as requesting aborts, adjourns, etc.

type MistakeMagnitude

type MistakeMagnitude string

type MistakeType

type MistakeType string

type Nower

type Nower interface {
	// Now returns a timestamp in milliseconds
	Now() int64
}

Nower is an interface for determining the current time

type PoolMember

type PoolMember struct {
	Id          string
	Rating      int
	RatingRange [2]int
	Blocking    []string
	Misses      int
	Wins        int
	Draws       int
	Spread      int
}

type Profile

type Profile struct {
	FirstName string
	LastName  string
	// BirthDate uses ISO format YYYY-MM-DD
	BirthDate   string
	CountryCode string
	Title       string
	About       string
	Ratings     Ratings
	Stats       ProfileStats
	AvatarUrl   string
}

Profile is a user profile. It might not be defined for anonymous users.

type ProfileStats

type ProfileStats struct {
	Data map[VariantKey]*Stats
}

type Quickdata

type Quickdata struct {
	OriginalRequestId string           `json:"o"`
	FinalScores       []int32          `json:"s"`
	PlayerInfo        []*pb.PlayerInfo `json:"pi"`
	OriginalRatings   []float64
	NewRatings        []float64
}

Quickdata represents data that we might need quick access to, for the purposes of aggregating large numbers of games rapidly. This should get saved in its own blob in the store, as opposed to being buried within a game history.

func (*Quickdata) Scan

func (q *Quickdata) Scan(value interface{}) error

func (*Quickdata) Value

func (q *Quickdata) Value() (driver.Value, error)

type Ratings

type Ratings struct {
	Data map[VariantKey]SingleRating
}

Ratings gets stored into a PostgreSQL database.

func (*Ratings) Scan

func (r *Ratings) Scan(value interface{}) error

func (*Ratings) Value

func (r *Ratings) Value() (driver.Value, error)

type SerializationProtocol

type SerializationProtocol int
const (
	EvtSerializationProtoWithHeader SerializationProtocol = iota
	EvtSerializationProto
	EvtSerializationJSONWithHeader
	EvtSerializationJSON
)

type Session

type Session struct {
	ID       string
	Username string
	UserUUID string
	Expiry   time.Time
}

Session - The db specific-details are in the store package.

type SingleRating

type SingleRating struct {
	Rating          float64 `json:"r"`
	RatingDeviation float64 `json:"rd"`
	Volatility      float64 `json:"v"`
	// This is the last game timestamp for this user for THIS variant:
	LastGameTimestamp int64 `json:"ts"`
}

SingleRating encodes a whole Glicko-225 rating object.

func NewDefaultRating

func NewDefaultRating(lastGameIsNow bool) *SingleRating

func (*SingleRating) Scan

func (r *SingleRating) Scan(value interface{}) error

func (*SingleRating) Value

func (r *SingleRating) Value() (driver.Value, error)

XXX: Get rid of these when we're no longer using Gorm anywhere. PGXV5 should be able to directly scan into these types.

type SoughtGame

type SoughtGame struct {
	SeekRequest *pb.SeekRequest
}

func NewSoughtGame

func NewSoughtGame(seekRequest *pb.SeekRequest) *SoughtGame

func (*SoughtGame) ID

func (sg *SoughtGame) ID() (string, error)

func (*SoughtGame) ReceiverConnID

func (sg *SoughtGame) ReceiverConnID() (string, error)

func (*SoughtGame) ReceiverDisplayName

func (sg *SoughtGame) ReceiverDisplayName() (string, error)

func (*SoughtGame) ReceiverIsPermanent

func (sg *SoughtGame) ReceiverIsPermanent() (bool, error)

func (*SoughtGame) ReceiverUserID

func (sg *SoughtGame) ReceiverUserID() (string, error)

func (*SoughtGame) Scan

func (sg *SoughtGame) Scan(value interface{}) error

func (*SoughtGame) SeekerConnID

func (sg *SoughtGame) SeekerConnID() (string, error)

func (*SoughtGame) SeekerUserID

func (sg *SoughtGame) SeekerUserID() (string, error)

func (*SoughtGame) Value

func (sg *SoughtGame) Value() (driver.Value, error)

type SoughtGameType

type SoughtGameType int
const (
	TypeSeek SoughtGameType = iota
	TypeNone
)

type StatItem

type StatItem struct {
	Name          string         `json:"-"`
	Minimum       int            `json:"-"`
	Maximum       int            `json:"-"`
	Total         int            `json:"t"`
	IncrementType IncrementType  `json:"-"`
	List          []*ListItem    `json:"l"`
	Subitems      map[string]int `json:"s"`
}

type StatItemType

type StatItemType int
const (
	SingleType StatItemType = iota
	ListType
	MinimumType
	MaximumType
)

type Stats

type Stats struct {
	PlayerOneId   string               `json:"i1"`
	PlayerTwoId   string               `json:"i2"`
	PlayerOneData map[string]*StatItem `json:"d1"`
	PlayerTwoData map[string]*StatItem `json:"d2"`
	NotableData   map[string]*StatItem `json:"n"`
}

type TimeControl

type TimeControl string

func VariantFromGameReq

func VariantFromGameReq(gamereq *pb.GameRequest) (TimeControl, game.Variant, error)

type Timers

type Timers struct {
	// TimeOfLastUpdate is the timestamp of the last update, in milliseconds.
	// If no update has been made, this defaults to timeStarted.
	TimeOfLastUpdate int64 `json:"lu"`
	// TimeStarted is a unix timestamp, in milliseconds.
	TimeStarted int64 `json:"ts"`
	// TimeRemaining is an array of remaining time per player, in milliseconds.
	TimeRemaining []int `json:"tr"`
	// MaxOvertime is in minutes. All others are in milliseconds.
	MaxOvertime int `json:"mo"`
}

func (*Timers) Scan

func (t *Timers) Scan(value interface{}) error

func (*Timers) Value

func (t *Timers) Value() (driver.Value, error)

type Tournament

type Tournament struct {
	sync.RWMutex
	UUID        string `json:"uuid"`
	Name        string `json:"name"`
	Description string `json:"desc"`
	// XXX: We will likely remove the following two fields
	AliasOf string `json:"aliasOf"`
	URL     string `json:"url"`
	// XXX: Investigate above.
	ExecutiveDirector string                         `json:"execDirector"`
	Directors         *pb.TournamentPersons          `json:"directors"`
	IsStarted         bool                           `json:"started"`
	IsFinished        bool                           `json:"finished"`
	Divisions         map[string]*TournamentDivision `json:"divs"`
	Type              CompetitionType                `json:"type"`
	ParentID          string                         `json:"parent"`
	Slug              string                         `json:"slug"`
	ExtraMeta         *TournamentMeta                `json:"extraMeta"`
}

type TournamentData

type TournamentData struct {
	Id        string
	Division  string `json:"d"`
	Round     int    `json:"r"`
	GameIndex int    `json:"i"`
}

TournamentData holds the tournament data for a game. This is nil if the game is not a tournament game.

type TournamentDivision

type TournamentDivision struct {
	ManagerType        TournamentType  `json:"mgrType"`
	DivisionRawMessage json.RawMessage `json:"json"`
	DivisionManager    DivisionManager `json:"-"`
}

type TournamentMeta

type TournamentMeta struct {
	Disclaimer                string          `json:"disclaimer"`
	TileStyle                 string          `json:"tileStyle"`
	BoardStyle                string          `json:"boardStyle"`
	DefaultClubSettings       *pb.GameRequest `json:"defaultClubSettings"`
	FreeformClubSettingFields []string        `json:"freeformClubSettingFields"`
	Password                  string          `json:"password"`
	Color                     string          `json:"color"`
	PrivateAnalysis           bool            `json:"privateAnalysis"`
	IRLMode                   bool            `json:"irlMode"`
}

type TournamentType

type TournamentType int
const (
	ClassicTournamentType TournamentType = iota
	// It's gonna be lit:
	ArenaTournamentType
)

type UnpairedPoolMembers

type UnpairedPoolMembers struct {
	PoolMembers   []*PoolMember
	RoundControls *ipc.RoundControl
	Repeats       map[string]int
}

type User

type User struct {
	sync.RWMutex

	Anonymous bool
	// ID is the database ID. Since this increases monotonically, we should
	// not expose it to the user
	ID uint
	// UUID is the "user-exposed" ID, in any APIs.
	UUID     string
	Username string
	Password string
	Email    string
	Profile  *Profile
	// CurrentChannel tracks presence; where is the user currently?
	CurrentChannel string
	IsBot          bool
	IsDirector     bool
	IsMod          bool
	IsAdmin        bool

	// DEPRECATED: use db actions
	Actions      *Actions
	Notoriety    int
	AuthedMethod AuthMethod
}

User - the db-specific details are in the store package.

func (*User) AvatarUrl

func (u *User) AvatarUrl() string

func (*User) GetProtoRatings

func (u *User) GetProtoRatings() (map[string]*pb.ProfileUpdate_Rating, error)

func (*User) GetRating

func (u *User) GetRating(ratingKey VariantKey) (*SingleRating, error)

GetRating gets a full Glicko-225 rating for this user, based on the passed-in rating key.

func (*User) GetRelevantRating

func (u *User) GetRelevantRating(ratingKey VariantKey) string

GetRelevantRating gets a displayable rating for this user, based on the passed-in rating key (encoding variant, time control, etc)

func (*User) IsChild

func (u *User) IsChild() pb.ChildStatus

func (*User) RealName

func (u *User) RealName() string

RealName returns a user's real name, or an empty string if anonymous.

func (*User) RealNameIfNotYouth

func (u *User) RealNameIfNotYouth() string

RealNameIfNotYouth returns a user's real name, only if they are older than 13. If a birth date has not been provided, do not show it.

func (*User) TournamentID

func (u *User) TournamentID() string

TournamentID returns the "player ID" of a user. UUID:username is probably not a good design, but let's at least narrow it down to this function.

type UserPermission

type UserPermission int
const (
	PermDirector UserPermission = iota
	PermMod
	PermAdmin
	PermBot
)

type Variant

type Variant string

type VariantKey

type VariantKey string

func LexiconToPuzzleVariantKey

func LexiconToPuzzleVariantKey(lexicon string) VariantKey

func ToVariantKey

func ToVariantKey(lexiconName string, variantName game.Variant, timeControl TimeControl) VariantKey

type WooglesError

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

func NewWooglesError

func NewWooglesError(code ipc.WooglesError, data ...string) *WooglesError

func (*WooglesError) Error

func (w *WooglesError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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