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

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 server from the client's point of
 *  view.
 *
 * @author     Andreas Enblom
 * @created    June 27, 2001
 */
public interface Server {
    /**
     *  Try to connect to the given host and port.
     *
     * @param  host  Description of Parameter
     * @param  port  Description of Parameter
     * @return       A boolean indicating if the connection could be
     *      established.
     */
    public boolean connect(String host, int port);


    /**
     *  Disconnects from the server.
     */
    public void disconnect();


    /**
     *  After a connection has been established, call this to get the available
     *  roles.
     *
     * @return    The AvailableRoles value
     */
    public StringTokenizer getAvailableRoles();


    /**
     *  Join the game as the given role.
     *
     * @param  role  Description of Parameter
     * @return       A boolean indicating if the join was successful.
     */
    public boolean joinAsRole(String role);


    /**
     *  Return the position at the upper left corner of the map.
     *
     * @return    The MapUpperLeft value
     */
    public Point getMapUpperLeft();


    /**
     *  Returns the size of the map.
     *
     * @return    The MapSize value
     */
    public Dimension getMapSize();


    /**
     *  Returns the map of the game. This may take some time and the server
     *  should call method mapLoadingProgressUpdate of interface Client as more
     *  and more of the map is loaded.
     *
     * @return    The Map value
     */
    public Image getMap();


    /**
     *  Called by the client when it is ready to start receiving game messages
     *  from the server.
     */
    public void startGame();


    /**
     *  Execute the given Action and return a unique id of that executing
     *  action. Make sure the piece does not already exeute an action.
     *
     * @param  pieceHandle  Description of Parameter
     * @param  a            Description of Parameter
     * @return              Description of the Returned Value
     */
    public long doAction(int pieceHandle, Action a);


    /**
     *  Abort an action that has previously been asked to be executed.
     *
     * @param  actionId  Description of Parameter
     */
    public void abortAction(long actionId);
}
