es.ucm.fdi.hysteria.game.scene
Class Reaction

java.lang.Object
  extended by es.ucm.fdi.hysteria.game.scene.Reaction
All Implemented Interfaces:
java.io.Serializable

public class Reaction
extends java.lang.Object
implements java.io.Serializable

This class implements all that is needed to make the "characters" react to a given item. A reaction may enable or disable topics in any scene.

Author:
Sandor
See Also:
Serialized Form

Constructor Summary
Reaction(Item item, java.lang.String message, boolean extinguish)
          Constructor
 
Method Summary
 void addRelated(Topic t, boolean enable)
          Adds a new related topic, enabling or disabling it when the time comes.
 boolean extinguishesItem(Item i)
           
 java.lang.String getMessage(Item item)
          This method evaluates the item, and if it's the one stored, returns the message and enables or disables the related topics.
 boolean reactsTo(Item item)
          Is this item the cause of the reaction?
 boolean wasWatched()
          Was the reaction triggered?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reaction

public Reaction(Item item,
                java.lang.String message,
                boolean extinguish)
Constructor

Parameters:
item - The item to react to
message - The reaction message
Method Detail

reactsTo

public boolean reactsTo(Item item)
Is this item the cause of the reaction?

Parameters:
item - The item to evaluate
Returns:
True if the item given is the one stored

wasWatched

public boolean wasWatched()
Was the reaction triggered?

Returns:
True if the reaction was triggered

getMessage

public java.lang.String getMessage(Item item)
This method evaluates the item, and if it's the one stored, returns the message and enables or disables the related topics.

Parameters:
item - The item
Returns:
The message

addRelated

public void addRelated(Topic t,
                       boolean enable)
Adds a new related topic, enabling or disabling it when the time comes. If the reaction has already been watched, this method has no effect.

Parameters:
t - The topic
enable - The topic is going to be enabled, or disabled?

extinguishesItem

public boolean extinguishesItem(Item i)