gecco.server.core
Class EventHandler

java.lang.Object
  |
  +--gecco.server.core.EventHandler
Direct Known Subclasses:
GameEventPointEventHandler, WarUnitEventHandler

public abstract class EventHandler
extends Object

This class represents an event handler for a unit. All event handlers should be subclasses of this class. An event handler should take care of the occasions when an event is sent to a unit, for example, when the unit stands on an automaton that affects unit in some way.

Author:
Henrik Bäärnhielm, Karl Hasselström, Henrik Hägeström.

Constructor Summary
EventHandler()
          Constructor for the EventHandler object
 
Method Summary
abstract  void handleEvent(UnitEvent event, Unit unit)
          The method that is called by the game engine when a unit of a unit type with this event handler receives a message.
protected  void sendUnitMessage(Unit unit, String unitMessage)
          Sends a message to all observers of the given unit (as well as to all God's Eye roles).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventHandler

public EventHandler()
Constructor for the EventHandler object

Method Detail

handleEvent

public abstract void handleEvent(UnitEvent event,
                                 Unit unit)
The method that is called by the game engine when a unit of a unit type with this event handler receives a message. Most of the code of the event handler will be in this method.

Parameters:
event - The event.
unit - The unit affected by the event.

sendUnitMessage

protected void sendUnitMessage(Unit unit,
                               String unitMessage)
Sends a message to all observers of the given unit (as well as to all God's Eye roles).

Parameters:
unit - The unit.
unitMessage - The message to be sent.