Added documentation
This commit is contained in:
@@ -17,6 +17,9 @@ func connect(server string, port int) (*websocket.Conn, error) {
|
||||
return websocket.Dial(url, "", origin)
|
||||
}
|
||||
|
||||
// Client keeps track of connection to server and has two interesting methods:
|
||||
// Negociate and Play. Users of this struct will likely use most everything as
|
||||
// is while defining their own Player to specify desired game play behavior.
|
||||
type Client struct {
|
||||
ForceJSON bool
|
||||
GameId string
|
||||
@@ -42,6 +45,7 @@ type decoder interface {
|
||||
Decode(v interface{}) error
|
||||
}
|
||||
|
||||
// Negociate runs through the hackerbots negociation protocol.
|
||||
func (c *Client) Negociate() (err error) {
|
||||
if c.Verbose {
|
||||
log.Printf("%s: trying to connect to game '%s'", c.Name, c.GameId)
|
||||
@@ -147,6 +151,9 @@ func (c *Client) Negociate() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Play contains the main game run loop. It gets a botserv.Boardstate from the
|
||||
// server, and passes this along to the embedded Player. Following this it
|
||||
// sends the server the Player's instruction.
|
||||
func (c *Client) Play() error {
|
||||
log.Printf("%s: starting loop", c.Name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user