de.adom.jade.world
Class Location

java.lang.Object
  extended by de.adom.jade.kernel.GUIDCarrier
      extended by de.adom.jade.world.Location
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Dungeon, Settlement, World

public abstract class Location
extends GUIDCarrier
implements java.io.Serializable

Describes a location of the world. This includes information about the location in known and unknown state, map data and more. Map creation can be deferred until the PC enters the location for the first time. This is especially useful for dungeons of which there are simply too many to create them all a once.

See Also:
Serialized Form

Constructor Summary
Location(java.lang.String unknownName, java.lang.String unknownDescription, java.lang.String knownName, java.lang.String knownDescription)
          Creates a new location.
Location(java.lang.String unknownName, java.lang.String unknownDescription, java.lang.String knownName, java.lang.String knownDescription, Map map)
          Creates a new location.
 
Method Summary
 void addConnection(Connection connection)
          Adds a connection to this location.
protected abstract  Map createMap()
          Creates a new map for this specific location.
 ActorQueue getActorQueue()
          Returns the actor queue for this location.
 Complex getComplex()
          Returns the complex to which this location belongs.
 long getComplexID()
          Returns the complex ID of this loocation.
 Connection getConnectionAt(int x, int y)
          Returns a connection for the given coordinates.
 Connection getConnectionByID(long id)
          Returns a connection by its ID.
 java.util.Iterator getConnectionPositions()
          Returns a list of all connection positions for this location.
 java.util.Iterator getConnections()
          Returns a list of all connections for this location.
 java.lang.String getDescription()
          Returns the description of this location.
 int getLevel()
          Returns the level number of this level.
 java.lang.String getLogicalName()
          Returns the internal unique logical name of this location.
 Map getMap()
          Returns the map of the location.
 java.lang.String getName()
          Returns the name of the location.
 long getTickCounter()
          Returns the tick counter when this location was last retrieved from the location manager.
abstract  boolean isDungeon()
          Determines whether the current location is a dungeon.
 boolean isKnown()
          Determines whether the location is already known.
abstract  boolean isSettlement()
          Determines whether the current location is a settlement.
abstract  boolean isSurfaceWorld()
          Determines whether the current location is the surface world area.
abstract  boolean isWilderness()
          Determines whether the current location is a wilderness area.
 void setComplex(int index, Complex theComplex)
          Defines the complex to which this location belongs.
 void setKnown(boolean known)
          Marks the location as known or unknown.
 void setMap(Map theMap)
          Explicitly defines a map for this location.
 void updateTicks()
          Updates the internal location timer by memorizing the current number of game ticks.
 
Methods inherited from class de.adom.jade.kernel.GUIDCarrier
getGUID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Location

public Location(java.lang.String unknownName,
                java.lang.String unknownDescription,
                java.lang.String knownName,
                java.lang.String knownDescription)
Creates a new location. The creation of the actual map is deferred until the player enters the location fr the first time.

Parameters:
unknownName - the name of the location in its unknown state
unknownDescription - the description of the location in its unknown state
knownName - the name of the location in its known state
knownDescription - the description of the location in its known state

Location

public Location(java.lang.String unknownName,
                java.lang.String unknownDescription,
                java.lang.String knownName,
                java.lang.String knownDescription,
                Map map)
Creates a new location.

Parameters:
complexID - the ID of this complex
level - the depth level of this location
unknownName - the name of the location in its unknown state
unknownDescription - the description of the location in its unknown state
knownName - the name of the location in its known state
knownDescription - the description of the location in its known state
map - the map of the location
Method Detail

getDescription

public java.lang.String getDescription()
Returns the description of this location.

Returns:
the description of this location

getName

public java.lang.String getName()
Returns the name of the location.

Returns:
the name of the location

getMap

public Map getMap()
Returns the map of the location.

Returns:
the map of the location

getActorQueue

public ActorQueue getActorQueue()
Returns the actor queue for this location.

Returns:
the actor queue for this location

isKnown

public boolean isKnown()
Determines whether the location is already known.

Returns:
a boolean value determining whether the location is known or not

setKnown

public void setKnown(boolean known)
Marks the location as known or unknown.

Parameters:
known - a boolean value determining whether the location is known or not

getLogicalName

public java.lang.String getLogicalName()
Returns the internal unique logical name of this location.

Returns:
the logical name of this location

createMap

protected abstract Map createMap()
Creates a new map for this specific location.

Returns:
the newly created map for this location TODO: Make this method abstract so that derived classes can overload it.

addConnection

public void addConnection(Connection connection)
Adds a connection to this location. Connections may be added more than once (once for the initial unlocated connection, once for the connection with correct position data). If a connection changes position you first need to remove it from the location, then change its location and then add it again (and remember to change the map tile for the connection, too!).

Parameters:
connection - the connection to add

getConnectionAt

public Connection getConnectionAt(int x,
                                  int y)
Returns a connection for the given coordinates.

Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the connection at that position or null

getConnectionByID

public Connection getConnectionByID(long id)
Returns a connection by its ID. If several connections exist with the same connection ID, the connection with the lowest GUID is returned.

Parameters:
id - the connection ID
Returns:
the connection with the given ID or null

getComplexID

public long getComplexID()
Returns the complex ID of this loocation.

Returns:
the complex ID

getLevel

public int getLevel()
Returns the level number of this level.

Returns:
the level number (0 = wilderness)

getConnections

public java.util.Iterator getConnections()
Returns a list of all connections for this location.

Returns:
an iterator for all connections for this location

getConnectionPositions

public java.util.Iterator getConnectionPositions()
Returns a list of all connection positions for this location.

Returns:
an iterator for all connection positions for this location

setMap

public void setMap(Map theMap)
Explicitly defines a map for this location.

Parameters:
theMap - the map for this location

isDungeon

public abstract boolean isDungeon()
Determines whether the current location is a dungeon.

Returns:
a flag indicating whether the location is a dungeon

isSettlement

public abstract boolean isSettlement()
Determines whether the current location is a settlement.

Returns:
a flag indicating whether the location is a settlement

isWilderness

public abstract boolean isWilderness()
Determines whether the current location is a wilderness area.

Returns:
a flag indicating whether the location is a wilderness area

isSurfaceWorld

public abstract boolean isSurfaceWorld()
Determines whether the current location is the surface world area.

Returns:
a flag indicating whether the location is the surface world area

updateTicks

public void updateTicks()
Updates the internal location timer by memorizing the current number of game ticks. This timer can be used to implement caching algorithms on the location maps by only keeping the x most recent maps in memory and storing the others on hard disk.


getTickCounter

public long getTickCounter()
Returns the tick counter when this location was last retrieved from the location manager.

Returns:
the tick counter of the last access time

setComplex

public void setComplex(int index,
                       Complex theComplex)
Defines the complex to which this location belongs.

Parameters:
index - the index of this location in the given complex
theComplex - the complex to which this location belongs

getComplex

public Complex getComplex()
Returns the complex to which this location belongs.

Returns:
the complex to which this location belongs