Documentation ¶
Index ¶
- Constants
- func ColorHex(hex string) (color, error)
- func ColorRgb(r, g, b uint8) color
- type Config
- type Logger
- func (*Logger) Debug(msg string)
- func (*Logger) Debugf(format string, v ...interface{})
- func (*Logger) Error(msg string)
- func (*Logger) Errorf(format string, v ...interface{})
- func (*Logger) Info(msg string)
- func (*Logger) Infof(format string, v ...interface{})
- func (*Logger) Warn(msg string)
- func (*Logger) Warnf(format string, v ...interface{})
- type Player
- func (p *Player) Announce(msg string)
- func (p *Player) Announcef(format string, v ...interface{})
- func (p *Player) Conn() string
- func (p *Player) Id() int
- func (p *Player) IsAdmin() bool
- func (p *Player) Kick(reason string, ban bool)
- func (p *Player) Message(msg string)
- func (p *Player) Messagef(format string, v ...interface{})
- func (p *Player) Name() string
- func (p *Player) Position() *mgl32.Vec2
- func (p *Player) SetAdmin(val bool)
- func (p *Player) SetAvatar(val string)
- func (p *Player) Team() team
- type Room
- func (r *Room) Announce(msg string)
- func (r *Room) Announcef(format string, v ...interface{})
- func (r *Room) ClearBan(id int)
- func (r *Room) ClearBans()
- func (r *Room) GetBallPosition() *mgl32.Vec2
- func (r *Room) GetDiscCount() int
- func (r *Room) GetPlayer(id int) *Player
- func (r *Room) GetPlayers() []*Player
- func (r *Room) GetScores() *scores
- func (r *Room) Link() string
- func (r *Room) Logger() *Logger
- func (r *Room) Message(msg string)
- func (r *Room) Messagef(format string, v ...interface{})
- func (r *Room) OnGamePause(fun func(by *Player))
- func (r *Room) OnGameStart(fun func(by *Player))
- func (r *Room) OnGameStop(fun func(by *Player))
- func (r *Room) OnGameTick(fun func())
- func (r *Room) OnGameUnpause(fun func(by *Player))
- func (r *Room) OnKickRateLimitSet(fun func(min int, rate int, burst int, by *Player))
- func (r *Room) OnPlayerActivity(fun func(*Player))
- func (r *Room) OnPlayerAdminChange(fun func(p *Player, by *Player))
- func (r *Room) OnPlayerBallKick(fun func(*Player))
- func (r *Room) OnPlayerChat(fun func(p *Player, msg string) (send bool))
- func (r *Room) OnPlayerJoin(fun func(*Player))
- func (r *Room) OnPlayerKicked(fun func(p *Player, reason string, ban bool, by *Player))
- func (r *Room) OnPlayerLeave(fun func(*Player))
- func (r *Room) OnPlayerTeamChange(fun func(p *Player, by *Player))
- func (r *Room) OnPositionsReset(fun func())
- func (r *Room) OnRoomLink(fun func(link string))
- func (r *Room) OnStadiumChange(fun func(stadium string, by *Player))
- func (r *Room) PauseGame(val bool)
- func (r *Room) Scheduler() *Scheduler
- func (r *Room) SetCustomStadium(val string)
- func (r *Room) SetDefaultStadium(name string)
- func (r *Room) SetKickRateLimit(min int, rate int, burst int)
- func (r *Room) SetPassword(val string)
- func (r *Room) SetRequireRecaptcha(val bool)
- func (r *Room) SetTeamsLock(val bool)
- func (r *Room) SetTimeLimit(val int)
- func (r *Room) Shutdown()
- func (r *Room) StartGame()
- func (r *Room) StartRecording()
- func (r *Room) StopGame()
- func (r *Room) StopRecording() []uint8
- type Scheduler
Constants ¶
const ( TeamSpectator team = 0 TeamRed team = 1 TeamBlue team = 2 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
func (*Player) Announce ¶
Sends a host announcement with msg as contents. Unlike sendChat, announcements will work without a host player and has a larger limit on the number of characters.
func (*Player) Announcef ¶
Sends a formatted host announcement with msg as contents. Unlike sendChat, announcements will work without a host player and has a larger limit on the number of characters.
func (*Player) Position ¶
The player's position in the field, if the player is not in the field the value will be null.
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
func (*Room) Announce ¶
Sends a host announcement with msg as contents. Unlike sendChat, announcements will work without a host player and has a larger limit on the number of characters.
func (*Room) Announcef ¶
Sends a formatted host announcement with msg as contents. Unlike sendChat, announcements will work without a host player and has a larger limit on the number of characters.
func (*Room) ClearBan ¶
Clears the ban for a playerId that belonged to a player that was previously banned.
func (*Room) GetBallPosition ¶
Returns the ball's position in the field or null if no game is in progress.
func (*Room) GetDiscCount ¶
Gets the number of discs in the game including the ball and player discs.
func (*Room) GetPlayers ¶
Returns the current list of players.
func (*Room) GetScores ¶
func (r *Room) GetScores() *scores
If a game is in progress it returns the current score information. Otherwise it returns null.
func (*Room) OnGamePause ¶
Event called when the game is paused.
func (*Room) OnGameStart ¶
Event called when a game starts.
`by` is the player which caused the event (can be null if the event wasn't caused by a player).
func (*Room) OnGameStop ¶
Event called when a game stops.
`by` is the player which caused the event (can be null if the event wasn't caused by a player).
func (*Room) OnGameTick ¶
func (r *Room) OnGameTick(fun func())
Event called once for every game tick (happens 60 times per second). This is useful if you want to monitor the player and ball positions without missing any ticks.
This event is not called if the game is paused or stopped.
func (*Room) OnGameUnpause ¶
Event called when the game is unpaused.
After this event there's a timer before the game is fully unpaused, to detect when the game has really resumed you can listen for the first onGameTick event after this event is called.
func (*Room) OnKickRateLimitSet ¶
Event called when the kick rate is set.
func (*Room) OnPlayerActivity ¶
Event called when a player gives signs of activity, such as pressing a key. This is useful for detecting inactive players.
func (*Room) OnPlayerAdminChange ¶
Event called when a player's admin rights are changed.
`by` is the player which caused the event (can be null if the event wasn't caused by a player).
func (*Room) OnPlayerBallKick ¶
Event called when a player kicks the ball.
func (*Room) OnPlayerChat ¶
Event called when a player sends a chat message.
The event function can return `false` in order to filter the chat message. This prevents the chat message from reaching other players in the room.
func (*Room) OnPlayerJoin ¶
Event called when a new player joins the room.
func (*Room) OnPlayerKicked ¶
Event called when a player has been kicked from the room. This is always called after the onPlayerLeave event.
`by` is the player which caused the event (can be null if the event wasn't caused by a player).
func (*Room) OnPlayerLeave ¶
Event called when a player leaves the room.
func (*Room) OnPlayerTeamChange ¶
Event called when a player team is changed.
`by` is the player which caused the event (can be null if the event wasn't caused by a player).
func (*Room) OnPositionsReset ¶
func (r *Room) OnPositionsReset(fun func())
Event called when the players and ball positions are reset after a goal happens.
func (*Room) OnRoomLink ¶
Event called when the room link is obtained.
func (*Room) OnStadiumChange ¶
Event called when the stadium is changed.
func (*Room) SetCustomStadium ¶
Parses the value as a .hbs stadium file and sets it as the selected stadium.
There must not be a game in progress, if a game is in progress this method does nothing.
func (*Room) SetDefaultStadium ¶
Sets the selected stadium to one of the default stadiums. The name must match exactly. (case sensitive)
There must not be a game in progress, if a game is in progress this method does nothing.
func (*Room) SetKickRateLimit ¶
Sets the room's kick rate limits.
`min` is the minimum number of logic-frames between two kicks. It is impossible to kick faster than this.
`rate` works like `min` but lets players save up extra kicks to use them later depending on the value of `burst`.
`burst` determines how many extra kicks the player is able to save up.
func (*Room) SetPassword ¶
Changes the password of the room, if pass is null the password will be cleared.
func (*Room) SetRequireRecaptcha ¶
Activates or deactivates the recaptcha requirement to join the room.
func (*Room) SetTeamsLock ¶
Sets the teams lock. When teams are locked players are not able to change team unless they are moved by an admin.
func (*Room) SetTimeLimit ¶
Sets the time limit of the room. The limit must be specified in number of minutes.
If a game is in progress this method does nothing.
func (*Room) StartGame ¶
func (r *Room) StartGame()
Starts the game, if a game is already in progress this method does nothing.
func (*Room) StartRecording ¶
func (r *Room) StartRecording()
Starts recording of a haxball replay.
Don't forget to call stop recording or it will cause a memory leak.
func (*Room) StopGame ¶
func (r *Room) StopGame()
Stops the game, if no game is in progress this method does nothing.
func (*Room) StopRecording ¶
Stops the recording previously started with startRecording and returns the replay file contents as a []uint8.
Returns null if recording was not started or had already been stopped.