us.asciiroth.client.terrain.decorators
Class Decorator

java.lang.Object
  extended by us.asciiroth.client.core.AbstractPiece
      extended by us.asciiroth.client.terrain.decorators.Decorator
All Implemented Interfaces:
ColorListener, Piece, Terrain, TerrainProxy
Direct Known Subclasses:
AgentDestroyer, AgentGate, Cliff, ColorRelay, Equipper, Flagger, Messenger, Mimic, PieceCreator, PlayerGate, Sign, Timer, TrapContainerBase, Trigger, TriggerOnceOnDrop, TriggerOnceOnPickup, Unequipper, Unflagger, WinGame

public abstract class Decorator
extends AbstractPiece
implements Terrain, TerrainProxy, ColorListener

A base class for terrain types that can augment the behavior of another terrain, looking like that terrain but behaving differently. Decorators receive color events, and if the wrapped terrain implements ColorListener, the wrapped piece will receive the color event as well.

TODO: Unlike agent proxy, this piece cannot augment the flags of the underlying piece... it doesn't look like they would work at all.


Constructor Summary
Decorator(Terrain terrain, int flags)
           
Decorator(Terrain terrain, int flags, Color color)
           
Decorator(Terrain terrain, int flags, Color color, Symbol symbol)
           
Decorator(Terrain terrain, int flags, Symbol symbol)
           
Decorator(Terrain terrain, java.lang.String name, int flags, Color color, Symbol symbol)
           
 
Method Summary
 boolean canEnter(Agent agent, Cell cell, Direction direction)
          Can the (non-player) agent enter this terrain? Without regard to side effects, this method should determine if the agent can actually move into the cell.
 boolean canExit(Agent agent, Cell cell, Direction direction)
          Can the (non-player) agent exit this terrain? Without regard to side effects, this method should determine if the agent can actually move into the cell.
 Terrain getProxiedTerrain()
           
 boolean is(int flag)
          Does this piece have the indicated bit flag?
 boolean not(int flag)
          Does this piece not have the indicated flag?
 void onAdjacentTo(Context context, Cell cell)
          This terrain is adjacent to the player.
 void onAgentEnter(Event event, Agent agent, Cell cell, Direction dir)
           
 void onAgentExit(Event event, Agent agent, Cell cell, Direction dir)
           
 void onColorEvent(Context ctx, Cell cell, Cell origin)
          Terrain has received a color event, probably related to the firing of a color event on the board.
 void onDrop(Event event, Cell cell, Item item)
          Item is going to drop onto the terrain at this point.
 void onEnter(Event event, Player player, Cell cell, Direction dir)
          Agent attempting to leave the from cell, heading toward the to cell.
 void onExit(Event event, Player player, Cell cell, Direction dir)
          Agent attempting to exit the from cell, heading toward the to cell.
 void onFlyOver(Event event, Cell cell, InFlightItem flier)
          Terrain has an item flying over it.
 void onNotAdjacentTo(Context context, Cell cell)
          This terrain is no longer adjacent to the player.
 void onPickup(Event event, Cell loc, Agent agent, Item item)
          Item is going to be picked up.
 
Methods inherited from class us.asciiroth.client.core.AbstractPiece
getColor, getName, getSymbol
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface us.asciiroth.client.core.Piece
getColor, getName, getSymbol
 
Methods inherited from interface us.asciiroth.client.core.TerrainProxy
proxy
 

Constructor Detail

Decorator

public Decorator(Terrain terrain,
                 int flags)

Decorator

public Decorator(Terrain terrain,
                 int flags,
                 Color color)

Decorator

public Decorator(Terrain terrain,
                 int flags,
                 Color color,
                 Symbol symbol)

Decorator

public Decorator(Terrain terrain,
                 int flags,
                 Symbol symbol)

Decorator

public Decorator(Terrain terrain,
                 java.lang.String name,
                 int flags,
                 Color color,
                 Symbol symbol)
Method Detail

canEnter

public boolean canEnter(Agent agent,
                        Cell cell,
                        Direction direction)
Description copied from interface: Terrain
Can the (non-player) agent enter this terrain? Without regard to side effects, this method should determine if the agent can actually move into the cell. Error on the side of caution and return false if the answer is ambiguous.

