room

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TeamSpectator team = 0
	TeamRed       team = 1
	TeamBlue      team = 2
)

Variables

This section is empty.

Functions

func ColorHex

func ColorHex(hex string) (color, error)

func ColorRgb

func ColorRgb(r, g, b uint8) color

Types

type Config

type Config struct {
	Bot struct {
		Active bool
		Name   string
	}
	General struct {
		Name      string
		Token     string
		MaxPlayer int
	}
	Security struct {
		Public   bool
		Password string
	}
	Logging struct {
		Debug  bool
		Pretty bool
	}
}

func (Config) String

func (c Config) String() string

type Logger

type Logger struct{}

func (*Logger) Debug

func (*Logger) Debug(msg string)

func (*Logger) Debugf

func (*Logger) Debugf(format string, v ...interface{})

func (*Logger) Error

func (*Logger) Error(msg string)

func (*Logger) Errorf

func (*Logger) Errorf(format string, v ...interface{})

func (*Logger) Info

func (*Logger) Info(msg string)

func (*Logger) Infof

func (*Logger) Infof(format string, v ...interface{})

func (*Logger) Warn

func (*Logger) Warn(msg string)

func (*Logger) Warnf

func (*Logger) Warnf(format string, v ...interface{})

type Player

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

func (*Player) Announce

func (p *Player) Announce(msg string)

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

func (p *Player) Announcef(format string, v ...interface{})

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) Conn

func (p *Player) Conn() string

Returns player conn.

func (*Player) Id

func (p *Player) Id() int

Returns player id.

func (*Player) IsAdmin

func (p *Player) IsAdmin() bool

Whether the player has admin rights.

func (*Player) Kick

func (p *Player) Kick(reason string, ban bool)

Kicks player from room with aditional ban option.

func (*Player) Message

func (p *Player) Message(msg string)

Sends a chat message to player using the host player.

func (*Player) Messagef

func (p *Player) Messagef(format string, v ...interface{})

Sends a formatted chat message to player using the host player.

func (*Player) Name

func (p *Player) Name() string

Returns player name.

func (*Player) Position

func (p *Player) Position() *mgl32.Vec2

The player's position in the field, if the player is not in the field the value will be null.

func (*Player) SetAdmin

func (p *Player) SetAdmin(val bool)

Sets player admin privileges.

func (*Player) SetAvatar

func (p *Player) SetAvatar(val string)

Overrides the avatar of the player.

func (*Player) Team

func (p *Player) Team() team

Returns player team.

type Room

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

func New

func New() *Room

Creates a new room

func (*Room) Announce

func (r *Room) Announce(msg string)

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

func (r *Room) Announcef(format string, v ...interface{})

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

func (r *Room) ClearBan(id int)

Clears the ban for a playerId that belonged to a player that was previously banned.

func (*Room) ClearBans

func (r *Room) ClearBans()

Clears the list of banned players.

func (*Room) GetBallPosition

func (r *Room) GetBallPosition() *mgl32.Vec2

Returns the ball's position in the field or null if no game is in progress.

func (*Room) GetDiscCount

func (r *Room) GetDiscCount() int

Gets the number of discs in the game including the ball and player discs.

func (*Room) GetPlayer

func (r *Room) GetPlayer(id int) *Player

Gets a player from room. (returns nil if player doesn't exists)

func (*Room) GetPlayers

func (r *Room) GetPlayers() []*Player

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 (r *Room) Link() string

Obtains room link.

func (*Room) Logger

func (r *Room) Logger() *Logger

Gets logger.

func (*Room) Message

func (r *Room) Message(msg string)

Sends a chat message using the host player.

func (*Room) Messagef

func (r *Room) Messagef(format string, v ...interface{})

Sends a formatted chat message using the host player.

func (*Room) OnGamePause

func (r *Room) OnGamePause(fun func(by *Player))

Event called when the game is paused.

func (*Room) OnGameStart

func (r *Room) OnGameStart(fun func(by *Player))

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

func (r *Room) OnGameStop(fun func(by *Player))

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

func (r *Room) OnGameUnpause(fun func(by *Player))

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

func (r *Room) OnKickRateLimitSet(fun func(min int, rate int, burst int, by *Player))

Event called when the kick rate is set.

func (*Room) OnPlayerActivity

func (r *Room) OnPlayerActivity(fun func(*Player))

Event called when a player gives signs of activity, such as pressing a key. This is useful for detecting inactive players.

func (*Room) OnPlayerAdminChange

func (r *Room) OnPlayerAdminChange(fun func(p *Player, by *Player))

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

func (r *Room) OnPlayerBallKick(fun func(*Player))

Event called when a player kicks the ball.

func (*Room) OnPlayerChat

func (r *Room) OnPlayerChat(fun func(p *Player, msg string) (send bool))

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

func (r *Room) OnPlayerJoin(fun func(*Player))

Event called when a new player joins the room.

func (*Room) OnPlayerKicked

func (r *Room) OnPlayerKicked(fun func(p *Player, reason string, ban bool, by *Player))

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

func (r *Room) OnPlayerLeave(fun func(*Player))

Event called when a player leaves the room.

func (*Room) OnPlayerTeamChange

func (r *Room) OnPlayerTeamChange(fun func(p *Player, by *Player))

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 (r *Room) OnRoomLink(fun func(link string))

Event called when the room link is obtained.

func (*Room) OnStadiumChange

func (r *Room) OnStadiumChange(fun func(stadium string, by *Player))

Event called when the stadium is changed.

func (*Room) PauseGame

func (r *Room) PauseGame(val bool)

Sets the pause state of the game.

func (*Room) Scheduler

func (r *Room) Scheduler() *Scheduler

Gets scheduler.

func (*Room) SetCustomStadium

func (r *Room) SetCustomStadium(val string)

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

func (r *Room) SetDefaultStadium(name string)

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

func (r *Room) SetKickRateLimit(min int, rate int, burst int)

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

func (r *Room) SetPassword(val string)

Changes the password of the room, if pass is null the password will be cleared.

func (*Room) SetRequireRecaptcha

func (r *Room) SetRequireRecaptcha(val bool)

Activates or deactivates the recaptcha requirement to join the room.

func (*Room) SetTeamsLock

func (r *Room) SetTeamsLock(val bool)

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

func (r *Room) SetTimeLimit(val int)

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) Shutdown

func (r *Room) Shutdown()

Waits receive signal to shutdown room properly.

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

func (r *Room) StopRecording() []uint8

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.

type Scheduler

type Scheduler struct{}

func (Scheduler) Delayed

func (Scheduler) Delayed(delay time.Duration, fun func())

Creates a delayed task.

func (*Scheduler) DelayedRepeating

func (*Scheduler) DelayedRepeating(delay time.Duration, period time.Duration, fun func(stop func())) func()

Creates a delayed repeating task.

func (Scheduler) Repeating

func (Scheduler) Repeating(period time.Duration, fun func(stop func())) func()

Creates a repeating task.

Jump to

Keyboard shortcuts

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