Documentation ¶
Index ¶
- Constants
- Variables
- type BeginCountdown
- type Client
- func (c *Client) AddEventHandler(handler interface{})
- func (c *Client) Close()
- func (c *Client) JoinRoom(Code string) error
- func (c *Client) JoinRound() error
- func (c *Client) LeaveRoom() error
- func (c *Client) LeaveRound() error
- func (c *Client) MakeRoom(name string, public bool) error
- func (c *Client) RemoveEventHandler(event Event)
- func (c *Client) SetGuess(guess string, submit bool)
- type Event
- type EventBonusAlphabetComplete
- type EventChat
- type EventChatterJoined
- type EventCountdown
- type EventJoinedGame
- type EventLivesLost
- type EventPlayerInput
- type EventPlayerJoinedRound
- type EventPlayerLeftRound
- type EventRoundEnd
- type EventRoundStart
- type EventSelfKicked
- type EventTurnChange
- type EventWordCorrect
- type EventWordFail
- type FailReason
- type Player
- type PlayerAuth
- type Room
- type RoomRules
- type Round
- type RoundPlayer
- type TurnChange
Constants ¶
View Source
const BASE_URL = "https://jklm.fun/api"
Variables ¶
View Source
var ( ErrNotConnected = errors.New("NotConnected") ErrNoRoom = errors.New("NoSuchRoom") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Username of the client Username string // Token used to identify the client Token string Room *Room // contains filtered or unexported fields }
func NewGuestClient ¶
func (*Client) AddEventHandler ¶
func (c *Client) AddEventHandler(handler interface{})
func (*Client) RemoveEventHandler ¶
type Event ¶
type Event string
All the events that could happen
const ( JOINED_GAME Event = "setup" PLAYER_JOINED_ROUND Event = "addPlayer" PLAYER_LEFT_ROUND Event = "removePlayer" CHATTER_JOINED Event = "chatterAdded" CHATTER_LEFT Event = "chatterRemoved" COUNTDOWN Event = "setStartTime" ROUND_START Event = "round" ROUND_END Event = "seating" TURN_CHANGE Event = "nextTurn" PLAYER_INPUT Event = "setPlayerWord" WORD_CORRECT Event = "correctWord" WORD_FAIL Event = "failWord" BONUS_ALPHABET_COMPLETED Event = "bonusAlphabetCompleted" KICKED Event = "kicked" CHAT Event = "chat" )
TODO: Change these from numbers to stuff like JoinGame!!!
type EventBonusAlphabetComplete ¶
type EventBonusAlphabetComplete struct {
Player *RoundPlayer
}
type EventChatterJoined ¶
type EventChatterJoined struct {
*Player
}
type EventCountdown ¶
Start the 15 second countdown
type EventJoinedGame ¶
type EventJoinedGame struct {
*Room
}
type EventLivesLost ¶
type EventLivesLost struct { Player *RoundPlayer AmountLost int }
Used whenever a player looses lives
type EventPlayerInput ¶
type EventPlayerInput struct {
*RoundPlayer
}
Whenever a player updates their guess
type EventPlayerJoinedRound ¶
type EventPlayerJoinedRound struct {
*Player
}
type EventPlayerLeftRound ¶
type EventPlayerLeftRound struct {
*Player
}
type EventRoundEnd ¶
type EventRoundEnd struct {
Winner *RoundPlayer
}
type EventRoundStart ¶
type EventRoundStart struct {
*TurnChange
}
type EventSelfKicked ¶
type EventSelfKicked struct {
Reason string
}
type EventWordCorrect ¶
type EventWordCorrect struct {
*RoundPlayer
}
type EventWordFail ¶
type EventWordFail struct { Player *RoundPlayer Reason FailReason }
type FailReason ¶
type FailReason int
The reason why a guess failed. Used as an enum with constants starting with FR_
const ( // The guess made isn't a recognised word FR_NOT_IN_DICTIONARY FailReason = iota // The guess didn't contain the prompt FR_NO_PROMPT // The guess has been used already FR_ALREADY_USED )
type PlayerAuth ¶
type Room ¶
type Room struct { // A WebSocket connection to a room WS *websocket.Conn WSAuth *websocket.Conn // The room code. An all-caps 4 letter string. Code string // Room rules Rules RoomRules // If Round == nil, there is no active round in this room. Round *Round // LastWinner will be nil if a a roung is being played, or if there is no previous round LastWinner *Player // The prefix that is used for a connection to this room. // I believe it's used for load balancing. Server string // This player's ID. Self *Player // All the connected chatters. This should be used as a repository of available players. Chatters map[string]*Player // Players waiting for the next round. To add your own player, see Client.JoinRound(). // If a round is happening, this will be an empty map. This should not be used for verifying if a round is happening. PlayersWaiting map[string]*Player // contains filtered or unexported fields }
Room (refered to as 'milestone' by the API) describes the room the player is in.
type RoomRules ¶
type RoomRules struct { // The name of the dictionary used Dictionary string // An array of letters needed to recover a life BonusAlphabet []string // The minimum turn duration, in seconds MinTurnDuration int // If PromptDifficulty < 0, then this is at most X words per prompt. // Otherwise, this is at least X words per prompt. PromptDifficulty int // If this many players fail, the prompt changes. MaxPromptAge int // Starting amount of lives StartingLives int // Maximum lives MaxLives int }
Rules for this room
type Round ¶
type Round struct { Order []string CurrentPlayer *RoundPlayer Self *RoundPlayer Prompt string Players map[string]*RoundPlayer PromptAge int BonusAlphabet []rune }
type RoundPlayer ¶
type TurnChange ¶
type TurnChange struct { LastPlayer *RoundPlayer LastPlayerWasHurt bool LastPrompt string CurrentPlayer *RoundPlayer Prompt string }
Click to show internal directories.
Click to hide internal directories.