dummy

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dummy implements a mocked Warcraft III game client that can be used to add dummy players to lobbies.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJoinRejected       = errors.New("dummy: Join rejected")
	ErrGameFull           = errors.New("dummy: Join rejected (game full)")
	ErrGameStarted        = errors.New("dummy: Join rejected (game started)")
	ErrInvalidFirstPacket = errors.New("dummy: Invalid first packet")
)

Errors

Functions

func RejectReasonToError

func RejectReasonToError(r w3gs.RejectReason) error

RejectReasonToError converts w3gs.RejectReason to an appropriate error

Types

type Chat

type Chat struct {
	Sender  *w3gs.PlayerInfo
	Content string
}

Chat event

type Player

type Player struct {
	peer.Host
	network.W3GSConn

	// Set once before Join(), read-only after that
	HostAddr    string
	HostCounter uint32
	DialPeers   bool
}

Player represents a mocked player that can join a game lobby

func Join

func Join(addr string, name string, hostCounter uint32, entryKey uint32, listenPort int) (*Player, error)

Join a game lobby as a mocked player

func (*Player) ChangeColor

func (p *Player) ChangeColor(c uint8) error

ChangeColor to c

func (*Player) ChangeHandicap

func (p *Player) ChangeHandicap(h uint8) error

ChangeHandicap to h

func (*Player) ChangeRace

func (p *Player) ChangeRace(r w3gs.RacePref) error

ChangeRace to r

func (*Player) ChangeTeam

func (p *Player) ChangeTeam(t uint8) error

ChangeTeam to t

func (*Player) Close

func (p *Player) Close() error

Close closes all connections to host and peers

func (*Player) InitDefaultHandlers

func (p *Player) InitDefaultHandlers()

InitDefaultHandlers adds the default callbacks for relevant packets

func (*Player) Join

func (p *Player) Join() error

Join opens a new connection to host Not safe for concurrent invocation

func (*Player) Leave

func (p *Player) Leave(reason w3gs.LeaveReason) error

Leave game

func (*Player) Run

func (p *Player) Run() error

Run reads packets and emits an event for each received packet Not safe for concurrent invocation

func (*Player) Say

func (p *Player) Say(s string) error

Say sends a chat message

type Say

type Say struct {
	Content string
}

Say event

Jump to

Keyboard shortcuts

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