net.sf.freecol.common.model
Class DefaultCostDecider

java.lang.Object
  extended by net.sf.freecol.common.model.DefaultCostDecider
All Implemented Interfaces:
CostDecider

public class DefaultCostDecider
extends java.lang.Object
implements CostDecider

Class for determining the cost of a single move.

This CostDecider is used as a default by findPath and search if no other CostDecider has been specified.


Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String LICENSE
           
static java.lang.String REVISION
           
 
Fields inherited from interface net.sf.freecol.common.model.CostDecider
ILLEGAL_MOVE
 
Constructor Summary
DefaultCostDecider()
           
 
Method Summary
 int getCost(Unit unit, Tile oldTile, Tile newTile, int ml, int turns)
          Determines the cost of a single move.
 int getMovesLeft()
          Gets the number of moves left.
 boolean isNewTurn()
          Checks if a new turn is needed in order to make the move.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

LICENSE

public static final java.lang.String LICENSE
See Also:
Constant Field Values

REVISION

public static final java.lang.String REVISION
See Also:
Constant Field Values
Constructor Detail

DefaultCostDecider

public DefaultCostDecider()
Method Detail

getCost

public int getCost(Unit unit,
                   Tile oldTile,
                   Tile newTile,
                   int ml,
                   int turns)
Determines the cost of a single move.

Specified by:
getCost in interface CostDecider
Parameters:
unit - The Unit making the move.
oldTile - The Tile we are moving from.
newTile - The Tile we are moving to.
ml - The remaining moves left.
turns - The number of turns spent so far.
Returns:
The cost of moving the given unit from the oldTile to the newTile.

getMovesLeft

public int getMovesLeft()
Gets the number of moves left. This method should be called after invoking getCost(net.sf.freecol.common.model.Unit, net.sf.freecol.common.model.Tile, net.sf.freecol.common.model.Tile, int, int).

Specified by:
getMovesLeft in interface CostDecider
Returns:
The number og moves left.

isNewTurn

public boolean isNewTurn()
Checks if a new turn is needed in order to make the move. This method should be called after invoking getCost(net.sf.freecol.common.model.Unit, net.sf.freecol.common.model.Tile, net.sf.freecol.common.model.Tile, int, int).

Specified by:
isNewTurn in interface CostDecider
Returns:
true if the move requires a new turn and false otherwise.