gecco.server.visibility
Interface VisibilityFilter

All Known Implementing Classes:
VisibilityManager

public interface VisibilityFilter

This interface acts as a filter between the server and the outside world. The server calls the methods here whenever something happens, and the class implementing this interface is then responsible for censoring this information before passing it on to the clients.

Author:
Karl Hasselström

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.
 void deleteUnit(Unit unit, double lastKnownX, double lastKnownY)
          This method is to be called whenever a unit is permanently taken off the map (typically, when it is killed).
 void resendAllData(String role)
          This method causes the server to resend all data to a role that the clients playing that role should know (and should be caching).
 void roleMessage(String role, Unit unit, String message)
          This method may be called to pass some information to a specific role regarding 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 to the owner of a unit.
 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)
          This method is to be called whenever an automaton changes state.
 void updateUnitPosition(Unit unit, double oldX, double oldY, double newX, double newY)
          This method is to be called whenever a unit changes its position.
 

Method Detail

updateAutomatonState

public void updateAutomatonState(int x,
                                 int y,
                                 int c)
This method is to be called whenever an automaton changes state.
Parameters:
x - The X coordinate of the automaton.
y - The Y coordinate of the automaton.
c - The new color of the automaton.

updateUnitPosition

public void updateUnitPosition(Unit unit,
                               double oldX,
                               double oldY,
                               double newX,
                               double newY)
This method is to be called whenever a unit changes its position.
Parameters:
unit - The unit.
oldX - The unit's old X coordinate.
oldY - The unit's old Y coordinate.
newX - The unit's new X coordinate.
newY - The unit's new Y coordinate.

deleteUnit

public void deleteUnit(Unit unit,
                       double lastKnownX,
                       double lastKnownY)
This method is to be called whenever a unit is permanently taken off the map (typically, when it is killed).
Parameters:
unit - The unit.
lastKnownX - The unit's last X coordinate.
lastKnownY - The unit's last Y coordinate.

actionBlocked

public void actionBlocked(Unit unit,
                          ActionDefinition action,
                          boolean isBlocked)
This method should be called whenever an action becomes blocked or unblocked.
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.
Parameters:
action - The action.
wasSuccessful - true if the action was successful, false if it failed.

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.
Parameters:
role - The role.
actionHandle - The action handle.

unitMessage

public void unitMessage(Unit unit,
                        String message)
This method may be called to pass some information to the owner of a unit. If message is null, no message is sent.
Parameters:
unit - The unit.
message - The message to be delivered.

roleMessage

public void roleMessage(String role,
                        Unit unit,
                        String message)
This method may be called to pass some information to a specific role regarding a unit. If message is null, no message is sent.
Parameters:
role - The role.
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.
Parameters:
time - A String representing the current game time.

unitPropertyChanged

public void unitPropertyChanged(Unit unit,
                                String key,
                                String newValue)
This method should be called whenever a unit property changes.
Parameters:
unit - The unit whose property changed.
key - The property that has changed.
newValue - The new value of the property.

resendAllData

public void resendAllData(String role)
This method causes the server to resend all data to a role that the clients playing that role should know (and should be caching). This is primarily used to provide clients with initial data when they join the game, but it could also be requested by a client who has forgotten things. The data is sent to all clients playing that role.
Parameters:
unit - The unit whose property changed.
key - The property that has changed.
newValue - The new value of the property.