gecco.client
Interface Client

All Known Implementing Classes:
Game

public interface Client

This is the interface that represents the client from the server's point of view. The client should keep a list of the pieces added, and their handles, as other methods should affect the pieces, and these methods use the handle as a reference to the pieces.

Author:
Andreas Enblom

Method Summary
 void actionReply(long id, boolean ok)
          Call this to indicate that the executed action with the given id has been finished.
 void addPiece(int handle, String name, Position pos, Set actions, Map properties, String type)
          Creates a new Piece and adds it to the game.
 void addPieceAction(int handle, Action a)
          Adds the given action to the list of actions that a piece can do.
 void connectionLost()
          Called to indicate that the connection to the server has been lost.
 void destroyPiece(int handle)
          This method is called to indicate that a piece has permanantly left the game.
 void hideMapPoint(int x, int y)
          Makes the given point (automaton) of the map invisible.
 void hideMapPoints(int[] x, int[] y)
          Makes the given points (automatons) of the map invisible.
 void mapLoadingProgressUpdate(double progress)
          The server calls this method as the initilizing loading of the map progresses.
 void mapUpdate(int[] x, int[] y, int[] colors)
          Update the given points to the corresponding colors.
 void mapUpdate(int x, int y, int color)
          Update the given point to the given color.
 void removePiece(int handle)
          Call this method to indicate that a piece is no longer visible and should be removed.
 void removePieceAction(int handle, Action a)
          Removes the given action from the list of actions the a piece can do.
 void timeUpdate(String time)
          This is called every now and then to tell the client what time it is.
 void unitMessage(int handle, String message)
          Sends a message that that describes that something has happened to the piece with the given handle.
 void updatePiece(int handle, Position newPosition)
          Sets a new position for the piece with the given handle.
 void updatePiece(int handle, Property[] newProperties)
          Adds/changed the given properties of the piece with the given handle.
 

Method Detail

mapUpdate

public void mapUpdate(int[] x,
                      int[] y,
                      int[] colors)
Update the given points to the corresponding colors. The colors are given as integers as described in java.awt.Color.
Parameters:
x - Description of Parameter
y - Description of Parameter
colors - Description of Parameter

mapUpdate

public void mapUpdate(int x,
                      int y,
                      int color)
Update the given point to the given color. The color is given as an integer as described in java.awt.Color.
Parameters:
x - Description of Parameter
y - Description of Parameter
color - Description of Parameter

hideMapPoints

public void hideMapPoints(int[] x,
                          int[] y)
Makes the given points (automatons) of the map invisible.
Parameters:
x - The x coordinates of the points.
y - The y coordinates of the points.

hideMapPoint

public void hideMapPoint(int x,
                         int y)
Makes the given point (automaton) of the map invisible.
Parameters:
x - The x coordinate of the point.
y - The y coordinate of the point.

addPiece

public void addPiece(int handle,
                     String name,
                     Position pos,
                     Set actions,
                     Map properties,
                     String type)
Creates a new Piece and adds it to the game. If a piece with the given handle already exists, it will be replaced. whether or not a piece with the given handle is already in the game is done.
Parameters:
handle - The unique handle of the new Piece.
name - The name of the Piece.
pos - The position of the new Piece.
actions - The actions of the Piece.
properties - The properties of the Piece.
type - The type of Piece. Type is not a property of a Piece, but the type is used to determine the symbol to use. Make sure the SymbolFactory has a symbol for this type of Piece.

updatePiece

public void updatePiece(int handle,
                        Property[] newProperties)
Adds/changed the given properties of the piece with the given handle.
Parameters:
handle - Description of Parameter
newProperties - Description of Parameter

updatePiece

public void updatePiece(int handle,
                        Position newPosition)
Sets a new position for the piece with the given handle.
Parameters:
handle - Description of Parameter
newPosition - Description of Parameter

removePiece

public void removePiece(int handle)
Call this method to indicate that a piece is no longer visible and should be removed.
Parameters:
handle - Description of Parameter

destroyPiece

public void destroyPiece(int handle)
This method is called to indicate that a piece has permanantly left the game.
Parameters:
handle - Description of Parameter

addPieceAction

public void addPieceAction(int handle,
                           Action a)
Adds the given action to the list of actions that a piece can do.
Parameters:
handle - The feature to be added to the PieceAction attribute
a - The feature to be added to the PieceAction attribute

removePieceAction

public void removePieceAction(int handle,
                              Action a)
Removes the given action from the list of actions the a piece can do.
Parameters:
handle - Description of Parameter
a - Description of Parameter

actionReply

public void actionReply(long id,
                        boolean ok)
Call this to indicate that the executed action with the given id has been finished.
Parameters:
id - The id of the executing action (as returned by the server, see Server.java).
ok - Did the action execute correctly, or was there an error?

unitMessage

public void unitMessage(int handle,
                        String message)
Sends a message that that describes that something has happened to the piece with the given handle.
Parameters:
handle - Description of Parameter
message - Description of Parameter

timeUpdate

public void timeUpdate(String time)
This is called every now and then to tell the client what time it is.
Parameters:
time - The current time

connectionLost

public void connectionLost()
Called to indicate that the connection to the server has been lost.

mapLoadingProgressUpdate

public void mapLoadingProgressUpdate(double progress)
The server calls this method as the initilizing loading of the map progresses. This method should be called as the client waits for a call to the server method getMap() to return.
Parameters:
progress - A number between 0 and 1 indicating how much of the map that has been loaded. (0 = nothing, 1 = all).