us.asciiroth.client.terrain
Class TerrainUtils

java.lang.Object
  extended by us.asciiroth.client.terrain.TerrainUtils

public class TerrainUtils
extends java.lang.Object

Terrain utilities.


Constructor Summary
TerrainUtils()
           
 
Method Summary
static Cell getCellOnOppositeSide(Cell cell, Direction direction)
          To support animated pieces that loop around the board, this method returns the approximate cell located on the opposite side of the board.
static Cell getRandomCell(java.util.List<Cell> cells)
          Give a list of cells, choose one at random.
static Direction getRandomDirection()
          Given a list of directions, choose one at random.
static Terrain getTerrainOtherState(Terrain terrain, State state)
          Get this terrain piece but with its state toggled.If a piece is supplied that does not have state, it will simply be returned by this method.
static Terrain getTerrainWithReverseDirection(Cell cell, Direction dir)
          Given a cell with a terrain that has a direction, and the current direction of that terrain, this method creates and caches a terrain piece with an opposite direction.
static void removeDecorator(Event event, TerrainProxy terrain)
           
static void toggleCellState(Cell cell, Terrain terrain, State state)
          Assuming the indicated cell has a terrain type with state, this method toggles the state on/off and then changes the terrain for that cell.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TerrainUtils

public TerrainUtils()
Method Detail

getCellOnOppositeSide

public static Cell getCellOnOppositeSide(Cell cell,
                                         Direction direction)
To support animated pieces that loop around the board, this method returns the approximate cell located on the opposite side of the board. It's approximate because there are many edge cases that aren't worth considering in this method.

Parameters:
cell -
direction -
Returns:
approximate cell on the opposite side of the board

getRandomCell

public static Cell getRandomCell(java.util.List<Cell> cells)
Give a list of cells, choose one at random.

Parameters:
cells -
Returns:
a randomly chosen cell taken from the list of cells

getRandomDirection

public static Direction getRandomDirection()
Given a list of directions, choose one at random.

Returns:
a randomly chosen direction taken from the list of directions

getTerrainOtherState

public static Terrain getTerrainOtherState(Terrain terrain,
                                           State state)
Get this terrain piece but with its state toggled.If a piece is supplied that does not have state, it will simply be returned by this method. The new terrain piece is cached by the Registry, but this method does not change the board. Be careful with this method that you don't change a terrain's state while an agent is on the terrain that would have a negative effect. The method toggleCellState prevents this.

Parameters:
terrain -
state -
Returns:
the new terrain piece with its state toggled on/off

getTerrainWithReverseDirection

public static Terrain getTerrainWithReverseDirection(Cell cell,
                                                     Direction dir)
Given a cell with a terrain that has a direction, and the current direction of that terrain, this method creates and caches a terrain piece with an opposite direction. It does not change the board.

Parameters:
cell - the target cell
dir - the current direction of the terrain
Returns:
the new terrain piece with its direction reversed

removeDecorator

public static void removeDecorator(Event event,
                                   TerrainProxy terrain)

toggleCellState

public static void toggleCellState(Cell cell,
                                   Terrain terrain,
                                   State state)
Assuming the indicated cell has a terrain type with state, this method toggles the state on/off and then changes the terrain for that cell. This method does change the board. This method will not toggle the state while an agent is in the cell. That's almost never what you want and the source of much oddity in the game if it happens.

Parameters:
cell -
state -

0.7

2009 Alx Dark