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

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

public class Scene
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class implements a way to have "characters" in the game to interact with.

Author:
Sandor
See Also:
Serialized Form

Field Summary
protected  boolean _enabled
          Is the scene enabled?
protected  java.lang.String _image
          Scene image
protected  es.ucm.fdi.hysteria.game.scene.Intro _intro
          The scene intro
protected  ReactionManager _reactions
          The reaction manager
protected  java.util.Vector<Scene> _relatedToDisable
          The scenes related to this one
protected  java.util.Vector<Scene> _relatedToEnable
          The scenes related to this one
protected  es.ucm.fdi.hysteria.game.scene.TopicManager _topics
          The topic manager
 
Constructor Summary
Scene(java.lang.String introText, java.lang.String reactionDefault)
          Constructor.
Scene(java.lang.String introText, java.lang.String reactionDefault, boolean enabled)
          Constructor
Scene(java.lang.String introText, java.lang.String reactionDefault, boolean enabled, java.lang.String image)
          Constructor
Scene(java.lang.String introText, java.lang.String reactionDefault, java.lang.String image)
          Constructor
 
Method Summary
 void addReaction(Reaction r)
          It adds a reaction to the manager
 boolean addRelated(Scene s, boolean enable)
          It adds a related scene.
 void addTopic(Topic t)
          It adds a topic to the topic Manager
protected  boolean checkFinished()
          It checks if the scene is finished, and then, updates the related ones.
 java.lang.String getImage()
           
 java.lang.String getText(int i)
          It returns the text of a topic, identified by its number
 java.lang.String getText(java.lang.String title)
          It returns the text of a topic, identified by its title
 java.util.Vector<java.lang.String> getTitles()
          It returns all topic titles
 ItemRepository getTopicItems(int i)
          It returns the items given by a topic, identified by its number
 ItemRepository getTopicItems(java.lang.String title)
          It returns the items given when asking for a given topic
 boolean hasImage()
           
 boolean hasItems(int i)
          It returns true if a topic gives items, identified by its number
 boolean hasItems(java.lang.String title)
          It returns true if a topic gives items, identified by its title
 boolean hasTopic(int i)
          It checks if a topic exists, with a given number
 boolean hasTopic(java.lang.String s)
          It checks if a topic exists, with a given title
 boolean introWatched()
          Was the intro watched?
 boolean isEnabled()
          Is the scene enabled?
 java.lang.String presentItem(Item i)
          It presents a given item to the character, and returns the reaction
 boolean presentItemExtinguish(Item i)
           
 java.lang.String reportIntro()
          It returns the intro text
 void setEnabled(boolean enabled)
          Sets the "enable" flag of this scene to the value given
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_enabled

protected boolean _enabled
Is the scene enabled?


_intro

protected es.ucm.fdi.hysteria.game.scene.Intro _intro
The scene intro


_topics

protected es.ucm.fdi.hysteria.game.scene.TopicManager _topics
The topic manager


_reactions

protected ReactionManager _reactions
The reaction manager


_relatedToEnable

protected java.util.Vector<Scene> _relatedToEnable
The scenes related to this one


_relatedToDisable

protected java.util.Vector<Scene> _relatedToDisable
The scenes related to this one


_image

protected java.lang.String _image
Scene image

Constructor Detail

Scene

public Scene(java.lang.String introText,
             java.lang.String reactionDefault)
Constructor. It builds a disabled scene.

Parameters:
introText - The intro message
reactionDefault - The default reaction

Scene

public Scene(java.lang.String introText,
             java.lang.String reactionDefault,
             java.lang.String image)
Constructor

Parameters:
introText - The intro message
reactionDefault - The default reaction
image - The scene image

Scene

public Scene(java.lang.String introText,
             java.lang.String reactionDefault,
             boolean enabled)
Constructor

Parameters:
introText - The intro message
reactionDefault - The default reaction
enabled - Is the scene enabled?

Scene

public Scene(java.lang.String introText,
             java.lang.String reactionDefault,
             boolean enabled,
             java.lang.String image)
Constructor

Parameters:
introText - The intro message
reactionDefault - The default reaction
enabled - Is the scene enabled?
image - The scene image
Method Detail

addTopic

public void addTopic(Topic t)
It adds a topic to the topic Manager

Parameters:
t - The topic

addRelated

public boolean addRelated(Scene s,
                          boolean enable)
It adds a related scene.

Parameters:
s - The scene
enable - It has to enable, or disable the scene?
Returns:
True if the operation was successful

addReaction

public void addReaction(Reaction r)
It adds a reaction to the manager

Parameters:
r - The reaction

isEnabled

public boolean isEnabled()
Is the scene enabled?

Returns:
True if it's enabled

setEnabled

public void setEnabled(boolean enabled)
Sets the "enable" flag of this scene to the value given

Parameters:
enabled - The value

introWatched

public boolean introWatched()
Was the intro watched?

Returns:
True if the intro was watched

reportIntro

public java.lang.String reportIntro()
It returns the intro text

Returns:
The text

getTitles

public java.util.Vector<java.lang.String> getTitles()
It returns all topic titles

Returns:
All titles

getText

public java.lang.String getText(int i)
It returns the text of a topic, identified by its number

Parameters:
i - The topic number
Returns:
The text

getText

public java.lang.String getText(java.lang.String title)
It returns the text of a topic, identified by its title

Parameters:
title - The topic title
Returns:
The text

hasItems

public boolean hasItems(int i)
It returns true if a topic gives items, identified by its number

Parameters:
i - The topic number
Returns:
True if it gives items

hasItems

public boolean hasItems(java.lang.String title)
It returns true if a topic gives items, identified by its title

Parameters:
title - The topic title
Returns:
True if it gives items

getTopicItems

public ItemRepository getTopicItems(int i)
It returns the items given by a topic, identified by its number

Parameters:
i - The topic number
Returns:
The items linked

getTopicItems

public ItemRepository getTopicItems(java.lang.String title)
It returns the items given when asking for a given topic

Parameters:
title - The topic title
Returns:
The items linked

checkFinished

protected boolean checkFinished()
It checks if the scene is finished, and then, updates the related ones.

Returns:
True if finished

hasTopic

public boolean hasTopic(int i)
It checks if a topic exists, with a given number

Parameters:
i - The number
Returns:
True if it exists

hasTopic

public boolean hasTopic(java.lang.String s)
It checks if a topic exists, with a given title

Parameters:
s - The title
Returns:
True if it exists

presentItem

public java.lang.String presentItem(Item i)
It presents a given item to the character, and returns the reaction

Parameters:
i - The item
Returns:
The reaction

presentItemExtinguish

public boolean presentItemExtinguish(Item i)

hasImage

public boolean hasImage()

getImage

public java.lang.String getImage()