types

package
v1.0.0-rc.20 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageSnakeCommandNorth = iota
	MessageSnakeCommandSouth
	MessageSnakeCommandWest
	MessageSnakeCommandEast
)

Variables

View Source
var (
	ErrDotUnmarshalJSONInsufficientInput = errors.Errorf("%s: %s",
		errDotUnmarshalJSONAnnotation, "insufficient input")
	ErrDotUnmarshalJSONInvalidStructure = errors.Errorf("%s: %s",
		errDotUnmarshalJSONAnnotation, "invalid structure")
)
View Source
var (
	ObjectTypeTokenSnake      = []byte(`"snake"`)
	ObjectTypeTokenApple      = []byte(`"apple"`)
	ObjectTypeTokenCorpse     = []byte(`"corpse"`)
	ObjectTypeTokenMouse      = []byte(`"mouse"`)
	ObjectTypeTokenWatermelon = []byte(`"watermelon"`)
	ObjectTypeTokenWall       = []byte(`"wall"`)
)

Functions

This section is empty.

Types

type Direction

type Direction string
const (
	DirectionZero  Direction = "zero"
	DirectionNorth Direction = "north"
	DirectionWest  Direction = "west"
	DirectionSouth Direction = "south"
	DirectionEast  Direction = "east"
)

func (Direction) ToMessageSnakeCommand

func (d Direction) ToMessageSnakeCommand() MessageSnakeCommand

type Dot

type Dot struct {
	X uint8
	Y uint8
}

func (Dot) String

func (d Dot) String() string

func (*Dot) UnmarshalJSON

func (d *Dot) UnmarshalJSON(b []byte) error

type GameEvent

type GameEvent struct {
	Type    GameEventType   `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

type GameEventType

type GameEventType string
const (
	GameEventTypeError   GameEventType = "error"
	GameEventTypeCreate  GameEventType = "create"
	GameEventTypeDelete  GameEventType = "delete"
	GameEventTypeUpdate  GameEventType = "update"
	GameEventTypeChecked GameEventType = "checked"
)

type Message

type Message struct {
	Type    MessageType     `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

type MessageSnakeCommand

type MessageSnakeCommand int8

func (MessageSnakeCommand) MarshalJSON

func (m MessageSnakeCommand) MarshalJSON() ([]byte, error)

func (MessageSnakeCommand) String

func (m MessageSnakeCommand) String() string

type MessageType

type MessageType string
const (
	MessageTypeGameEvent MessageType = "game"
	MessageTypePlayer    MessageType = "player"
	MessageTypeBroadcast MessageType = "broadcast"
)

type Object

type Object struct {
	Type      ObjectType `json:"type"`
	Id        uint32     `json:"id"`
	Dot       Dot        `json:"dot"`
	Dots      []Dot      `json:"dots"`
	Direction Direction  `json:"direction"`
}

func (*Object) GetDots

func (o *Object) GetDots() []Dot

func (*Object) GetType

func (o *Object) GetType() ObjectType

type ObjectType

type ObjectType uint8
const (
	ObjectTypeUnknown ObjectType = iota
	ObjectTypeSnake
	ObjectTypeApple
	ObjectTypeCorpse
	ObjectTypeMouse
	ObjectTypeWatermelon
	ObjectTypeWall
)

func (*ObjectType) UnmarshalJSON

func (t *ObjectType) UnmarshalJSON(b []byte) error

type PlayerEvent

type PlayerEvent struct {
	Type    PlayerEventType `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

type PlayerEventType

type PlayerEventType string
const (
	PlayerEventTypeSize      PlayerEventType = "size"
	PlayerEventTypeSnake     PlayerEventType = "snake"
	PlayerEventTypeNotice    PlayerEventType = "notice"
	PlayerEventTypeError     PlayerEventType = "error"
	PlayerEventTypeCountdown PlayerEventType = "countdown"
	PlayerEventTypeObjects   PlayerEventType = "objects"
)

type Size

type Size struct {
	Width  uint8 `json:"width"`
	Height uint8 `json:"height"`
}

Jump to

Keyboard shortcuts

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