net.sf.freecol.common.model
Interface ModelController

All Known Implementing Classes:
ClientModelController, ServerModelController

public interface ModelController

The ModelController is used by the model to perform tasks which cannot be done by the model.

The tasks might not be allowed to perform within the model (like generating random numbers or creating new FreeColGameObjects), or the model might have insufficient data.

Any FreeColGameObject may get access to the ModelController by using getGame().getModelController().


Method Summary
 Building createBuilding(java.lang.String taskID, Colony colony, BuildingType type)
          Creates a new building.
 Unit createUnit(java.lang.String taskID, Location location, Player owner, UnitType type)
          Creates a new unit.
 void exploreTiles(Player player, java.util.ArrayList<Tile> tiles)
          Explores the given tiles for the given player.
 TradeRoute getNewTradeRoute(Player player)
          Get a new TradeRoute object.
 int getRandom(java.lang.String taskID, int n)
          Returns a pseudo-random int, uniformly distributed between 0 (inclusive) and the specified value (exclusive).
 void setStance(Player first, Player second, Player.Stance stance)
          Updates stances.
 Location setToVacantEntryLocation(Unit unit)
          Puts the specified Unit in America.
 void tileImprovementFinished(Unit unit, TileImprovement improvement)
          Tells the ModelController that a tile improvement was finished
 

Method Detail

createUnit

Unit createUnit(java.lang.String taskID,
                Location location,
                Player owner,
                UnitType type)
Creates a new unit.

Parameters:
taskID - The taskID should be a unique identifier. One method to make a unique taskID:

getId() + "methodName:taskDescription"

As long as the "taskDescription" is unique within the method ("methodName"), you get a unique identifier.
location - The Location where the Unit will be created.
owner - The Player owning the Unit.
type - The type of unit (Unit.FREE_COLONIST...).
Returns:
The created Unit.

createBuilding

Building createBuilding(java.lang.String taskID,
                        Colony colony,
                        BuildingType type)
Creates a new building.

Parameters:
taskID - The taskID should be a unique identifier. One method to make a unique taskID:

getId() + "methodName:taskDescription"

As long as the "taskDescription" is unique within the method ("methodName"), you get a unique identifier.
colony - The Colony where the Building will be created.
type - The type of building.
Returns:
The created Building.

setToVacantEntryLocation

Location setToVacantEntryLocation(Unit unit)
Puts the specified Unit in America.

Parameters:
unit - The Unit.
Returns:
The Location where the Unit appears.

exploreTiles

void exploreTiles(Player player,
                  java.util.ArrayList<Tile> tiles)
Explores the given tiles for the given player.

Parameters:
player - The Player that should see more tiles.
tiles - The tiles to explore.

tileImprovementFinished

void tileImprovementFinished(Unit unit,
                             TileImprovement improvement)
Tells the ModelController that a tile improvement was finished

Parameters:
unit - an Unit value
improvement - a TileImprovement value

setStance

void setStance(Player first,
               Player second,
               Player.Stance stance)
Updates stances.

Parameters:
first - The first Player.
second - The second Player.
stance - The new stance.

getRandom

int getRandom(java.lang.String taskID,
              int n)
Returns a pseudo-random int, uniformly distributed between 0 (inclusive) and the specified value (exclusive).

Parameters:
taskID - The taskID should be a unique identifier. One method to make a unique taskID:

getId() + "methodName:taskDescription"

As long as the "taskDescription" is unique within the method ("methodName"), you get a unique identifier.
n - The specified value.
Returns:
The generated number.

getNewTradeRoute

TradeRoute getNewTradeRoute(Player player)
Get a new TradeRoute object.