asteroid

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INIT      = "init"
	ATTACK    = "attack"
	RANK      = "rank"
	STATUS    = "status"
	ROUND     = "round"
	EGG       = "easterEgg"
	TIME      = "time"
	CLEAR     = "clear"
	CLEAR_ALL = "clearAll"
)

Variables

This section is empty.

Functions

func Attack

func Attack(c *gin.Context) (int, interface{})

func Clear

func Clear(c *gin.Context) (int, interface{})

func ClearAll

func ClearAll(c *gin.Context) (int, interface{})

func EasterEgg

func EasterEgg(c *gin.Context) (int, interface{})

func GetAsteroidStatus

func GetAsteroidStatus(c *gin.Context) (int, interface{})

func Init

func Init(function func() Greet)

Init is used to init the asteroid. A function will be given to get the team rank data.

func NewRoundAction

func NewRoundAction()

NewRoundAction runs in the new round begin. Refresh rank, clean all gameboxes' status, set round text, set time text.

func Rank

func Rank(c *gin.Context) (int, interface{})

func Round

func Round(c *gin.Context) (int, interface{})

func SendAttack

func SendAttack(from int, to int)

SendAttack sends an attack action message.

func SendStatus

func SendStatus(team int, statusString string)

SendStatus sends the teams' status message.

func ServeWebSocket

func ServeWebSocket(c *gin.Context)

ServeWebSocket handles websocket requests from the peer.

func Status

func Status(c *gin.Context) (int, interface{})

func Time

func Time(c *gin.Context) (int, interface{})

Types

type Greet

type Greet struct {
	Title string
	Time  int
	Round int
	Team  []Team
}

Greet will been sent when the client connect to the server firstly.

type Hub

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

Hub contains all the connections and the action signal.

type Team

type Team struct {
	Id    int
	Name  string
	Rank  int
	Image string
	Score int
}

Jump to

Keyboard shortcuts

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