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

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.server.core;
import java.awt.Color;
import java.util.List;
import java.util.Map;

import java.util.Set;

/**
 *  Description of the Interface
 *
 * @author     Henrik Bäärnhielm or Henrik Hägerström
 * @created    April 30, 2001
 */
public interface Client {

    /**
     *  Tells the clients that the specified unit, which was previously
     *  invisible to them, is now visible. Note that the sets of actions and
     *  properties should be censored, so that properties are not sent to
     *  clients that are not observers.
     *
     * @param  role              The message is to be sent only to the client(s)
     *      playing this role.
     * @param  handle            Specifies which unit the message is about.
     * @param  name              the name of this particular unit.
     * @param  type              the name of this kind of unit.
     * @param  x                 the X coordinate of the unit.
     * @param  y                 the Y coordinate of the unit.
     * @param  unblockedActions  the set containing <code>ActionDefinitions
     *      </code>for all actions that the specified client(s) may order this
     *      unit to perform, and that are currently not blocked. May be <code>
     *      null</code> if the clients can't give this unit any orders at all.
     * @param  blockedActions    the set containing <code>ActionDefinitions
     *      </code>for all actions that the specified client(s) may order this
     *      unit to perform, and that are currently blocked (such as, for
     *      example, the command "Move" when the unit has no fuel left). May be
     *      <code>null</code> if the set is empty.
     * @param  properties        the properties (key/value pairs) of this unit
     *      that the specified client(s) can see. May be <code>null</code> .
     */
    public void unitVisible(String role, int handle, String name, String type,
            double x, double y, Set unblockedActions,
            Set blockedActions, Map properties);


    /**
     *  Tells the clients that the specified unit, which was previosly visible
     *  to them, is now invisible.
     *
     * @param  role    The message is to be sent only to the client(s) playing
     *      this role.
     * @param  handle  Specifies which unit the message is about.
     */
    public void unitInvisible(String role, int handle);


    /**
     *  Tells the clients that the specified unit, which was previosly visible
     *  to them, is now deleted.
     *
     * @param  role    The message is to be sent only to the client(s) playing
     *      this role.
     * @param  handle  Specifies which unit the message is about.
     */
    public void unitDeleted(String role, int handle);


    /**
     *  Tells the clients that the specified unit, which was and is visible to
     *  them, has moved.
     *
     * @param  role    The message is to be sent only to the client(s) playing
     *      this role.
     * @param  handle  Specifies which unit the message is about.
     * @param  newX    the new X coordinate of the unit.
     * @param  newY    the new Y coordinate of the unit.
     */
    public void unitMoved(String role, int handle, double newX, double newY);


    /**
     *  Tells the clients that a property of the specified unit, which was and
     *  is visible to them, has changed.
     *
     * @param  role      The message is to be sent only to the client(s) playing
     *      this role.
     * @param  handle    Specifies which unit the message is about.
     * @param  key       the property that has changed.
     * @param  newValue  the new value of the property.
     */
    public void unitPropertyChanged(String role, int handle,
            String key, String newValue);


    /**
     *  Tells the clients that an action of the specified unit, which was and is
     *  visible to them, is now blocked or unblocked (depending on <code>
     *  isBlocked</code> ).
     *
     * @param  role       The message is to be sent only to the client(s)
     *      playing this role.
     * @param  handle     Specifies which unit the message is about.
     * @param  action     the action that is now blocked or unblocked.
     * @param  isBlocked  Description of Parameter
     */
    public void unitActionBlocked(String role, int handle,
            ActionDefinition action, boolean isBlocked);


    /**
     *  Tells the clients that an automaton, which may or may not have been
     *  visible to them previously, is now visible and in a certain state. This
     *  message is intended to serve two purposes: a) tell the clients about a
     *  state change in an automaton they can already see, or b) tell them that
     *  an automaton they could not previously see is now visible (in which case
     *  they get to know what state it's in).
     *
     * @param  role   The message is to be sent only to the client(s) playing
     *      this role.
     * @param  x      the X coordinate of the automaton.
     * @param  y      the Y coordinate of the automaton.
     * @param  color  the color representing the current state.
     */
    public void automatonHasState(String role, int x, int y,
            Color color);


    /**
     *  Description of the Method
     *
     * @param  role          Description of Parameter
     * @param  pointObjects  Description of Parameter
     * @param  colors        Description of Parameter
     */
    public void automatonsHasState(String role, List pointObjects, List colors);


    /**
     *  Tells the clients that an automaton, which was previously visible to
     *  them, is now invisible.
     *
     * @param  role  The message is to be sent only to the client(s) playing
     *      this role.
     * @param  x     the X coordinate of the automaton.
     * @param  y     the Y coordinate of the automaton.
     */
    public void automatonInvisible(String role, int x, int y);


    /**
     *  Description of the Method
     *
     * @param  role          Description of Parameter
     * @param  pointObjects  Description of Parameter
     */
    public void automatonsInvisible(String role, List pointObjects);


    /**
     *  Tells the clients that an action was successfully completed.
     *
     * @param  role          The message is to be sent only to the client(s)
     *      playing this role.
     * @param  actionHandle  The handle for the completed action.
     * @param  unitMessage   Description of Parameter
     */
    public void actionCompleted(String role, int actionHandle, String unitMessage);


    /**
     *  Tells the clients that an action has failed.
     *
     * @param  role          The message is to be sent only to the client(s)
     *      playing this role.
     * @param  actionHandle  The handle for the failed action.
     * @param  errorMessage  A message explaining what caused the failure.
     */
    public void actionFailed(String role, int actionHandle, String errorMessage);


    /**
     *  Description of the Method
     *
     * @param  role         Description of Parameter
     * @param  unitHandle   Description of Parameter
     * @param  unitMessage  Description of Parameter
     */
    public void unitMessage(String role, int unitHandle, String unitMessage);

}
