messages

package
v0.0.0-...-afdd1b7 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InKill       = "kill"
	InRoundStart = "round_start"
	InRoundEnd   = "round_end"
	InMatchStart = "match_start"
	InMatchEnd   = "match_end"
	InPickup     = "arrows_collected"
	InShot       = "arrow_shot"
	InShield     = "shield_state"
	InWings      = "wings_state"
	InOrbLava    = "lava_orb_state"
	// TODO(thiderman): Non-player orbs are not implemented
	InOrbSlow   = "slow_orb_state"
	InOrbDark   = "dark_orb_state"
	InOrbScroll = "scroll_orb_state"
)

Message types as used by IncomingGameMessage nolint

View Source
const (
	GameMatch      = "match"
	GameConnect    = "game_connected"
	GameDisconnect = "game_disconnected"
	GameStartPlay  = "start_play"
	GameComplete   = "tournament_complete"
)

Constant strings for use as kinds when communicating with the game

View Source
const EnvironmentKill = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrowMessage

type ArrowMessage struct {
	Player int           `json:"player"`
	Arrows models.Arrows `json:"arrows"`
}

type DarkOrbMessage

type DarkOrbMessage struct {
	State bool `json:"state"`
}

type GameMatchMessage

type GameMatchMessage struct {
	Players    []GamePlayer `json:"players"`
	Tournament string       `json:"tournament"`
	Level      string       `json:"level"`
	Length     int          `json:"length"`
	Ruleset    string       `json:"ruleset"`
	Kind       string       `json:"kind"`
}

GameMatchMessage is the message sent to the game about the configuration of the next match

type GamePlayer

type GamePlayer struct {
	TopName    string `json:"top_name"`
	BottomName string `json:"bottom_name"`
	Color      int    `json:"color"`
	ArcherType int    `json:"archer_type"`
}

GamePlayer is a player object to be consumed by the game

type IncomingGameMessage

type IncomingGameMessage struct {
	ID        uint        `json:"id"`
	MatchID   uint        `json:"match_id"`
	Type      string      `json:"type"`
	Data      interface{} `json:"data" sql:"-"`
	JSON      string      `json:"-"`
	Timestamp time.Time   `json:"timestamp"`
	RoundID   uint        `json:"round_id"`
	// contains filtered or unexported fields
}

An IncomingGameMessage is a message from the game put into the DB consumer queue

type KillMessage

type KillMessage struct {
	Player int `json:"player"`
	Killer int `json:"killer"`
	Cause  int `json:"cause"`
}

type LavaOrbMessage

type LavaOrbMessage struct {
	Player int  `json:"player"`
	State  bool `json:"state"`
}

type MatchUpdateMessage

type MatchUpdateMessage struct {
	Tournament uint                  `json:"tournament"`
	Match      *models.Match         `json:"match"`
	Players    []*models.PlayerState `json:"player_states"`
}

type PlayerStateUpdateMessage

type PlayerStateUpdateMessage struct {
	Tournament uint                `json:"tournament"`
	Match      int                 `json:"match"`
	State      *models.PlayerState `json:"state"`
}

type ScrollOrbMessage

type ScrollOrbMessage struct {
	State bool `json:"state"`
}

type ShieldMessage

type ShieldMessage struct {
	Player int  `json:"player"`
	State  bool `json:"state"`
}

type SlowOrbMessage

type SlowOrbMessage struct {
	State bool `json:"state"`
}

type StartMatchMessage

type StartMatchMessage struct{}

StartMatchMessage is sent when a match is starting

type StartPlayMessage

type StartPlayMessage struct{}

StartPlayMessage is sent to the game whenever one of the shot girls have indicated that the next round can start

type StartRoundMessage

type StartRoundMessage struct {
	Arrows []models.Arrows `json:"arrows"`
}

type TournamentCompleteMessage

type TournamentCompleteMessage struct{}

TournamentCompleteMessage is sent when the tournament is done

type WebsocketBroker

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

func NewWebsocketBroker

func NewWebsocketBroker(log *zap.Logger) *WebsocketBroker

func (*WebsocketBroker) DisableWebsocketUpdates

func (w *WebsocketBroker) DisableWebsocketUpdates()

DisableWebsocketUpdates... disables websocket updates.

func (*WebsocketBroker) EnableWebsocketUpdates

func (w *WebsocketBroker) EnableWebsocketUpdates()

EnableWebsocketUpdates... enables websocket updates.

func (*WebsocketBroker) HandleRequest

func (w *WebsocketBroker) HandleRequest(rw http.ResponseWriter, r *http.Request) error

HandleRequest passes the handling on to Melody

func (*WebsocketBroker) MatchEndUpdate

func (w *WebsocketBroker) MatchEndUpdate(t *models.Tournament, ms []*models.Match, runnerups []*models.PlayerSummary, summaries []*models.PlayerSummary) error

MatchEndUpdate sends the updates needed when a match is ended

func (*WebsocketBroker) MatchUpdate

func (w *WebsocketBroker) MatchUpdate(m *models.Match, sts []*models.PlayerState) error

MatchUpdate sends a status update for the entire match

func (*WebsocketBroker) MatchesUpdate

func (w *WebsocketBroker) MatchesUpdate(t *models.Tournament, ms []*models.Match) error

MatchesUpdate sends an update about the matches

func (*WebsocketBroker) PlayerSummariesUpdate

func (w *WebsocketBroker) PlayerSummariesUpdate(t *models.Tournament, summaries []*models.PlayerSummary) error

PlayerSummariesUpdate sends an update to the player summaries

func (*WebsocketBroker) TournamentUpdate

func (w *WebsocketBroker) TournamentUpdate(t *models.Tournament) error

TournamentUpdate sends an update about the tournament

func (*WebsocketBroker) WebsocketUpdate

func (w *WebsocketBroker) WebsocketUpdate(kind string, data interface{}) error

WebsocketUpdate sends an update to all listening sockets

type WingsMessage

type WingsMessage struct {
	Player int  `json:"player"`
	State  bool `json:"state"`
}

Jump to

Keyboard shortcuts

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