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.


Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String LICENSE
           
static java.lang.String REVISION
           
 
Constructor Summary
ClientModelController(FreeColClient freeColClient)
          Creates a new ClientModelController.
 
Method Summary
 Unit createUnit(java.lang.String taskID, Location location, Player owner, int 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.
 PseudoRandom getPseudoRandom()
          Get the pseudo-random number generator provided by the client.
 int getRandom(java.lang.String taskID, int n)
          Returns a pseudorandom int, uniformly distributed between 0 (inclusive) and the specified value (exclusive).
 void setStance(Player first, Player second, int stance)
          Updates stances.
 Location setToVacantEntryLocation(Unit unit)
          Puts the specified Unit in America.
 boolean shouldCallNewTurn(FreeColGameObject freeColGameObject)
          Check if game object should receive newTurn call.
 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
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

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 pseudorandom 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,
                       int 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.

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,
                      int 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.

getPseudoRandom

public PseudoRandom getPseudoRandom()
Get the pseudo-random number generator provided by the client.

Specified by:
getPseudoRandom in interface ModelController
Returns:
random number generator.

getNewTradeRoute

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

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

shouldCallNewTurn

public boolean shouldCallNewTurn(FreeColGameObject freeColGameObject)
Check if game object should receive newTurn call.

Specified by:
shouldCallNewTurn in interface ModelController
Parameters:
freeColGameObject - The game object.
Returns:
true if owned by client player or not ownable.