jurpe.dungeon.rpgmap
Class Cell

java.lang.Object
  extended by jurpe.dungeon.rpgmap.Cell
All Implemented Interfaces:
java.io.Serializable

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

Cell is the logical abstraction of a dungeon cell. A cell contains six passages. A cell with six passages closed is a wall. Can contain doors and other furnishing.

See Also:
Serialized Form

Field Summary
 boolean visited
           
 
Constructor Summary
Cell(short xx, short yy)
          Constructor
Cell(short xx, short yy, LocationType location)
          Constructor
 
Method Summary
 RpgMapPoint getCoordinates()
          Get cell coordinates
 Direction[] getDoorables()
          Return all the directions in which this cell may have a door.
 Direction[] getDoors()
          Get all directions in whose there are doors.
 Location getLocation()
           
 short getNumberOfCorridors()
          Get the number of open corridors leading out of this cell.
 CellPassages getPassages()
          The passages from this cell
 boolean isCorridor(Direction dir)
          Return true if the passage between this cell and the cell in d direction is a corridor, that is, it's opened.
 boolean isDoor(Direction dir)
          Return true if there is a door in the direction dir
 boolean isSpecial()
          Return true if this cell is not a wall or a corridor.
 boolean isWall()
          A cell without exits is considered a wall
 void setCorridor(Direction dir, boolean opened)
          Set if the passage between this cell and the cell in d direction is opened
 void setDoor(Direction dir)
          Set a door.
 void setLocation(LocationType location)
          Set location type
 void setLocation(LocationType location, java.lang.String message)
          Set location type and message.
 void setWall()
          This cell becomes a wall.
 void setWall(boolean isWall)
          Determine if this cell is a wall or not
 java.lang.String toString()
          String with cell coordinates
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

visited

public boolean visited
Constructor Detail

Cell

public Cell(short xx,
            short yy)
Constructor

Parameters:
xx - X coordinate of cell
yy - Y coordinate of cell

Cell

public Cell(short xx,
            short yy,
            LocationType location)
Constructor

Parameters:
xx - X coordinate of cell
yy - Y coordinate of cell
location - type of this cell (ie: inn, trainer, normal...)
Method Detail

getPassages

public CellPassages getPassages()
The passages from this cell

Returns:
The passages from this cell

getLocation

public Location getLocation()
Returns:
Location

setLocation

public void setLocation(LocationType location)
Set location type

Parameters:
location - LocationType

setLocation

public void setLocation(LocationType location,
                        java.lang.String message)
Set location type and message.

Parameters:
message - Message shown when selecting location
location - LocationType

isSpecial

public boolean isSpecial()
Return true if this cell is not a wall or a corridor.

Returns:
boolean

getCoordinates

public RpgMapPoint getCoordinates()
Get cell coordinates

Returns:
cell coordinates

isWall

public boolean isWall()
A cell without exits is considered a wall

Returns:
true if this cell is a wall

setWall

public void setWall()
This cell becomes a wall.


setWall

public void setWall(boolean isWall)
Determine if this cell is a wall or not

Parameters:
isWall - true if this cell is a wall

getDoors

public Direction[] getDoors()
                     throws JurpeException
Get all directions in whose there are doors.

Returns:
Direction[]
Throws:
JurpeException

setDoor

public void setDoor(Direction dir)
Set a door. A door exist in the passages of this cell, and in the ones of the connected cell.

Parameters:
dir - Direction

getDoorables

public Direction[] getDoorables()
                         throws JurpeException
Return all the directions in which this cell may have a door. A cell is doorable if it has at least one corridor between two non-corridors.

Returns:
Direction
Throws:
JurpeException

isCorridor

public boolean isCorridor(Direction dir)
Return true if the passage between this cell and the cell in d direction is a corridor, that is, it's opened.

Parameters:
dir - Direction adiacent cell
Returns:
true if the passage between this cell and the cell in d direction is opened

isDoor

public boolean isDoor(Direction dir)
Return true if there is a door in the direction dir

Parameters:
dir - Direction in which looking for a door
Returns:
True if door is found in direction dir

setCorridor

public void setCorridor(Direction dir,
                        boolean opened)
Set if the passage between this cell and the cell in d direction is opened

Parameters:
dir - Direction from the center
opened - true if the passage in this direction is opened

getNumberOfCorridors

public short getNumberOfCorridors()
Get the number of open corridors leading out of this cell.

Returns:
the number of open corridors leading out of this cell

toString

public java.lang.String toString()
String with cell coordinates

Overrides:
toString in class java.lang.Object
Returns:
String with cell coordinates

Jurpe - Java Universal Role Playing Engine - http://jurpe.sourceforge.net