us.asciiroth.client.board
Class Cell

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

public class Cell
extends java.lang.Object


Method Summary
 boolean canEnter(Cell agentLoc, Agent agent, Direction dir, boolean targetPlayer)
          Can the agent enter this cell, accounting both for the terrain type and the presence of other agents, as well as the intent of the agent (attack player vs.
 boolean containsPlayer()
          Does this cell contain the player? This method is more effective than testing the agent using the instanceof operator because it accounts for the fact that the player may be wrapped by an AgentProxy.
 void createCloud(java.lang.Class<? extends Effect> c)
           
 boolean equals(java.lang.Object obj)
           
 void explosion(Player player)
           
 Cell getAdjacentCell(Direction direction)
          Get the cell adjacent to the current cell in the indicated direction.
 java.util.List<Cell> getAdjacentCells(CellFilter filter)
           
 Agent getAgent()
           
 Terrain getApparentTerrain()
          Get the terrain of this cell as it appears to the player.
 ItemBag getBag()
           
 Board getBoard()
           
 ModifiableSymbol getCurrentSymbol(Piece piece, Symbol symbol)
          Accounting for the layering of pieces on this cell, what would the union of the pieces be in a symbol?
 EffectBag getEffects()
          The thrown or shot objects currently over this cell.
 com.google.gwt.user.client.Element getTd()
           
 Terrain getTerrain()
          Get the terrain of this cell.
 double getVisited()
          The timestamp of the last time the player visited this cell, during the current occupation of the board by the player (the information is wiped out when the player leaves the board).
 int getX()
           
 int getY()
           
 int hashCode()
           
 boolean hasNoEffects()
          Are there effects (thrown or shot pieces) in this cell.
 boolean hasOpeningEffect()
           
 Cell init(Board board)
           
 boolean isBagEmpty()
          Check to see if there are items in this cell.
 void moveAgentTo(Cell next, Agent agent)
          Move an agent to another cell.
 void onSteppedOn(Event event, Cell agentLoc, Agent agent)
           
 void openContainer(java.lang.String string, Item item, int count, java.lang.Class<?> c)
          Animation and related behavior for opening a crate or chest.
 void removeAgent(Agent agent)
          Remove the agent current on this square.
 void setAgent(Agent agent)
          Set the agent occupying this square.
 void setTerrain(Terrain newTerrain)
           
 void setTerrain(Terrain newTerrain, boolean forceProxyReplace)
          Set the terrain for this cell.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

canEnter

public boolean canEnter(Cell agentLoc,
                        Agent agent,
                        Direction dir,
                        boolean targetPlayer)
Can the agent enter this cell, accounting both for the terrain type and the presence of other agents, as well as the intent of the agent (attack player vs. just move while avoiding all other agents). This isn't absolutely perfect, but should account for most situations.

Parameters:
agentLoc -
agent -
targetPlayer -
Returns:
true if the agent can move to the indicated cell

containsPlayer

public boolean containsPlayer()
Does this cell contain the player? This method is more effective than testing the agent using the instanceof operator because it accounts for the fact that the player may be wrapped by an AgentProxy. It is analogous to getApparentTerrain() in this regard.

Returns:
true if the agent is the player or a proxy that proxies the player

createCloud

public void createCloud(java.lang.Class<? extends Effect> c)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

explosion

public void explosion(Player player)

getAdjacentCell

public Cell getAdjacentCell(Direction direction)
Get the cell adjacent to the current cell in the indicated direction. Returns null if the direction is up or down.

Parameters:
direction - - the direction in which the adjacent cell is located, relative to this cell
Returns:
the adjacent cell, or null if the direction is up or down

getAdjacentCells

public java.util.List<Cell> getAdjacentCells(CellFilter filter)

getAgent

public Agent getAgent()
Returns:
the agent currently occupying this square, or null if empty

getApparentTerrain

public Terrain getApparentTerrain()
Get the terrain of this cell as it appears to the player. Terrain behavior is augmented through the use of the Decorator pattern, so the terrain returned from getTerrain is not always the terrain as it is displayed to the user or as it behaves

Returns:
the terrain for this cell or the proxied terrain, if the terrain implements the TerrainProxy interface.

getBag

public ItemBag getBag()
Returns:
the items lying on the ground in this cell

getBoard

public Board getBoard()
Returns:
the board containing this cell

getCurrentSymbol

public ModifiableSymbol getCurrentSymbol(Piece piece,
                                         Symbol symbol)
Accounting for the layering of pieces on this cell, what would the union of the pieces be in a symbol?

Parameters:
piece -
symbol -
Returns:
a symbol showing the union of all pieces on the cell.

getEffects

public EffectBag getEffects()
The thrown or shot objects currently over this cell.

Returns:
the effects currently occuping this cell.

getTd

public com.google.gwt.user.client.Element getTd()

getTerrain

public Terrain getTerrain()
Get the terrain of this cell.

Returns:
the terrain of this cell

getVisited

public double getVisited()
The timestamp of the last time the player visited this cell, during the current occupation of the board by the player (the information is wiped out when the player leaves the board).

Returns:
the time in millis since the epoch (the higher the number, the more recently visited)

getX

public int getX()
Returns:
the x/column coordinate of this cell

getY

public int getY()
Returns:
the y/row coordinate of this cell

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

hasNoEffects

public boolean hasNoEffects()
Are there effects (thrown or shot pieces) in this cell. This method will not create a bag for the cell as a side effect of the check, and so it preferable to using getEffects().isEmpty().

Returns:
true if there are effects in this cell, false otherwise

hasOpeningEffect

public boolean hasOpeningEffect()

init

public Cell init(Board board)

isBagEmpty

public boolean isBagEmpty()
Check to see if there are items in this cell. Does not create a bag for the cell as a side effect of the check, and so is preferable to getBag().isEmpty().

Returns:
true if there are no items in this cell, false otherwise

moveAgentTo

public void moveAgentTo(Cell next,
                        Agent agent)
Move an agent to another cell. This method is more efficient than removing and then adding the agent to another cell, and should be used for true move operations.

Parameters:
next - the cell to move the agent to
agent - the agent to be moved

onSteppedOn

public void onSteppedOn(Event event,
                        Cell agentLoc,
                        Agent agent)

openContainer

public void openContainer(java.lang.String string,
                          Item item,
                          int count,
                          java.lang.Class<?> c)
Animation and related behavior for opening a crate or chest.

Parameters:
string - the name of the container
item - the item in the container (can be null)
count - the number of items in the container
c - the class of terrain being opened (Chest or Crate)

removeAgent

public void removeAgent(Agent agent)
Remove the agent current on this square. Safe to use outside of a controller method method.

Parameters:
agent -

setAgent

public void setAgent(Agent agent)
Set the agent occupying this square. To clear the cell of an agent, use removeAgent. An existing agent on this square will be removed, so you must be careful when calling this method. The controller methods include logic for pushing agents, and similar behavior, that cannot be expressed here.

Parameters:
agent -

setTerrain

public void setTerrain(Terrain newTerrain)

setTerrain

public void setTerrain(Terrain newTerrain,
                       boolean forceProxyReplace)
Set the terrain for this cell. If the new terrain is not a proxy, and the existing terrain is a proxy, then the final terrain will be a proxy with the same behavior, but the new terrain will be the proxied terrain. From the player's perspective, the terrain will have changed but the decorated behavior will remain. If the new terrain is a proxy, then it will simply replace the existing terrain, whatever it is. But replacing one proxy with another proxy can be considered an error.

Parameters:
newTerrain -
forceProxyReplace - force any proxy in this cell to be replaced (so far only the editor needs to do this)

0.7

© 2009 Alx Dark