/***********************************************************************

GECCO, a platform for command and control gaming

Copyright (C) 2001 Henrik Bäärnhielm, Andreas Enblom, Niklas
Hallenfur, Karl Hasselström, Henrik Hägerström, Oskar Linde, Jing Fu
Zi and Jon Åslund

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.

***********************************************************************/

package gecco.client;
import java.awt.*;

import java.util.*;

/**
 *  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
 * @created    June 27, 2001
 */
public interface Client {
    /**
     *  Update the given points to the corresponding colors. The colors are
     *  given as integers as described in java.awt.Color.
     *
     * @param  points  Description of Parameter
     * @param  colors  Description of Parameter
     */
    public void mapUpdate(Point[] points, int[] colors);


    /**
     *  Update the given point to the given color. The color is given as an
     *  integer as described in java.awt.Color.
     *
     * @param  p      Description of Parameter
     * @param  color  Description of Parameter
     */
    public void mapUpdate(Point p, int color);


    /**
     *  Makes the given points of the map invisible.
     *
     * @param  points  Description of Parameter
     */
    public void invisibilizeMapPoints(Point[] points);


    /**
     *  Makes the given point of the map invisible.
     *
     * @param  p  Description of Parameter
     */
    public void invisibilizeMapPoint(Point p);


    /**
     *  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.
     *
     * @param  handle      The unique handle of the new Piece.
     * @param  name        The name of the Piece.
     * @param  pos         The position of the new Piece.
     * @param  actions     The actions of the Piece.
     * @param  properties  The properties of the Piece.
     * @param  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.
     */
    public void addPiece(int handle, String name, Position pos,
            Enumeration actions, Enumeration properties,
            String type);


    /**
     *  Adds/changed the given properties of the piece with the given handle.
     *
     * @param  handle         Description of Parameter
     * @param  newProperties  Description of Parameter
     */
    public void updatePiece(int handle, Property[] newProperties);


    /**
     *  Sets a new position for the piece with the given handle.
     *
     * @param  handle       Description of Parameter
     * @param  newPosition  Description of Parameter
     */
    public void updatePiece(int handle, Position newPosition);


    /**
     *  Call this method to indicate that a piece is no longer visible and
     *  should be removed.
     *
     * @param  handle  Description of Parameter
     */
    public void removePiece(int handle);


    /**
     *  This method is called to indicate that a piece has permanantly left the
     *  game.
     *
     * @param  handle  Description of Parameter
     */
    public void destroyPiece(int handle);


    /**
     *  Adds the given action to the list of actions that a piece can do.
     *
     * @param  handle  The feature to be added to the PieceAction attribute
     * @param  a       The feature to be added to the PieceAction attribute
     */
    public void addPieceAction(int handle, Action a);


    /**
     *  Removes the given action from the list of actions the a piece can do.
     *
     * @param  handle  Description of Parameter
     * @param  a       Description of Parameter
     */
    public void removePieceAction(int handle, Action a);


    /**
     *  Call this to indicate that the executed action with the given id has
     *  been finished.
     *
     * @param  id       The id of the executing action (as returned by the
     *      server, see Server.java).
     * @param  ok       Did the action execute correctly, or was there an error?
     * @param  message  A message that describes what happened when the action
     *      was finished.
     */
    public void actionReply(long id, boolean ok, String message);


    /**
     *  Sends a message that that describes that something has happened to the
     *  piece with the given handle.
     *
     * @param  handle   Description of Parameter
     * @param  message  Description of Parameter
     */
    public void unitMessage(int handle, String message);


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


    /**
     *  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.
     *
     * @param  progress  A number between 0 and 1 indicating how much of the map
     *      that has been loaded. (0 = nothing, 1 = all).
     */
    public void mapLoadingProgressUpdate(double progress);
}
