game

package
v0.0.0-...-ce9d6f3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "/snake/game/0.1.0"

Variables

This section is empty.

Functions

func ToBytesUint32

func ToBytesUint32(n uint32) []byte

func ToUint32Bytes

func ToUint32Bytes(b []byte) (n uint32)

Types

type GameEstablished

type GameEstablished struct {
	Facilitator peer.ID
	Game        *GameInstance
}

type GameInstance

type GameInstance struct {
	Seed int64
	// contains filtered or unexported fields
}

func NewGameInstance

func NewGameInstance() *GameInstance

func (*GameInstance) AddPeer

func (gi *GameInstance) AddPeer(s network.Stream)

func (*GameInstance) Close

func (gi *GameInstance) Close()

func (*GameInstance) IncommingMoves

func (gi *GameInstance) IncommingMoves() <-chan interface{}

func (*GameInstance) PeerCount

func (gi *GameInstance) PeerCount() int

func (*GameInstance) PlayersIDs

func (gi *GameInstance) PlayersIDs() []peer.ID

func (*GameInstance) RemovePeer

func (gi *GameInstance) RemovePeer(p peer.ID)

func (*GameInstance) Run

func (gi *GameInstance) Run() int64

func (*GameInstance) SelfID

func (gi *GameInstance) SelfID() peer.ID

func (*GameInstance) SendMove

func (gi *GameInstance) SendMove(move core.Direction) (err error)

type GameInstanceEvent

type GameInstanceEvent interface{}

type GameService

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

func NewGameService

func NewGameService(h host.Host) *GameService

func (*GameService) Close

func (g *GameService) Close()

func (*GameService) Connect

func (g *GameService) Connect(ctx context.Context, p peer.ID) error

func (*GameService) Disconnect

func (g *GameService) Disconnect(p peer.ID)

func (*GameService) GameHandler

func (g *GameService) GameHandler(s network.Stream)

func (*GameService) GetInstance

func (g *GameService) GetInstance() *GameInstance

Jump to

Keyboard shortcuts

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