jurpe.dungeon.rpgmap
Class RpgMap

java.lang.Object
  extended by jurpe.dungeon.rpgmap.RpgMap
All Implemented Interfaces:
java.io.Serializable, ILogicalMap

public class RpgMap
extends java.lang.Object
implements ILogicalMap, java.io.Serializable

RpgMap is the description of a single map, that is a level in the HexDungeon

See Also:
Serialized Form

Constructor Summary
RpgMap(java.util.Random rnd, short sizeX, short sizeY)
          Constructor
 
Method Summary
 boolean areAllVisitedCells()
          Returns true if all cells in the map were visited
 RpgMapPoint getBottomRight()
          Get coordinates of Bottom/Right map point (w,h)
 Cell getCell(Cell from, Direction to)
          Get RpgMapCell that is located in direction 'to' starting from 'from' Cell
 Cell getCell(HexPoint p)
          Get Cell
 Cell getCell(short x, short y)
          Get Cell
 RpgMapPoint getCenter()
          Get the coordinates of the center of this map
 Cell getEmptyRandomCell(boolean nextToCenter)
          Get a random cell in this map that is not a wall or a special cell.
 short getHeight()
          Height of RpgMap in Hexagons
 Cell getRandomCell()
          Get a random cell in this map
 RpgMapPoint getRandomPoint()
          Get a random point inside this map
 java.util.Random getRandomSeed()
          Return random seed.
 Cell getSpecialCell(LocationType type)
          Get the first found cell of the specified location type
 RpgMapPoint getTopLeft()
          Get coordinates of Top/Left map point (0,0)
 short getWidth()
          Width of RpgMap in Hexagons
 boolean isInside(RpgMapPoint p)
          Return true if point p is inside this map.
 MapIterator iterator()
          Iterator
 RpgMapPoint moveTo(RpgMapPoint from, Direction dir)
          This method returns the coordinates of the arrival point when starting from a point a taking a direction.
 void setSpecialCell(RpgMapPoint p, LocationType type)
          Set special cell
 void setSpecialCell(RpgMapPoint p, LocationType type, java.lang.String message)
          Set special cell with a message
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RpgMap

public RpgMap(java.util.Random rnd,
              short sizeX,
              short sizeY)
Constructor

Parameters:
rnd - Random seed
sizeX - Width in hexagons of RpgMap
sizeY - Height in hexagons of RpgMap
Method Detail

getRandomSeed

public java.util.Random getRandomSeed()
Return random seed.

Returns:
The random seed object

iterator

public MapIterator iterator()
Iterator

Specified by:
iterator in interface ILogicalMap
Returns:
RpgMapIterator

getWidth

public short getWidth()
Width of RpgMap in Hexagons

Specified by:
getWidth in interface ILogicalMap
Returns:
Width of RpgMap in Hexagons

getHeight

public short getHeight()
Height of RpgMap in Hexagons

Specified by:
getHeight in interface ILogicalMap
Returns:
Height of RpgMap in Hexagons

getRandomPoint

public RpgMapPoint getRandomPoint()
Get a random point inside this map

Returns:
RpgMapPoint

getRandomCell

public Cell getRandomCell()
Get a random cell in this map

Returns:
a random cell in this map

isInside

public boolean isInside(RpgMapPoint p)
Return true if point p is inside this map.

Specified by:
isInside in interface ILogicalMap
Parameters:
p - RpgPoint to be checked
Returns:
true if point p is inside this map

setSpecialCell

public void setSpecialCell(RpgMapPoint p,
                           LocationType type)
                    throws JurpeException
Set special cell

Parameters:
p - RpgMapPoint to set as special
type - Location type
Throws:
JurpeException

setSpecialCell

public void setSpecialCell(RpgMapPoint p,
                           LocationType type,
                           java.lang.String message)
                    throws JurpeException
Set special cell with a message

Parameters:
message - Message that this cell displays when actioned
p - Map point
type - Type of cell
Throws:
JurpeException

getSpecialCell

public Cell getSpecialCell(LocationType type)
Get the first found cell of the specified location type

Parameters:
type - Special cell type
Returns:
the first found cell of the specified location type

getTopLeft

public RpgMapPoint getTopLeft()
Get coordinates of Top/Left map point (0,0)

Specified by:
getTopLeft in interface ILogicalMap
Returns:
RpgMapPoint

getBottomRight

public RpgMapPoint getBottomRight()
Get coordinates of Bottom/Right map point (w,h)

Specified by:
getBottomRight in interface ILogicalMap
Returns:
RpgMapPoint

areAllVisitedCells

public boolean areAllVisitedCells()
Returns true if all cells in the map were visited

Returns:
true if all cells in the map were visited

moveTo

public RpgMapPoint moveTo(RpgMapPoint from,
                          Direction dir)
This method returns the coordinates of the arrival point when starting from a point a taking a direction.

Parameters:
from - Point coordinates of starting hexagon
dir - Direction taken
Returns:
the coordinates in hexagons of the arrival point

getCenter

public RpgMapPoint getCenter()
Get the coordinates of the center of this map

Returns:
RpgMapPoint Center of the map

getEmptyRandomCell

public Cell getEmptyRandomCell(boolean nextToCenter)
Get a random cell in this map that is not a wall or a special cell. Optionally can be a cell "next to the center".

Parameters:
nextToCenter - if true, it will try to return a cell next to the center of the dungeon
Returns:
null if no cell is found. Else return the wanted cell

getCell

public Cell getCell(HexPoint p)
Get Cell

Specified by:
getCell in interface ILogicalMap
Parameters:
p - HexPoint
Returns:
The cell at hexpoint p

getCell

public Cell getCell(short x,
                    short y)
Get Cell

Parameters:
x - x coordinate
y - y coordinate HexPoint
Returns:
The cell at hexpoint(x,y)

getCell

public Cell getCell(Cell from,
                    Direction to)
Get RpgMapCell that is located in direction 'to' starting from 'from' Cell

Parameters:
from - Initial RpgMapCell
to - Direction to go to
Returns:
Cell that will be reached in that direction

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