Specified by:
canEnter in interface Terrain
Returns:
true if the agent can enter the terrain moving between the two cells using the indicated direction
See Also:
Cell.canEnter(Cell, Agent, Direction, boolean)

canExit

public boolean canExit(Agent agent,
                       Cell cell,
                       Direction direction)
Description copied from interface: Terrain
Can the (non-player) agent exit this terrain? Without regard to side effects, this method should determine if the agent can actually move into the cell. Error on the side of caution and return false if the answer is ambiguous.

Specified by:
canExit in interface Terrain
Returns:
true if the agent can leave this cell going in the indicated direction
See Also:
Cell.canEnter(Cell, Agent, Direction, boolean)

getProxiedTerrain

public Terrain getProxiedTerrain()
Specified by:
getProxiedTerrain in interface TerrainProxy
Returns:
the proxied terrain which will be used for rendering

is

public boolean is(int flag)
Description copied from interface: Piece
Does this piece have the indicated bit flag?

Specified by:
is in interface Piece
Overrides:
is in class AbstractPiece
Returns:
true if piece has the flag
See Also:
Flags

not

public boolean not(int flag)
Description copied from interface: Piece
Does this piece not have the indicated flag?

Specified by:
not in interface Piece
Overrides:
not in class AbstractPiece
Returns:
true if piece does not have the flag
See Also:
Flags

onAdjacentTo

public void onAdjacentTo(Context context,
                         Cell cell)
Description copied from interface: Terrain
This terrain is adjacent to the player. It may render differently under these circumstances.

Specified by:
onAdjacentTo in interface Terrain

onAgentEnter

public void onAgentEnter(Event event,
                         Agent agent,
                         Cell cell,
                         Direction dir)
Specified by:
onAgentEnter in interface Terrain

onAgentExit

public void onAgentExit(Event event,
                        Agent agent,
                        Cell cell,
                        Direction dir)
Specified by:
onAgentExit in interface Terrain

onColorEvent

public void onColorEvent(Context ctx,
                         Cell cell,
                         Cell origin)
Description copied from interface: ColorListener
Terrain has received a color event, probably related to the firing of a color event on the board. Different terrain behave differently when triggered, most flip between a set of states.

Specified by:
onColorEvent in interface ColorListener
Parameters:
ctx - a context object with references to game state

onDrop

public void onDrop(Event event,
                   Cell cell,
                   Item item)
Description copied from interface: Terrain
Item is going to drop onto the terrain at this point. If the event if canceled at this point, then the item will simply disappear from the board.

Specified by:
onDrop in interface Terrain

onEnter

public void onEnter(Event event,
                    Player player,
                    Cell cell,
                    Direction dir)
Description copied from interface: Terrain
Agent attempting to leave the from cell, heading toward the to cell. The terrain being used is the terrain of the to cell. The agent is still in the from
Specified by:
onEnter in interface Terrain

onExit

public void onExit(Event event,
                   Player player,
                   Cell cell,
                   Direction dir)
Description copied from interface: Terrain
Agent attempting to exit the from cell, heading toward the to cell. The terrain being used is the from cell terrain, and the agent is still in the from cell. If the event is canceled at this point, the agent will not be able leave this cell. The move will be canceled. This event is fired for the player as well as all other agents

Specified by:
onExit in interface Terrain

onFlyOver

public void onFlyOver(Event event,
                      Cell cell,
                      InFlightItem flier)
Description copied from interface: Terrain
Terrain has an item flying over it. If the event is canceled at this point, the item will fall to the ground on this cell.

Specified by:
onFlyOver in interface Terrain

onNotAdjacentTo

public void onNotAdjacentTo(Context context,
                            Cell cell)
Description copied from interface: Terrain
This terrain is no longer adjacent to the player. It may render differently under these circumstances.

Specified by:
onNotAdjacentTo in interface Terrain

onPickup

public void onPickup(Event event,
                     Cell loc,
                     Agent agent,
                     Item item)
Description copied from interface: Terrain
Item is going to be picked up. If the event is canceled at this point, the item will not be picked up and will remain on the cell.

Specified by:
onPickup in interface Terrain

0.7

© 2009 Alx Dark