proto

package
v0.0.0-...-7787783 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatMessage

type ChatMessage struct {
	Message string
}

type InitMessage

type InitMessage struct {
	Update *UpdateMessage
	Size   *domain.FieldSize
}

InitMessage contains all info to initialize player.

type JoinMessage

type JoinMessage struct {
	Nick string
}

type LeaveMessage

type LeaveMessage struct{}

type Player

type Player interface {
	// UID must return unique player id.
	// This is must be same for every call.
	UID() uuid.UUID

	Init(InitMessage)
	Update(UpdateMessage)
}

type Server

type Server interface {
	// Connect must be called once and must be the first call.
	Connect(Player)

	Join(Player, JoinMessage)
	Leave(Player, LeaveMessage)
	Turn(Player, TurnMessage)
	Chat(Player, ChatMessage)

	// Disconnect must be called once and must be the last call.
	Disconnect(Player)
}

Server is an interface for player to use. All calls must be sequential, i.e. parallel calls are not allowed.

type TurnMessage

type TurnMessage struct {
	Direction domain.BaseDirection
}

type UpdateCell

type UpdateCell struct {
	Location domain.Pair
	Cell     domain.Cell
}

UpdateCell contains update for ID and Food at specified Location.

type UpdateChat

type UpdateChat struct {
	ID      domain.ObjectID
	Message string
}

type UpdateID

type UpdateID struct {
	ID domain.ObjectID

	Type  domain.CellType
	Color domain.Color
	Nick  string
}

type UpdateMessage

type UpdateMessage struct {
	IDUpdates   []UpdateID
	CellUpdates []UpdateCell
	ChatUpdates []UpdateChat
}

UpdateMessage contains all updates.

Jump to

Keyboard shortcuts

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