gecco.server.visibility
Class VisibilityManager

java.lang.Object
  |
  +--gecco.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()
           
 
Method Summary
 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 setClient(Client client)
          Sets the client (the part of the communication system that lets the server send messages to the clients).
 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, int c)
          Description of the Method
 void updateUnitPosition(Unit unit, double oldX, double oldY, double newX, double newY)
          Description of the Method
 boolean[][] visibleAutomatons(String role)
          Returns, for every automaton on the map, true if the role can see it, and false otherwise.
 Set visibleUnits(String role)
          Returns the set of all units visible to the given role.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VisibilityManager

public VisibilityManager()
Method Detail

setClient

public void setClient(Client client)
Sets the client (the part of the communication system that lets the server send messages to the clients).
Parameters:
client - The new client.

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,
                                 int 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

visibleAutomatons

public boolean[][] visibleAutomatons(String role)
Returns, for every automaton on the map, true if the role can see it, and false otherwise.
Parameters:
role - The role.
Returns:
A map of visibility info.

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

visibleUnits

public Set visibleUnits(String role)
Returns the set of all units visible to the given role.
Parameters:
role - The role.
Returns:
The units visible to that role.

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.

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.