us.asciiroth.client.board
Class Board

java.lang.Object
  extended by us.asciiroth.client.board.Board

public class Board
extends java.lang.Object

The main model object in the game, the board represents the entire map and all the pieces on it.


Field Summary
static int COLUMNS
          The size of boards in columns.
static int ROWS
          The size of boards in rows.
 
Constructor Summary
Board()
          Constructor.
 
Method Summary
 Cell find(CellFilter filter)
           
 java.util.List<Cell> findAdjacent(Cell start, CellFilter filter)
          Starting at a specific cell, test adjacent cells with the selector and continue finding and selecting adjacent cells until no adjacent cells match.
 Cell findRandomCell()
          Find a random cell that an item could be placed on that the player should be able to enter in order to pick up the item (cells that have traversable terrain).
 void fireColorEvent(Context ctx, Color color, Cell origin)
          Fire a color-related trigger across the board.
 java.lang.String getAdjacentBoard(Direction direction)
          Get a board adjacent to the current board in the indicated direction.
 Cell getAdjacentCell(int x, int y, Direction dir)
          Given a location on the board and a direction, get the adjacent cell.
 java.util.List<AnimationProxy> getAnimated()
          Get the list of pieces currently on the board that are animated.
 Cell getCellAt(int x, int y)
          Get the cell at the given coordinates
 java.lang.String getCreator()
           
 Cell getCurrentCell()
          Get the cell currently occupied by the player.
 java.lang.String getDescription()
           
 java.lang.String getMusic()
           
 java.lang.String getScenarioName()
           
 java.lang.String getStartInventory()
           
 int getStartX()
          Get the start X position of the board.
 int getStartY()
          Get the start Y position of the board.
 boolean hasNonTransientEffect()
          If the board is serialized (player leaves board or saves) while there are effects that are not transient, then saving will be delayed until these effects are played out.
 boolean isOutside()
          Is the terrain represented by this board above-ground?
 void rerenderBoard()
           
 void setAdjacentBoard(java.lang.String direction, java.lang.String boardID)
          Set an adjacent board.
 void setCreator(java.lang.String creator)
           
 void setDescription(java.lang.String description)
           
 void setMusic(java.lang.String music)
           
 void setOutside(boolean outside)
           
 void setScenarioName(java.lang.String scenarioName)
           
 void setStartInventory(java.lang.String startInventory)
           
 void setStartXY(int x, int y)
          Set the starting X/Y coordinates of the player on this board.
 void visit(CellVisitor visitor)
          Visit every cell on the board, for whatever reason.
 void visitRange(Cell center, int range, boolean includeCenter, CellVisitor visitor)
          This searches a square of the board, centered on the range, from the closest to the most distant squares, up and including the range of cells (so a range of 3 searches up to 3 cells away).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLUMNS

public static final int COLUMNS
The size of boards in columns.

See Also:
Constant Field Values

ROWS

public static final int ROWS
The size of boards in rows.

See Also:
Constant Field Values
Constructor Detail

Board

public Board()
Constructor.

Method Detail

find

public Cell find(CellFilter filter)

findAdjacent

public java.util.List<Cell> findAdjacent(Cell start,
                                         CellFilter filter)
Starting at a specific cell, test adjacent cells with the selector and continue finding and selecting adjacent cells until no adjacent cells match.

Parameters:
start -
filter -
Returns:
list of cells that matched the selector

findRandomCell

public Cell findRandomCell()
Find a random cell that an item could be placed on that the player should be able to enter in order to pick up the item (cells that have traversable terrain). Because this could include squares with agents that are not actually movable, we also avoid cells with agents on them at the time we look.

Returns:
a cell that can take an agent or item

fireColorEvent

public void fireColorEvent(Context ctx,
                           Color color,
                           Cell origin)
Fire a color-related trigger across the board. All terrain that has color, and that matches the color of the event, will have its onTrigger method fired. Each terrain type can have behavior under these circumstances. Triggers set up conditions for when such an event can occur.

Parameters:
ctx - context object containing game state
color - the color of the event; colorEvent will be called on all terrain of this color

getAdjacentBoard

public java.lang.String getAdjacentBoard(Direction direction)
Get a board adjacent to the current board in the indicated direction. This includes boards above and below the current one.

Parameters:
direction -
Returns:
the adjacent boardID or null if there is none.

getAdjacentCell

public Cell getAdjacentCell(int x,
                            int y,
                            Direction dir)
Given a location on the board and a direction, get the adjacent cell.

Parameters:
x - the x location of the starting cell
y - the y location of the starting cell
dir - the direction to retrieve the adjacent cell from
Returns:
the adjacent cell

getAnimated

public java.util.List<AnimationProxy> getAnimated()
Get the list of pieces currently on the board that are animated.

Returns:
a list of AnimationProxy elements, one for each animated piece on the board

getCellAt

public Cell getCellAt(int x,
                      int y)
Get the cell at the given coordinates

Parameters:
x -
y -
Returns:
the cell at the given coordinates.

getCreator

public java.lang.String getCreator()

getCurrentCell

public Cell getCurrentCell()
Get the cell currently occupied by the player.

Returns:
the cell currently occupied by the player

getDescription

public java.lang.String getDescription()

getMusic

public java.lang.String getMusic()

getScenarioName

public java.lang.String getScenarioName()

getStartInventory

public java.lang.String getStartInventory()

getStartX

public int getStartX()
Get the start X position of the board. If the player does not enter the board from another board, this is the X position that will be used to place the player. Used for the entry map of a scenario as well as testing.

Returns:
the start X position assigned to this board

getStartY

public int getStartY()
Get the start Y position of the board. If the player does not enter the board from another board, this is the Y position that will be used to place the player. Used for the entry map of a scenario as well as testing.

Returns:
the start Y position assigned to this board

hasNonTransientEffect

public boolean hasNonTransientEffect()
If the board is serialized (player leaves board or saves) while there are effects that are not transient, then saving will be delayed until these effects are played out. For example, you cannot save thrown items because when the player returns, they will appear to have hung in mid air the whole time. So instead, saving occurs on a timer that checks until there are no such effects, allowing them to all resolve their movement before the board is final serialized.

Returns:
true if there are any non transient effects currently in effect on the board.

isOutside

public boolean isOutside()
Is the terrain represented by this board above-ground?

Returns:
true if outside, false otherwise

rerenderBoard

public void rerenderBoard()

setAdjacentBoard

public void setAdjacentBoard(java.lang.String direction,
                             java.lang.String boardID)
Set an adjacent board.

Parameters:
direction - the direction of the board
boardID - the boardID of the new board.

setCreator

public void setCreator(java.lang.String creator)

setDescription

public void setDescription(java.lang.String description)

setMusic

public void setMusic(java.lang.String music)

setOutside

public void setOutside(boolean outside)
Parameters:
outside -

setScenarioName

public void setScenarioName(java.lang.String scenarioName)

setStartInventory

public void setStartInventory(java.lang.String startInventory)

setStartXY

public void setStartXY(int x,
                       int y)
Set the starting X/Y coordinates of the player on this board.

Parameters:
x -
y -

visit

public void visit(CellVisitor visitor)
Visit every cell on the board, for whatever reason.

Parameters:
visitor -

visitRange

public void visitRange(Cell center,
                       int range,
                       boolean includeCenter,
                       CellVisitor visitor)
This searches a square of the board, centered on the range, from the closest to the most distant squares, up and including the range of cells (so a range of 3 searches up to 3 cells away). It passes each cell to the visitor, if the visitor returns a cell, it is immediately returned, otherwise, all cells are traversed.


0.7

2009 Alx Dark