Documentation ¶
Overview ¶
Package client handles drawing the UI, interfacing with the player, and talking to the server.
TODO: SpawnNPC() should always trigger a new goroutine to handle that NPCs
Index ¶
- func CheckError(e error)
- type Actors
- type Client
- func (c *Client) Addr() string
- func (c *Client) HandleAction(a engine.Action)
- func (c *Client) Init() *engine.UI
- func (c *Client) Maps() map[string]engine.Map
- func (c *Client) Move(a engine.Action)
- func (c *Client) Ping()
- func (c *Client) SetAddr(addr string)
- func (c *Client) SetRPC(conn *rpc.Client)
- func (c *Client) Spawn(a ...engine.Actor)
- func (c *Client) Squad() []engine.Actor
- type Map
- type MoveAction
- type Player
- func (p *Player) ID() string
- func (p *Player) Index() int
- func (p *Player) JSON() PlayerJSON
- func (p *Player) MarshalJSON() ([]byte, error)
- func (p *Player) Move(pos engine.Pos) bool
- func (p *Player) Name() string
- func (p *Player) Pos() *engine.Pos
- func (p *Player) SetIndex(i int)
- func (p *Player) SetPos(pos engine.Pos)
- func (p *Player) Sprite() termbox.Cell
- func (p *Player) UnmarshalJSON(data []byte) error
- type PlayerJSON
- type Pong
- type Server
- func (s *Server) Conns() map[string]*engine.Conn
- func (s *Server) HandleRequests()
- func (s *Server) Move(args *MoveAction, reply *engine.ActionResponse) error
- func (s *Server) Ping(addr *string, reply *Pong) error
- func (s *Server) SetPort(port string)
- func (s *Server) Spawn(args *SpawnAction, reply *bool) error
- type SpawnAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckError ¶
func CheckError(e error)
Types ¶
type Actors ¶
Actors is a wrapper for an array of Actors. It is necessary to Unmarshal objects that implement Actor.
func (*Actors) UnmarshalJSON ¶
Takes JSON data and reads it into this array.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) HandleAction ¶
func (*Client) Ping ¶
func (c *Client) Ping()
Ping asks the server for all information relevant to the client.
type Map ¶
type Map struct { Name string // The key that identifies this map in the server. Height int // The number of vertical tiles. Width int // The number of horizontal tiles. Players Actors Tiles [][]engine.Tile // contains filtered or unexported fields }
Map is a 2 dimensional plane containing tiles, objects and Actors. Each map will continue to Tick, so long as it has at least one active connection.
func (*Map) AllTiles ¶
AllTiles returns all of the map's tiles. It is congruent with calling TileSlice(0, 0, Map.Width, Map.Height)
func (*Map) Tick ¶
func (m *Map) Tick()
Tick moves time forward one tick after it has received a valid Action from each Actor on the Map. Tick blocks all NPCs and connections.
Currently, Actions are evaluated in FIFO order, meaning that Players' actions
will almost always be evaluated last.
func (*Map) TileSlice ¶
TileSlice returns the contents of all tiles within the bounds of [(x1, y1), (x2, y2)]
func (*Map) WaitForTurn ¶
WaitForTurn blocks an actor until Tick gives them priority.
type MoveAction ¶
type MoveAction struct { Caller string // The originator of the MocwAction. Target string // The name of the Actor to move. Pos rogue.Pos // The coordinates to move them to. }
MoveAction is used to move Objects.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
func (*Player) JSON ¶
func (p *Player) JSON() PlayerJSON
func (*Player) MarshalJSON ¶
MarshalJSON converts the Player into JSON bytes.
func (*Player) UnmarshalJSON ¶
UnmarshalJSON reads JSON data into this Player.
type PlayerJSON ¶
PlayerJSON allows Player objects to be converted into JSON and transported via JSON RPC.
type Server ¶
Game logic is handled on the server.
Each world gets at least one goroutine, with each active map getting its own goroutine as well.
func (*Server) HandleRequests ¶
func (s *Server) HandleRequests()
func (*Server) Move ¶
func (s *Server) Move(args *MoveAction, reply *engine.ActionResponse) error
type SpawnAction ¶
type SpawnAction struct { Caller string Actors Actors // TODO: (8) Change to object rather than Actor. }
MoveAction is used to spawn Objects.