Documentation
¶
Overview ¶
Package game contains communication structures for the game controller, lobby, and socket to use
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { // ID is unique among the other games that currently exist. ID ID `json:"id"` // Status is the state of the game. Status Status `json:"status"` // Players is a list of the names of players in the game. Players []string `json:"players"` // CreatedAt is the game's creation time in seconds since the unix epoch. CreatedAt int64 `json:"createdAt"` }
Info contains information about a game
type Message ¶
type Message struct { Type MessageType `json:"type"` Info string `json:"info,omitempty"` Tiles []tile.Tile `json:"tiles,omitempty"` TilePositions []tile.Position `json:"tilePositions,omitempty"` TilesLeft int `json:"tilesLeft,omitempty"` GameInfos []Info `json:"gameInfos,omitempty"` GameID ID `json:"gameID,omitempty"` GameStatus Status `json:"gameStatus,omitempty"` GamePlayers []string `json:"gamePlayers,omitempty"` NumCols int `json:"c,omitempty"` NumRows int `json:"r,omitempty"` PlayerName PlayerName `json:"-"` }
Message contains information to or from a socket for a game/lobby
type MessageType ¶
type MessageType int
MessageType represents what the purpose of a message is
const ( // Create is a MessageType that users send to open a new game. Create MessageType // Join is a MessageType that users send to join a game or the server sends to have the user load a game. Join // Leave is a MessageType that servers send to indicate that a user can to longer be in the current game. Leave // Delete is a MessageType that users send to remove a game from the server. Delete // StatusChange is a MessageType that users and servers send to request or inform of a game status change. StatusChange // TilesChange is a MessageType that the server sends to users to indicate that tiles have been changed for any player. TilesChange // Snag is a MessageType that users send to the server to request a new tile when they have none left to use. Snag // Swap is a MessageType that users send to the server to exchange a tile for three new ones. Swap // TilesMoved is a MessageType that users send to the server whenever they change the state of their boards. TilesMoved // Infos is a MessageType that users/servers send to request/report changes in the games in a lobby. Infos // PlayerDelete is a MessageType that gets sent to inform the game that a player's account has been deleted. PlayerDelete // SocketWarning is a MessageType that servers send to inform users that a request is invalid. SocketWarning // SocketError is a MessageType that servers send to users to report an unexpected state. SocketError // SocketHTTPPing is a MessageType the server sends to the user to request a http request to the site to keep it active. Some environments shut down after a period of HTTP inactivity has passed. SocketHTTPPing // Chat is a MessageType that users send to communicate with ether players through the server. Chat )
type Status ¶
type Status int
Status is the state of the game
const ( // NotStarted is the status of a game that is waiting for mor players to join before allowing them to rearrange their tiles. NotStarted Status // InProgress is the status of a game that has been started but is not finished. InProgress // Finished is the status of a game that has no tiles left and has a winner that has used all his tiles to form one group of interconnected words. Finished )
type WordChecker ¶
type WordChecker struct {
// contains filtered or unexported fields
}
WordChecker can be used to check if words are valid
func NewWordChecker ¶
func NewWordChecker(r io.Reader) (*WordChecker, error)
NewWordChecker consumes the lower case words in the reader to use for checking and creates a new WordChecker
func (WordChecker) Check ¶
func (wc WordChecker) Check(word string) bool
Check determines whether or not the word is valid
Directories
¶
Path | Synopsis |
---|---|
Package board stores the tiles for a game and handles queries to read and update tiles
|
Package board stores the tiles for a game and handles queries to read and update tiles |
Package controller handles the logic to run the game
|
Package controller handles the logic to run the game |
Package lobby handles players connecting to games and communication between games and players
|
Package lobby handles players connecting to games and communication between games and players |
Package socket handles communication with a player using a websocket connection
|
Package socket handles communication with a player using a websocket connection |
Package tile contains structures that players interact with on game boards
|
Package tile contains structures that players interact with on game boards |
Click to show internal directories.
Click to hide internal directories.