Documentation ¶
Index ¶
- Constants
- Variables
- func GetRandomWord(words []string) string
- func GetResult(guess, answer string) []int
- func ValidDefinition(definition PlayerDefinition) (bool, error)
- func ValidGuess(guess, answer string) bool
- type Game
- type Guess
- type GuessResult
- type Match
- type MatchSnapshot
- type Player
- type PlayerConnection
- type PlayerDefinition
- type PlayerGameState
- type PlayerMatchResults
Constants ¶
View Source
const ( LetterResultBlack = iota LetterResultYellow LetterResultGreen )
View Source
const (
GuessIDHeader = "guessID"
)
Variables ¶
View Source
var ( CommonWords = []string{}/* 2309 elements not displayed */ AllWords = []string{}/* 10638 elements not displayed */ )
Functions ¶
func GetRandomWord ¶
func ValidDefinition ¶ added in v0.12.0
func ValidDefinition(definition PlayerDefinition) (bool, error)
Types ¶
type Game ¶ added in v0.3.0
type GuessResult ¶ added in v0.7.0
type Match ¶ added in v0.3.0
type Match struct {
// contains filtered or unexported fields
}
func InitMatch ¶ added in v0.3.0
func InitMatch(log logrus.FieldLogger, allWords, commonWords []string, playerURIs []string, numLetters, numRounds, numGames int) (*Match, error)
InitMatch generates all the games for the match and populates player information and other match level metadata
func (*Match) Broadcast ¶ added in v0.3.2
func (m *Match) Broadcast()
Broadcast takes the results of the match and sends it to all players
func (*Match) Snapshot ¶ added in v0.8.0
func (m *Match) Snapshot() MatchSnapshot
type MatchSnapshot ¶ added in v0.8.0
type MatchSnapshot struct { UUID string `json:"match_id,omitempty"` Start time.Time `json:"start,omitempty"` End time.Time `json:"end,omitempty"` Players []Player `json:"players,omitempty"` Games []Game `json:"games,omitempty"` RoundsPerGame int `json:"rounds_per_game,omitempty"` LettersPerWord int `json:"letters_per_word,omitempty"` }
MatchSnapshot is what clients can use to get the current state of the game, and what gets sent to the contestants at the end of matches
type Player ¶
type Player struct { ID string `json:"player_id,omitempty"` Definition PlayerDefinition `json:"definition,omitempty"` GamesPlayed []PlayerGameState `json:"games_played,omitempty"` Finish time.Time `json:"finish,omitempty"` // contains filtered or unexported fields }
func InitPlayer ¶
func (*Player) BroadcastMatch ¶ added in v0.3.2
func (p *Player) BroadcastMatch(m MatchSnapshot) error
type PlayerConnection ¶ added in v0.3.0
type PlayerConnection struct {
// contains filtered or unexported fields
}
This is all secret or not json readable types
type PlayerDefinition ¶ added in v0.3.0
type PlayerDefinition struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` ConcurrentConnLimit int `json:"concurrent_connection_limit,omitempty"` Colour string `json:"colour,omitempty"` }
func GetDefinition ¶ added in v0.4.0
func GetDefinition(uri string) (PlayerDefinition, error)
type PlayerGameState ¶ added in v0.3.0
type PlayerGameState struct { GameID string `json:"game_id,omitempty"` Start time.Time `json:"start,omitempty"` Finish time.Time `json:"finish,omitempty"` GuessResults []GuessResult `json:"guess_results,omitempty"` Correct bool `json:"correct,omitempty"` Error string `json:"error,omitempty"` GuessDurationsNS []int64 `json:"guess_durations_ns,omitempty"` // contains filtered or unexported fields }
func GetNextState ¶ added in v0.8.0
func GetNextState(ctx context.Context, log logrus.FieldLogger, c PlayerConnection, s PlayerGameState, answer string) PlayerGameState
func PlayGame ¶ added in v0.8.0
func PlayGame(ctx context.Context, log logrus.FieldLogger, c PlayerConnection, g Game) PlayerGameState
type PlayerMatchResults ¶ added in v0.5.0
type PlayerMatchResults struct { PlayerID string `json:"player_id,omitempty"` Results MatchSnapshot `json:"results,omitempty"` }
this struct includes the player's id to give them certainty about who they were
Click to show internal directories.
Click to hide internal directories.