|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectes.ucm.fdi.hysteria.game.Location
public class Location
This class represents a room in the adventure game. Every room has no more than 4 doors and contains a textual description about itself. The rooms can also contain items that the player can pick and drop. Each item have a unique name, that is, it is not allowed to be two different items with the same name in a room.
Field Summary | |
---|---|
protected Scene |
_activeScene
The active scene |
protected java.lang.String |
_desc
Room description |
protected java.util.EnumMap<Game.Direction,Location> |
_doors
Adjacent rooms. |
protected java.lang.String |
_exit
Exit Message |
protected java.lang.String |
_imagePath
Image of the room |
protected ItemRepository |
_items
The items contained in the room |
protected boolean |
_light
|
protected java.lang.String |
_musicPath
Music of the room |
protected java.lang.String |
_name
Name of the room |
protected java.util.EnumMap<Game.Direction,Obstacle> |
_obstacles
Adjacent obstacles. |
protected java.util.Vector<Scene> |
_scenes
Possible scenes on this location |
protected int |
_threshold
Exit threshold |
protected boolean |
_visited
|
Constructor Summary | |
---|---|
Location(java.lang.String name,
java.lang.String desc)
Constructor for class Room |
|
Location(java.lang.String name,
java.lang.String desc,
boolean light)
|
|
Location(java.lang.String name,
java.lang.String desc,
boolean light,
int exitThreshold,
java.lang.String exitMessage)
|
|
Location(java.lang.String name,
java.lang.String desc,
int exitThreshold,
java.lang.String exitMessage)
|
Method Summary | |
---|---|
void |
addItem(Item item)
|
void |
addObstacle(Game.Direction dir,
Obstacle o)
|
void |
addScene(Scene s)
|
boolean |
checkSceneIntro()
|
java.lang.Object |
clone()
|
java.util.Set<Item> |
getAllItems()
Reports the names of all the items of the location. |
java.util.Vector<java.lang.String> |
getAvailableTopics()
|
Location |
getConnectedLocation(Game.Direction direction)
Gets the connected location to a given direction. |
java.lang.String |
getDescription()
|
java.lang.String |
getExitMessage()
Reports the exit message for the location. |
int |
getExitThreshold()
Gets the exit threshold for the location. |
java.lang.String |
getImagePath()
|
java.util.Set<Item> |
getItems(java.lang.String name)
Gets a set of items from this location, identified by a common name. |
java.lang.String |
getMusicPath()
|
java.lang.String |
getName()
|
Obstacle |
getObstacle(Game.Direction dir)
|
java.lang.String |
getSceneImagePath()
|
java.lang.String |
getSceneIntro()
|
java.lang.String |
getTopic(int i)
|
java.lang.String |
getTopic(java.lang.String s)
|
ItemRepository |
getTopicItems(int i)
|
ItemRepository |
getTopicItems(java.lang.String title)
|
boolean |
hasActiveScene()
|
boolean |
hasConnectedLocation(Game.Direction direction)
It returns true when there is no door in the given direction |
boolean |
hasExitThreshold()
Checks if this location has exit threshold (and its corresponding exit message). |
boolean |
hasImage()
|
boolean |
hasItem(Item item)
Checks whether the repository contains an specific item. |
boolean |
hasLightLevel(int lightLevel)
|
boolean |
hasMusic()
|
boolean |
hasObstacle(Game.Direction dir)
|
boolean |
hasSceneImage()
|
boolean |
hasTopic(int i)
|
boolean |
hasTopic(java.lang.String s)
|
boolean |
isAlreadyVisited()
|
java.lang.String |
presentItem(Item i)
|
boolean |
presentItemExtinguish(Item i)
|
void |
removeItem(Item it)
Removes an item from this location. |
java.util.List<java.lang.String> |
reportAllItems()
Reports the names of all the items of the location. |
void |
setConnection(Game.Direction direction,
Location location)
Sets the connections between this location and other one. |
void |
setImage(java.lang.String image)
|
void |
setMusic(java.lang.String music)
|
void |
setVisited()
|
boolean |
topicHasItems(int i)
|
boolean |
topicHasItems(java.lang.String title)
|
java.lang.String |
toString()
It returns the room description |
boolean |
updateActiveScene()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int _threshold
protected java.lang.String _name
protected java.lang.String _musicPath
protected java.lang.String _imagePath
protected Scene _activeScene
protected java.util.Vector<Scene> _scenes
protected java.lang.String _desc
protected java.lang.String _exit
protected ItemRepository _items
protected java.util.EnumMap<Game.Direction,Location> _doors
protected java.util.EnumMap<Game.Direction,Obstacle> _obstacles
protected boolean _visited
protected boolean _light
Constructor Detail |
---|
public Location(java.lang.String name, java.lang.String desc) throws java.lang.IllegalArgumentException
name
- Name for Roomdesc
- Description for Room
java.lang.IllegalArgumentException
public Location(java.lang.String name, java.lang.String desc, int exitThreshold, java.lang.String exitMessage)
public Location(java.lang.String name, java.lang.String desc, boolean light) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public Location(java.lang.String name, java.lang.String desc, boolean light, int exitThreshold, java.lang.String exitMessage)
Method Detail |
---|
public void addItem(Item item) throws ItemAlreadyInRepositoryException
ItemAlreadyInRepositoryException
public void addObstacle(Game.Direction dir, Obstacle o) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public boolean hasObstacle(Game.Direction dir)
public Obstacle getObstacle(Game.Direction dir) throws NoObstacleException
NoObstacleException
public Location getConnectedLocation(Game.Direction direction) throws java.lang.IllegalArgumentException, NoConnectedLocationException
direction
- Direction for checking the room
NoConnectedLocationException
- There is no connected location to the player location java.lang.IllegalArgumentException
public java.lang.String getName()
public java.lang.String getDescription()
public java.lang.String getExitMessage() throws NoExitThresholdException
NoExitThresholdException
- This location has no exit threshold.public int getExitThreshold() throws NoExitThresholdException
NoExitThresholdException
- This location has no exit threshold.public java.util.Set<Item> getItems(java.lang.String name) throws java.lang.IllegalArgumentException
name
- The common name of the items.
java.lang.IllegalArgumentException
- Argument 'name' cannot be null.public boolean hasConnectedLocation(Game.Direction direction) throws java.lang.IllegalArgumentException
direction
- Direction
java.lang.IllegalArgumentException
- Argument 'direction' cannot be null.public boolean hasExitThreshold()
public void removeItem(Item it) throws ItemNotInRepositoryException
it
- The item
ItemNotInRepositoryException
- The item is not in this repository.public java.util.Set<Item> getAllItems()
public java.util.List<java.lang.String> reportAllItems()
public void setConnection(Game.Direction direction, Location location) throws java.lang.IllegalArgumentException
direction
- The directionlocation
- The location to link
java.lang.IllegalArgumentException
- The arguments 'direction' and 'location' cannot be null.public java.lang.String toString()
toString
in class java.lang.Object
public boolean hasItem(Item item)
item
- The item.
public void setMusic(java.lang.String music)
public boolean hasMusic()
public java.lang.String getMusicPath()
public void setImage(java.lang.String image)
public boolean hasImage()
public java.lang.String getImagePath()
public boolean hasSceneImage()
public java.lang.String getSceneImagePath()
public java.lang.Object clone()
clone
in class java.lang.Object
public void addScene(Scene s)
public boolean updateActiveScene()
public boolean hasActiveScene()
public boolean checkSceneIntro()
public java.lang.String getSceneIntro()
public java.util.Vector<java.lang.String> getAvailableTopics()
public java.lang.String getTopic(int i)
public java.lang.String getTopic(java.lang.String s)
public boolean isAlreadyVisited()
public void setVisited()
public boolean hasTopic(int i)
public boolean hasTopic(java.lang.String s)
public boolean topicHasItems(int i)
public boolean topicHasItems(java.lang.String title)
public ItemRepository getTopicItems(int i)
public ItemRepository getTopicItems(java.lang.String title)
public java.lang.String presentItem(Item i)
public boolean presentItemExtinguish(Item i)
public boolean hasLightLevel(int lightLevel)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |