Package net.sf.freecol.common.model
Class Unit.ClosestSettlementGoalDecider
- java.lang.Object
-
- net.sf.freecol.common.model.Unit.ClosestSettlementGoalDecider
-
- All Implemented Interfaces:
GoalDecider
- Enclosing class:
- Unit
private static class Unit.ClosestSettlementGoalDecider extends java.lang.Object implements GoalDecider
-
-
Constructor Summary
Constructors Constructor Description ClosestSettlementGoalDecider(Tile exclude, boolean coastal)
Build a new goal decider to find the closest path to a settlement owned by the player controlling the searching unit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
check(Unit u, PathNode path)
Checks whether the givenPathNode
is a goal/sub-goal.PathNode
getGoal()
Gets thePathNode
containing the goal.boolean
hasSubGoals()
Determines whether thisGoalDecider
has any sub goals.
-
-
-
Constructor Detail
-
ClosestSettlementGoalDecider
public ClosestSettlementGoalDecider(Tile exclude, boolean coastal)
Build a new goal decider to find the closest path to a settlement owned by the player controlling the searching unit.- Parameters:
exclude
- An optional tile to exclude.coastal
- If true, a connected port is required.
-
-
Method Detail
-
getGoal
public PathNode getGoal()
Gets thePathNode
containing the goal.- Specified by:
getGoal
in interfaceGoalDecider
- Returns:
- The
PathNode
where theTile
returned bypathNode.getTile()
is the goal.
-
hasSubGoals
public boolean hasSubGoals()
Determines whether thisGoalDecider
has any sub goals.- Specified by:
hasSubGoals
in interfaceGoalDecider
- Returns:
true
if there are any sub goals andfalse
otherwise.
-
check
public boolean check(Unit u, PathNode path)
Checks whether the givenPathNode
is a goal/sub-goal.- Specified by:
check
in interfaceGoalDecider
- Parameters:
u
- TheUnit
which we are trying to find a path for.path
- ThePathNode
where theTile
returned bypathNode.getTile()
is the tile to be checked.- Returns:
true
if thePathNode
was either a goal or a sub goal andfalse
otherwise. The goal should be returned byGoalDecider.getGoal()
right after a call to this method, if this method returnstrue
andGoalDecider.hasSubGoals()
returnsfalse
.
-
-