Documentation ¶
Index ¶
- Constants
- func AcceptCommands(playerId string, connection *rpc.Client)
- func CreateServerConnection(username, password, address string) (string, *rpc.Client, error)
- func PrintMap(boardSize uint8, icon func(x, y int) string) string
- func PrintTeamCounts(game *game.Game)
- func RunServer(path string, maxPlayers, boardSize, shipLimit int, pass, adminPass string, ...)
- func StartGameServer(newGame *game.Game)
- type ClientCommand
- type JoinDetails
- type LoginCredentials
- type Result
- type Server
- func (t *Server) ChatHelp(args ClientCommand, response *string) error
- func (t *Server) Deploy(args ClientCommand, response *string) error
- func (t *Server) EchoTest(args ClientCommand, response *string) error
- func (t *Server) JoinGame(login LoginCredentials, info *JoinDetails) error
- func (t *Server) Map(args ClientCommand, response *string) error
- func (t *Server) Mutiny(args ClientCommand, response *string) error
- func (t *Server) Players(args ClientCommand, response *string) error
- func (t *Server) Points(args ClientCommand, response *string) error
- func (t *Server) Radar(args ClientCommand, response *string) error
- func (t *Server) Rename(args ClientCommand, response *string) error
- func (t *Server) Shutdown(args ClientCommand, response *string) error
- func (t *Server) Target(args ClientCommand, response *string) error
- func (t *Server) Teams(args ClientCommand, response *string) error
Constants ¶
const RPC_PORT = 51832
RPC_PORT is the TCP port that the server listens to
Variables ¶
This section is empty.
Functions ¶
func AcceptCommands ¶
AcceptCommands takes a the UserID and RPC Client object and prompts the user for keyboard input. If the first token of the input matches a key in hashmap of commands their UserID and full input are sent to the server wrapped in ClientCommand struct. Response string from server is printed to screen.
func CreateServerConnection ¶
CreateServerConnection takes a username, password and network address and attempts to connect to a Game server running at that location. If a user using that username has never connected to that server before a Player is created on the server with the given username and password.
If a Player already exists on that server the password entered must be the password they entered when they first logged in or else they must re-login with a new username/password combo.
Upon successful login a string (their UserID) and the RPC Client object are returned, or an error.
func PrintTeamCounts ¶
PrintTeamCounts prints a list of all the Teams and the number of users on each team
func StartGameServer ¶
StartGameServer creates the Server using a new Game, sets up the RPC Listener and handles all incoming Client requests.
Types ¶
type ClientCommand ¶
ClientCommand wraps the PlayerID and command input into a single struct to send to server
type JoinDetails ¶
JoinDetails is information sent back to the Client after a successful login telling the Client program their PlayerID and the team they've been assigned
type LoginCredentials ¶
LoginCredentials is the Username/Password combo passed by the client when attempting to log in
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a struct exposed to clients and acts a buffer between clients and the actual Game
func (*Server) EchoTest ¶
func (t *Server) EchoTest(args ClientCommand, response *string) error
EchoTest is used to confirm we are connected and the Client can send commands, the Server can receive them, and the Server can send a response that the Client can receive
func (*Server) JoinGame ¶
func (t *Server) JoinGame(login LoginCredentials, info *JoinDetails) error
JoinGame joins a Player to the running Server using LoginCredentials.
func (*Server) Mutiny ¶
func (t *Server) Mutiny(args ClientCommand, response *string) error
Mutiny will start a new team and steal half the deployment points, but your score is reset to 10
func (*Server) Players ¶
func (t *Server) Players(args ClientCommand, response *string) error
Players serves a list of Players on a given team# (team# based on Teams command)
func (*Server) Rename ¶
func (t *Server) Rename(args ClientCommand, response *string) error
Rename a team