net.sf.freecol.server.control
Class InGameController

java.lang.Object
  extended by net.sf.freecol.server.control.FreeColServerHolder
      extended by net.sf.freecol.server.control.Controller
          extended by net.sf.freecol.server.control.InGameController

public final class InGameController
extends Controller

TODO: write class comment.


Field Summary
 int debugOnlyAITurns
           
 
Constructor Summary
InGameController(FreeColServer freeColServer)
          The constructor to use.
 
Method Summary
 Player checkForWinner()
          Checks if anybody has won the game and returns that player.
 void closeTransactionSession(Unit unit, Settlement settlement)
           
 boolean createMission(IndianSettlement settlement, Unit missionary)
           
 ServerPlayer createREFPlayer(ServerPlayer player)
           
 java.util.List<Unit> createREFUnits(ServerPlayer player, ServerPlayer refPlayer)
           
 ModelMessage emigrate(ServerPlayer player, int slot, boolean fountain)
          A unit migrates from Europe.
 void endTurn(ServerPlayer player)
          Ends the turn of the given player.
 java.util.List<ServerPlayer> getOtherPlayers(ServerPlayer serverPlayer)
          Get a list of all server players, optionally excluding the supplied one.
 java.util.Map<java.lang.String,java.lang.Object> getTransactionSession(Unit unit, Settlement settlement)
           
 boolean isTransactionSessionOpen(Unit unit, Settlement settlement)
           
 void sendRemoveUnitToAll(Unit unit, ServerPlayer serverPlayer)
          Tell all players to remove a unit, optionally excluding one player.
 void sendUpdatedTileToAll(Tile newTile, ServerPlayer serverPlayer)
          Tell all players to update a tile, optionally excluding one player.
 void sendUpdateToAll(FreeColGameObject obj, ServerPlayer serverPlayer)
          Unconditionally tell all players to update an object, optionally excluding one player.
 void unloadCargo(Player player, Goods goods)
           
 void yearlyGoodsRemoval(ServerPlayer player)
          Remove a standard yearly amount of storable goods, and a random extra amount of a random type.
 
Methods inherited from class net.sf.freecol.server.control.Controller
shutdown
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debugOnlyAITurns

public int debugOnlyAITurns
Constructor Detail

InGameController

public InGameController(FreeColServer freeColServer)
The constructor to use.

Parameters:
freeColServer - The main server object.
Method Detail

getOtherPlayers

public java.util.List<ServerPlayer> getOtherPlayers(ServerPlayer serverPlayer)
Get a list of all server players, optionally excluding the supplied one.

Parameters:
serverPlayer - A ServerPlayer to exclude (may be null).
Returns:
A list of all connected server players except one.

sendRemoveUnitToAll

public void sendRemoveUnitToAll(Unit unit,
                                ServerPlayer serverPlayer)
Tell all players to remove a unit, optionally excluding one player. Only send if the unit is visible to the player.

Parameters:
unit - The Unit to remove.
serverPlayer - A ServerPlayer to exclude (may be null).

sendUpdateToAll

public void sendUpdateToAll(FreeColGameObject obj,
                            ServerPlayer serverPlayer)
Unconditionally tell all players to update an object, optionally excluding one player.

Parameters:
obj - The FreeColGameObject to update.
serverPlayer - A ServerPlayer to exclude (may be null).

sendUpdatedTileToAll

public void sendUpdatedTileToAll(Tile newTile,
                                 ServerPlayer serverPlayer)
Tell all players to update a tile, optionally excluding one player. Only send if the tile is visible.

Parameters:
newTile - The Tile to update.
serverPlayer - A ServerPlayer to exclude (may be null).

endTurn

public void endTurn(ServerPlayer player)
Ends the turn of the given player.

Parameters:
player - The player to end the turn of.

yearlyGoodsRemoval

public void yearlyGoodsRemoval(ServerPlayer player)
Remove a standard yearly amount of storable goods, and a random extra amount of a random type. Send the market and change messages to the player. This method is public so it can be use in the Market test code.

Parameters:
player - The player whose market is to be updated.

checkForWinner

public Player checkForWinner()
Checks if anybody has won the game and returns that player.

Returns:
The Player who have won the game or null if the game is not finished.

createREFPlayer

public ServerPlayer createREFPlayer(ServerPlayer player)

createREFUnits

public java.util.List<Unit> createREFUnits(ServerPlayer player,
                                           ServerPlayer refPlayer)

createMission

public boolean createMission(IndianSettlement settlement,
                             Unit missionary)

getTransactionSession

public java.util.Map<java.lang.String,java.lang.Object> getTransactionSession(Unit unit,
                                                                              Settlement settlement)

closeTransactionSession

public void closeTransactionSession(Unit unit,
                                    Settlement settlement)

isTransactionSessionOpen

public boolean isTransactionSessionOpen(Unit unit,
                                        Settlement settlement)

emigrate

public ModelMessage emigrate(ServerPlayer player,
                             int slot,
                             boolean fountain)
A unit migrates from Europe.

Parameters:
player - The ServerPlayer whose unit it will be.
slot - The slot within Europe to select the unit from.
fountain - True if this occurs as a result of a Fountain of Youth.

unloadCargo

public void unloadCargo(Player player,
                        Goods goods)