gecco.server.visibility
Class VisibilityManager

java.lang.Object
  extended bygecco.server.visibility.VisibilityManager
All Implemented Interfaces:
VisibilityFilter, VisibilityInfo

public class VisibilityManager
extends Object
implements VisibilityFilter, VisibilityInfo

Description of the Class

Author:
Karl Hasselström, Henrik Hägerström

Constructor Summary
VisibilityManager(Client client)
          Constructor for the VisibilityManager object
 
Method Summary
 void abortAllActions(Unit unit)
          Abort all actions for a unit
 void actionBlocked(Unit unit, ActionDefinition action, boolean isBlocked)
          This method should be called whenever an action becomes blocked or unblocked.
 void actionCompleted(Action action, boolean wasSuccessful)
          This method is to be called whenever the execution of an action is finished.
 void actionRejected(String role, int actionHandle)
          This method is to be called when a role requests that an action be carried out, and that is for some reason impossible.
 boolean canSeeAutomaton(String role, int x, int y, Unit excludeUnit)
          Description of the Method
 boolean canSeePosition(String role, double x, double y)
          Description of the Method
 boolean canSeeUnit(String role, Unit unit, Unit excludeUnit)
          Description of the Method
 void deleteUnit(Unit unit, double lastKnownX, double lastKnownY)
          Description of the Method
 void resendAllData(String role)
          Description of the Method
 void roleMessage(String role, Unit unit, String message)
          This method may be called to pass some information to a specific role redarding a unit.
 void timeUpdate(String time)
          This method may be called to tell the clients that some time has passed.
 void unitMessage(Unit unit, String message)
          This method may be called to pass some information regarding a unit, such as when it has finished an action.
 void unitPropertyChanged(Unit unit, String key, String newValue)
          This method should be called whenever a unit property changes.
 void updateAutomatonState(int x, int y, Color c)
          Description of the Method
 void updateUnitPosition(Unit unit, double oldX, double oldY, double newX, double newY)
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VisibilityManager

public VisibilityManager(Client client)
Constructor for the VisibilityManager object

Parameters:
client - The client.
Method Detail

canSeePosition

public boolean canSeePosition(String role,
                              double x,
                              double y)
Description of the Method

Specified by:
canSeePosition in interface VisibilityInfo
Parameters:
role - Description of Parameter
x - Description of Parameter
y - Description of Parameter
Returns:
Description of the Returned Value

updateAutomatonState

public void updateAutomatonState(int x,
                                 int y,
                                 Color c)
Description of the Method

Specified by:
updateAutomatonState in interface VisibilityFilter
Parameters:
x - Description of Parameter
y - Description of Parameter
c - Description of Parameter

canSeeAutomaton

public boolean canSeeAutomaton(String role,
                               int x,
                               int y,
                               Unit excludeUnit)
Description of the Method

Specified by:
canSeeAutomaton in interface VisibilityInfo
Parameters:
role - Description of Parameter
x - Description of Parameter
y - Description of Parameter
excludeUnit - Description of Parameter
Returns:
Description of the Returned Value

canSeeUnit

public boolean canSeeUnit(String role,
                          Unit unit,
                          Unit excludeUnit)
Description of the Method

Specified by:
canSeeUnit in interface VisibilityInfo
Parameters:
role - Description of Parameter
unit - Description of Parameter
excludeUnit - Description of Parameter
Returns:
Description of the Returned Value

updateUnitPosition

public void updateUnitPosition(Unit unit,
                               double oldX,
                               double oldY,
                               double newX,
                               double newY)
Description of the Method

Specified by:
updateUnitPosition in interface VisibilityFilter
Parameters:
unit - Description of Parameter
oldX - Description of Parameter
oldY - Description of Parameter
newX - Description of Parameter
newY - Description of Parameter

deleteUnit

public void deleteUnit(Unit unit,
                       double lastKnownX,
                       double lastKnownY)
Description of the Method

Specified by:
deleteUnit in interface VisibilityFilter
Parameters:
unit - Description of Parameter
lastKnownX - Description of Parameter
lastKnownY - Description of Parameter

resendAllData

public void resendAllData(String role)
Description of the Method

Specified by:
resendAllData in interface VisibilityFilter
Parameters:
role - Description of Parameter

actionBlocked

public void actionBlocked(Unit unit,
                          ActionDefinition action,
                          boolean isBlocked)
This method should be called whenever an action becomes blocked or unblocked.

Specified by:
actionBlocked in interface VisibilityFilter
Parameters:
unit - The unit whose action gets blocked or unblocked.
action - The action that is now blocked or unblocked.
isBlocked - true if the action is blocked, false if it is unblocked.

actionCompleted

public void actionCompleted(Action action,
                            boolean wasSuccessful)
This method is to be called whenever the execution of an action is finished.

Specified by:
actionCompleted in interface VisibilityFilter
Parameters:
action - The action.
wasSuccessful - true if the action was successful, false if it failed.

unitPropertyChanged

public void unitPropertyChanged(Unit unit,
                                String key,
                                String newValue)
This method should be called whenever a unit property changes.

Specified by:
unitPropertyChanged in interface VisibilityFilter
Parameters:
unit - The unit whose property changed.
key - The property that has changed.
newValue - The new value of the property.

actionRejected

public void actionRejected(String role,
                           int actionHandle)
This method is to be called when a role requests that an action be carried out, and that is for some reason impossible.

Specified by:
actionRejected in interface VisibilityFilter
Parameters:
role - The role.
actionHandle - The action handle.

roleMessage

public void roleMessage(String role,
                        Unit unit,
                        String message)
This method may be called to pass some information to a specific role redarding a unit. If message is null, no message is sent.

Specified by:
roleMessage in interface VisibilityFilter
Parameters:
role - The role.
unit - The unit.
message - The message to be delivered.

unitMessage

public void unitMessage(Unit unit,
                        String message)
This method may be called to pass some information regarding a unit, such as when it has finished an action.

Specified by:
unitMessage in interface VisibilityFilter
Parameters:
unit - The unit.
message - The message to be delivered.

abortAllActions

public void abortAllActions(Unit unit)
Description copied from interface: VisibilityFilter
Abort all actions for a unit

Specified by:
abortAllActions in interface VisibilityFilter

timeUpdate

public void timeUpdate(String time)
This method may be called to tell the clients that some time has passed.

Specified by:
timeUpdate in interface VisibilityFilter
Parameters:
time - A String representing the current game time.