net.sf.freecol.client.control
Class ClientModelController

java.lang.Object
  extended by net.sf.freecol.client.control.ClientModelController
All Implemented Interfaces:
ModelController

public class ClientModelController
extends java.lang.Object
implements ModelController

A client-side implementation of the ModelController interface.


Constructor Summary
ClientModelController(FreeColClient freeColClient)
          Creates a new ClientModelController.
 
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)
          Returns 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
 void update(Tile tile)
          Tells the ModelController that an internal change (that is; not caused by the control) has occured in the model.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientModelController

public ClientModelController(FreeColClient freeColClient)
Creates a new ClientModelController.

Parameters:
freeColClient - The main controller.
Method Detail

getRandom

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

Specified by:
getRandom in interface ModelController
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.

createUnit

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

Specified by:
createUnit in interface ModelController
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

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

Specified by:
createBuilding in interface ModelController
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 (Building.FREE_COLONIST...).
Returns:
The created Building.

setToVacantEntryLocation

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

Specified by:
setToVacantEntryLocation in interface ModelController
Parameters:
unit - The Unit.
Returns:
The Location where the Unit appears.

setStance

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

Specified by:
setStance in interface ModelController
Parameters:
first - The first Player.
second - The second Player.
stance - The new stance.

exploreTiles

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

Specified by:
exploreTiles in interface ModelController
Parameters:
player - The Player that should see more tiles.
tiles - The tiles to explore.

update

public void update(Tile tile)
Tells the ModelController that an internal change (that is; not caused by the control) has occured in the model.

Parameters:
tile - The Tile which will need an update.

tileImprovementFinished

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

Specified by:
tileImprovementFinished in interface ModelController
Parameters:
unit - an Unit value
improvement - a TileImprovement value

getNewTradeRoute

public TradeRoute getNewTradeRoute(Player player)
Returns a new TradeRoute object.

Specified by:
getNewTradeRoute in interface ModelController
Returns:
a new TradeRoute object.