net.sf.freecol.common.networking
Class ServerAPI

java.lang.Object
  extended by net.sf.freecol.common.networking.ServerAPI

public class ServerAPI
extends java.lang.Object

The API for client->server messaging.


Nested Class Summary
private  class ServerAPI.TrivialMessage
          Temporary trivial message wrapper.
 
Field Summary
private  FreeColClient freeColClient
           
private static java.util.logging.Logger logger
           
 
Constructor Summary
ServerAPI(FreeColClient freeColClient)
          Creates a new ServerAPI.
 
Method Summary
 boolean abandonColony(Colony colony)
          Server query-response to abandon a colony.
 boolean answerMonarch(Monarch.MonarchAction action, boolean accept)
          Server query-response to respond to a monarch offer.
private  org.w3c.dom.Element askExpecting(DOMMessage message, java.lang.String tag, java.util.HashMap<java.lang.String,java.lang.String> results)
          Sends the specified message to the server and returns the reply, if it has the specified tag.
private  boolean askHandling(DOMMessage message, java.lang.String tag, java.util.HashMap<java.lang.String,java.lang.String> results)
          Extends askExpecting to also handle returns from the server.
 boolean askSkill(Unit unit, Map.Direction direction)
          Server query-response for finding out the skill taught at a settlement.
 boolean assignTeacher(Unit student, Unit teacher)
          Server query-response for assigning a teacher.
 boolean assignTradeRoute(Unit unit, TradeRoute tradeRoute)
          Server query-response for assigning a trade route to a unit.
 boolean attack(Unit unit, Map.Direction direction)
          Server query-response for attacking.
 boolean buildColony(java.lang.String name, Unit unit)
          Server query-response for building a colony.
 boolean buyFromSettlement(Unit unit, Settlement settlement, Goods goods, int gold)
          Server query-response to buy the given goods from the natives.
 boolean buyGoods(Unit carrier, GoodsType type, int amount)
          Server query-response for buying goods in Europe.
 int buyProposition(Unit unit, Settlement settlement, Goods goods, int gold)
          Server query-response to ask the natives if a purchase is acceptable.
 boolean cashInTreasureTrain(Unit unit)
          Server query-response to cash in a treasure train.
 boolean changeState(Unit unit, Unit.UnitState state)
          Server query-response for changing unit state.
 boolean changeWorkImprovementType(Unit unit, TileImprovementType type)
          Server query-response for changing work improvement type.
 boolean changeWorkType(Unit unit, GoodsType workType)
          Server query-response for changing work type.
 boolean chat(java.lang.String chat)
          Send a chat message.
 boolean checkHighScore()
          Server query-response for checking the high score.
 boolean claimLand(Tile tile, Colony colony, int price)
          Server query-response to claim a piece of land.
 boolean clearSpeciality(Unit unit)
          Server query-response for clearing a unit speciality.
 boolean closeTransactionSession(Unit unit, Settlement settlement)
          Server query-response to close a transaction session for a trade.
 boolean declareIndependence(java.lang.String nation, java.lang.String country)
          Server query-response for declaring independence.
 boolean declineMounds(Unit unit, Map.Direction direction)
          Server query-response for the special case of deciding to explore a rumour but then declining not to investigate the strange mounds.
 boolean deliverGiftToSettlement(Unit unit, Settlement settlement, Goods goods)
          Server query-response to give the given goods to the natives.
 boolean demandTribute(Unit unit, Map.Direction direction)
          Server query-response for demanding a tribute from a native settlement.
 DiplomaticTrade diplomacy(Unit unit, Settlement settlement, DiplomaticTrade agreement)
          Handler server query-response for diplomatic messages.
 boolean disbandUnit(Unit unit)
          Server query-response for disbanding a unit.
 boolean disembark(Unit unit)
          Server query-response for disembarking from a carrier.
 boolean embark(Unit unit, Unit carrier, Map.Direction direction)
          Server query-response for boarding a carrier.
 boolean emigrate(int slot)
          Server query-response for emigration.
 boolean endTurn()
          Server query-response for asking for the turn to end.
 boolean enterRevengeMode()
          Server query-response for asking to enter revenge mode.
 boolean equipUnit(Unit unit, EquipmentType type, int amount)
          Server query-response for equipping a unit.
 java.util.List<Goods> getGoodsForSaleInSettlement(Unit unit, Settlement settlement)
          Server query-response to get a list of goods for sale from a settlement.
 java.util.List<HighScore> getHighScores()
          Server query-response for asking for the high scores list.
 NationSummary getNationSummary(Player player)
          Server query-response for asking for the nation summary of a player.
 boolean getNewTradeRoute()
          Server query-response for creating a new trade route.
 java.util.List<AbstractUnit> getREFUnits()
          Server query-response for asking about a players REF.
 java.util.Map<java.lang.String,java.lang.String> getStatistics()
          Server query-response for asking for the server statistics.
private  void handleReply(org.w3c.dom.Element reply)
          Handle a reply element using the client input handler.
 int incite(Unit unit, Map.Direction direction, Player enemy, int gold)
          Server query-response for inciting the natives.
 boolean joinColony(Unit unit, Colony colony)
          Server query-response for joining a colony.
 boolean learnSkill(Unit unit, Map.Direction direction)
          Server query-response for learning the skill taught at a settlement.
 boolean loadCargo(Goods goods, Unit carrier)
          Server query-response for loading cargo.
private  java.util.HashMap<java.lang.String,java.lang.String> loadMap(java.lang.String... queries)
          Helper to load a map.
 boolean loot(Unit winner, java.lang.String defenderId, java.util.List<Goods> goods)
          Server query-response for looting.
 boolean missionary(Unit unit, Map.Direction direction, boolean denounce)
          Server query-response for establishing/denouncing a mission.
 boolean move(Unit unit, Map.Direction direction)
          Server query-response for moving a unit.
 boolean moveTo(Unit unit, Location destination)
          Server query-response for moving to across the high seas.
 boolean newLandName(Unit unit, java.lang.String name, Player welcomer, boolean accept)
          Server query-response for naming a new land.
 boolean newRegionName(Region region, Tile tile, java.lang.String name)
          Server query-response for naming a new region.
 boolean[] openTransactionSession(Unit unit, Settlement settlement)
          Server query-response to get the transaction session for a trade.
 boolean payArrears(GoodsType type)
          Server query-response for tax paying arrears.
 boolean payForBuilding(Colony colony)
          Server query-response for paying for a building.
 boolean putOutsideColony(Unit unit)
          Server query-response for putting a unit outside a colony.
 boolean rename(FreeColGameObject object, java.lang.String name)
          Server query-response for renaming an object.
 boolean retire()
          Retires the player from the game.
 java.lang.String scoutSpeak(Unit unit, Map.Direction direction)
          Server query-response for speaking with a native chief.
 boolean sellGoods(Goods goods, Unit carrier)
          Server query-response for selling goods in Europe.
 int sellProposition(Unit unit, Settlement settlement, Goods goods, int gold)
          Server query-response to ask the natives if a sale is acceptable.
 boolean sellToSettlement(Unit unit, Settlement settlement, Goods goods, int gold)
          Server query-response to sell the given goods to the natives.
private  boolean send(DOMMessage message)
          Sends a DOMMessage to the server.
 boolean setBuildQueue(Colony colony, java.util.List<BuildableType> buildQueue)
          Server query-response for changing a build queue.
 boolean setDestination(Unit unit, Location destination)
          Server query-response to set the destination of the given unit.
 boolean setGoodsLevels(Colony colony, ExportData data)
          Server query-response for setting goods levels.
 boolean setTradeRoutes(java.util.List<TradeRoute> routes)
          Server query-response for setting the trade routes.
 boolean spy(Unit unit, Map.Direction direction)
          Server query-response for spying on a colony.
 boolean startSkipping()
          Server query-response for starting to skip turns.
 boolean trainUnitInEurope(UnitType type)
          Server query-response for training a unit in Europe.
 boolean unloadCargo(Goods goods)
          Server query-response for unloading cargo.
 boolean updateCurrentStop(Unit unit)
          Server query-response for updating the current stop.
 boolean updateTradeRoute(TradeRoute route)
          Server query-response for asking for updating the trade route.
 boolean work(Unit unit, WorkLocation workLocation)
          Server query-response for changing a work location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

freeColClient

private FreeColClient freeColClient
Constructor Detail

ServerAPI

public ServerAPI(FreeColClient freeColClient)
Creates a new ServerAPI.

Parameters:
freeColClient - The FreeColClient that is communicating with a server.
Method Detail

loadMap

private java.util.HashMap<java.lang.String,java.lang.String> loadMap(java.lang.String... queries)
Helper to load a map.

Parameters:
queries - Query strings.
Returns:
A map with null mappings for the query strings.

send

private boolean send(DOMMessage message)
Sends a DOMMessage to the server.

Parameters:
message - The DOMMessage to send.
Returns:
True if the send succeeded.

askExpecting

private org.w3c.dom.Element askExpecting(DOMMessage message,
                                         java.lang.String tag,
                                         java.util.HashMap<java.lang.String,java.lang.String> results)
Sends the specified message to the server and returns the reply, if it has the specified tag. Handle "error" replies if they have a messageID or when in debug mode. This routine allows code simplification in much of the following client-server communication. In following routines we follow the convention that server I/O is confined to the ask() routine, which typically returns true if the server interaction succeeded, which does *not* necessarily imply that the actual substance of the request was allowed (e.g. a move may result in the death of a unit rather than actually moving).

Parameters:
message - A DOMMessage to send.
tag - The expected tag
results - A Map to store special attribute results in.
Returns:
The answer from the server if it has the specified tag, otherwise null.

handleReply

private void handleReply(org.w3c.dom.Element reply)
Handle a reply element using the client input handler.

Parameters:
reply - The reply Element to handle.

askHandling

private boolean askHandling(DOMMessage message,
                            java.lang.String tag,
                            java.util.HashMap<java.lang.String,java.lang.String> results)
Extends askExpecting to also handle returns from the server.

Parameters:
message - A DOMMessage to send.
tag - The expected tag
results - A Map to store special attribute results in.
Returns:
True if the server interaction succeeded, else false.

abandonColony

public boolean abandonColony(Colony colony)
Server query-response to abandon a colony.

Parameters:
colony - The Colony to abandon.
Returns:
True if the server interaction succeeded.

answerMonarch

public boolean answerMonarch(Monarch.MonarchAction action,
                             boolean accept)
Server query-response to respond to a monarch offer.

Parameters:
action - The monarch action responded to.
accept - Accept or reject the offer.
Returns:
True if the server interaction succeeded.

askSkill

public boolean askSkill(Unit unit,
                        Map.Direction direction)
Server query-response for finding out the skill taught at a settlement.

Parameters:
unit - The Unit that is asking.
direction - The direction to a settlement to ask.
Returns:
True if the server interaction succeeded.

assignTeacher

public boolean assignTeacher(Unit student,
                             Unit teacher)
Server query-response for assigning a teacher.

Parameters:
student - The student Unit.
teacher - The teacher Unit.
Returns:
True if the server interaction succeeded.

assignTradeRoute

public boolean assignTradeRoute(Unit unit,
                                TradeRoute tradeRoute)
Server query-response for assigning a trade route to a unit.

Parameters:
unit - The Unit to assign a trade route to.
tradeRoute - The TradeRoute to assign.
Returns:
True if the server interaction succeeded.

attack

public boolean attack(Unit unit,
                      Map.Direction direction)
Server query-response for attacking.

Parameters:
unit - The Unit to perform the attack.
direction - The direction in which to attack.
Returns:
True if the server interaction succeeded.

buildColony

public boolean buildColony(java.lang.String name,
                           Unit unit)
Server query-response for building a colony.

Parameters:
name - The name for the colony.
unit - The Unit that will build.
Returns:
True if the server interaction succeeded.

buyFromSettlement

public boolean buyFromSettlement(Unit unit,
                                 Settlement settlement,
                                 Goods goods,
                                 int gold)
Server query-response to buy the given goods from the natives.

Parameters:
unit - The Unit that is trading.
settlement - The Settlement that is trading.
goods - The Goods to buy.
gold - The agreed price.
Returns:
True if the server interaction succeeded.

buyGoods

public boolean buyGoods(Unit carrier,
                        GoodsType type,
                        int amount)
Server query-response for buying goods in Europe.

Parameters:
carrier - The Unit to load with the goods.
type - The type of goods to buy.
amount - The amount of goods to buy.
Returns:
True if the server interaction succeeded.

buyProposition

public int buyProposition(Unit unit,
                          Settlement settlement,
                          Goods goods,
                          int gold)
Server query-response to ask the natives if a purchase is acceptable.

Parameters:
unit - The Unit that is trading.
settlement - The Settlement that is trading.
goods - The Goods to trade.
gold - The proposed price (including query on negative).
Returns:
The price of the goods.

cashInTreasureTrain

public boolean cashInTreasureTrain(Unit unit)
Server query-response to cash in a treasure train.

Parameters:
unit - The treasure train Unit to cash in.
Returns:
True if the server interaction succeeded.

changeState

public boolean changeState(Unit unit,
                           Unit.UnitState state)
Server query-response for changing unit state.

Parameters:
unit - The Unit to change the state of.
state - The new UnitState.
Returns:
boolean true if the server interaction succeeded.

changeWorkImprovementType

public boolean changeWorkImprovementType(Unit unit,
                                         TileImprovementType type)
Server query-response for changing work improvement type.

Parameters:
unit - The Unit to change the work type of.
type - The new TileImprovementType to work on.
Returns:
True if the server interaction succeeded.

changeWorkType

public boolean changeWorkType(Unit unit,
                              GoodsType workType)
Server query-response for changing work type.

Parameters:
unit - The Unit to change the work type of.
workType - The new GoodsType to produce.
Returns:
True if the server interaction succeeded.

checkHighScore

public boolean checkHighScore()
Server query-response for checking the high score.

Returns:
True if the player has achieved a new high score.

claimLand

public boolean claimLand(Tile tile,
                         Colony colony,
                         int price)
Server query-response to claim a piece of land.

Parameters:
tile - The land to claim.
colony - An optional Colony to own the land.
price - The amount to pay.
Returns:
True if the server interaction succeeded.

clearSpeciality

public boolean clearSpeciality(Unit unit)
Server query-response for clearing a unit speciality.

Parameters:
unit - The Unit to operate on.
Returns:
True if the server interaction succeeded.

closeTransactionSession

public boolean closeTransactionSession(Unit unit,
                                       Settlement settlement)
Server query-response to close a transaction session for a trade.

Parameters:
unit - The Unit that is trading.
settlement - The Settlement that is trading.
Returns:
True if the server interaction succeeded.

chat

public boolean chat(java.lang.String chat)
Send a chat message.

Parameters:
chat - The text of the message.
Returns:
True if the send succeeded.

declareIndependence

public boolean declareIndependence(java.lang.String nation,
                                   java.lang.String country)
Server query-response for declaring independence.

Parameters:
nation - The name for the new nation.
country - The name for the new country.
Returns:
True if the server interaction succeeded.

declineMounds

public boolean declineMounds(Unit unit,
                             Map.Direction direction)
Server query-response for the special case of deciding to explore a rumour but then declining not to investigate the strange mounds.

Parameters:
unit - The Unit that is exploring.
direction - The Direction to move.
Returns:
True if the server interaction succeeded.

deliverGiftToSettlement

public boolean deliverGiftToSettlement(Unit unit,
                                       Settlement settlement,
                                       Goods goods)
Server query-response to give the given goods to the natives.

Parameters:
unit - The Unit that is trading.
settlement - The Settlement that is trading.
goods - The Goods to give.
Returns:
True if the server interaction succeeded.

demandTribute

public boolean demandTribute(Unit unit,
                             Map.Direction direction)
Server query-response for demanding a tribute from a native settlement.

Parameters:
unit - The Unit that demands.
direction - The direction to demand in.
Returns:
True if the server interaction succeeded.

diplomacy

public DiplomaticTrade diplomacy(Unit unit,
                                 Settlement settlement,
                                 DiplomaticTrade agreement)
Handler server query-response for diplomatic messages.

Parameters:
unit - The Unit conducting the diplomacy.
settlement - The Settlement to negotiate with.
agreement - The DiplomaticTrade agreement to propose.
Returns:
The resulting agreement or null if none present.

disbandUnit

public boolean disbandUnit(Unit unit)
Server query-response for disbanding a unit.

Parameters:
unit - The Unit to operate on.
Returns:
True if the server interaction succeeded.

disembark

public boolean disembark(Unit unit)
Server query-response for disembarking from a carrier.

Parameters:
unit - The Unit that is disembarking.
Returns:
True if the server interaction succeeded.

embark

public boolean embark(Unit unit,
                      Unit carrier,
                      Map.Direction direction)
Server query-response for boarding a carrier.

Parameters:
unit - The Unit that is boarding.
carrier - The carrier Unit.
direction - An optional direction if the unit is boarding from an adjacent tile, or null if from the same tile.
Returns:
True if the server interaction succeeded.

emigrate

public boolean emigrate(int slot)
Server query-response for emigration.

Parameters:
slot - The slot from which the unit migrates, 1-3 selects a specific one, otherwise the server will choose one.
Returns:
True if the client-server interaction succeeded.

endTurn

public boolean endTurn()
Server query-response for asking for the turn to end.

Returns:
True if the server interaction succeeded.

enterRevengeMode

public boolean enterRevengeMode()
Server query-response for asking to enter revenge mode.

Returns:
True if the server interaction succeeded.

equipUnit

public boolean equipUnit(Unit unit,
                         EquipmentType type,
                         int amount)
Server query-response for equipping a unit.

Parameters:
unit - The Unit to equip on.
type - The EquipmentType to equip with.
amount - The amount of equipment.
Returns:
True if the server interaction succeeded.

getHighScores

public java.util.List<HighScore> getHighScores()
Server query-response for asking for the high scores list.

Returns:
The list of high scores.

getNewTradeRoute

public boolean getNewTradeRoute()
Server query-response for creating a new trade route.

Returns:
True if the server interaction succeeded.

getREFUnits

public java.util.List<AbstractUnit> getREFUnits()
Server query-response for asking about a players REF.

Returns:
A list of REF units for the player.

getGoodsForSaleInSettlement

public java.util.List<Goods> getGoodsForSaleInSettlement(Unit unit,
                                                         Settlement settlement)
Server query-response to get a list of goods for sale from a settlement.

Parameters:
unit - The Unit that is trading.
settlement - The Settlement that is trading.
Returns:
The goods for sale in the settlement, or null if the server interaction failed.

getStatistics

public java.util.Map<java.lang.String,java.lang.String> getStatistics()
Server query-response for asking for the server statistics.

Returns:
The server statistics.

incite

public int incite(Unit unit,
                  Map.Direction direction,
                  Player enemy,
                  int gold)
Server query-response for inciting the natives.

Parameters:
unit - The missionary Unit.
direction - The direction to a settlement to speak to.
enemy - An enemy Player.
gold - The amount of bribe, negative to enquire.
Returns:
The amount of gold to bribe with if this was an inquiry, zero for failure to incite and >0 for successful incitement, negative if the server interaction failed.

joinColony

public boolean joinColony(Unit unit,
                          Colony colony)
Server query-response for joining a colony.

Parameters:
unit - The Unit that will join.
colony - The Colony to join.
Returns:
True if the server interaction succeeded.

learnSkill

public boolean learnSkill(Unit unit,
                          Map.Direction direction)
Server query-response for learning the skill taught at a settlement.

Parameters:
unit - The Unit that is asking.
direction - The direction to a settlement to ask.
Returns:
True if the server interaction succeeded.

loadCargo

public boolean loadCargo(Goods goods,
                         Unit carrier)
Server query-response for loading cargo.

Parameters:
goods - The Goods to load.
carrier - The Unit to load onto.
Returns:
True if the query-response succeeds.

loot

public boolean loot(Unit winner,
                    java.lang.String defenderId,
                    java.util.List<Goods> goods)
Server query-response for looting. Handles both an initial query and the actual looting.

Parameters:
winner - The Unit that is looting.
defenderId - The id of the defender unit (it may have sunk).
goods - A list of Goods, if empty this is a query as to what is to be looted which is filled into the list, if non-empty, then the list of goods to loot.
Returns:
True if the server interaction succeeded.

missionary

public boolean missionary(Unit unit,
                          Map.Direction direction,
                          boolean denounce)
Server query-response for establishing/denouncing a mission.

Parameters:
unit - The missionary Unit.
direction - The direction to a settlement to establish with.
denounce - True if this is a denouncement.
Returns:
True if the server interaction succeeded.

move

public boolean move(Unit unit,
                    Map.Direction direction)
Server query-response for moving a unit.

Parameters:
unit - The Unit to move.
direction - The direction to move in.
Returns:
True if the server interaction succeeded.

moveTo

public boolean moveTo(Unit unit,
                      Location destination)
Server query-response for moving to across the high seas.

Parameters:
unit - The Unit to move.
destination - The Location to move to.
Returns:
True if the server interaction succeeded.

getNationSummary

public NationSummary getNationSummary(Player player)
Server query-response for asking for the nation summary of a player.

Parameters:
player - The Player to summarize.
Returns:
A summary of that nation, or null on error.

newLandName

public boolean newLandName(Unit unit,
                           java.lang.String name,
                           Player welcomer,
                           boolean accept)
Server query-response for naming a new land.

Parameters:
unit - The Unit that has come ashore.
name - The new land name.
welcomer - A welcoming native player with whom to make a treaty.
accept - True if the treaty was accepted.
Returns:
True if the server interaction succeeded.

newRegionName

public boolean newRegionName(Region region,
                             Tile tile,
                             java.lang.String name)
Server query-response for naming a new region.

Parameters:
region - The Region that is being discovered.
tile - The Tile where the region is discovered.
name - The new region name.
Returns:
True if the server interaction succeeded.

openTransactionSession

public boolean[] openTransactionSession(Unit unit,
                                        Settlement settlement)
Server query-response to get the transaction session for a trade.

Parameters:
unit - The Unit that is trading.
settlement - The Settlement that is trading.
Returns:
An array of booleans for the buy/sell/gift status, or null if the server interaction failed.

payArrears

public boolean payArrears(GoodsType type)
Server query-response for tax paying arrears.

Parameters:
type - The GoodsType to pay the arrears for.
Returns:
True if the server interaction succeeded.

payForBuilding

public boolean payForBuilding(Colony colony)
Server query-response for paying for a building.

Parameters:
colony - The Colony that is building.
Returns:
True if the server interaction succeeded.

rename

public boolean rename(FreeColGameObject object,
                      java.lang.String name)
Server query-response for renaming an object.

Parameters:
object - A FreeColGameObject to rename.
name - The name to apply.
Returns:
True if the renaming succeeded.

retire

public boolean retire()
Retires the player from the game.

Returns:
True if the player achieved a new high score.

putOutsideColony

public boolean putOutsideColony(Unit unit)
Server query-response for putting a unit outside a colony.

Parameters:
unit - The Unit to put out.
Returns:
True if the server interaction succeeded.

scoutSpeak

public java.lang.String scoutSpeak(Unit unit,
                                   Map.Direction direction)
Server query-response for speaking with a native chief.

Parameters:
unit - The Unit that is speaking.
direction - The direction to a settlement to ask.
Returns:
A string describing the result, or null if the server interaction failed.

sellGoods

public boolean sellGoods(Goods goods,
                         Unit carrier)
Server query-response for selling goods in Europe.

Parameters:
goods - The Goods to sell.
carrier - The Unit in Europe with the goods.
Returns:
True if the server interaction succeeded.

sellProposition

public int sellProposition(Unit unit,
                           Settlement settlement,
                           Goods goods,
                           int gold)
Server query-response to ask the natives if a sale is acceptable.

Parameters:
unit - The Unit that is trading.
settlement - The Settlement that is trading.
goods - The Goods to trade.
gold - The proposed price (including query on negative).
Returns:
The selling price for the goods.

sellToSettlement

public boolean sellToSettlement(Unit unit,
                                Settlement settlement,
                                Goods goods,
                                int gold)
Server query-response to sell the given goods to the natives.

Parameters:
unit - The Unit that is trading.
settlement - The Settlement that is trading.
goods - The Goods to sell.
gold - The agreed price.
Returns:
True if the server interaction succeeded.

setBuildQueue

public boolean setBuildQueue(Colony colony,
                             java.util.List<BuildableType> buildQueue)
Server query-response for changing a build queue.

Parameters:
colony - the Colony
buildQueue - the new values for the build queue
Returns:
True if the server interaction succeeded.

setDestination

public boolean setDestination(Unit unit,
                              Location destination)
Server query-response to set the destination of the given unit.

Parameters:
unit - The Unit to direct.
destination - The destination Location.
Returns:
True if the server interaction succeeded.
See Also:
Unit.setDestination(Location)

setGoodsLevels

public boolean setGoodsLevels(Colony colony,
                              ExportData data)
Server query-response for setting goods levels.

Parameters:
colony - The Colony where the levels are set.
data - The ExportData setting.
Returns:
True if the server interaction succeeded.

setTradeRoutes

public boolean setTradeRoutes(java.util.List<TradeRoute> routes)
Server query-response for setting the trade routes.

Parameters:
routes - A list of trade routes to update.
Returns:
True if the server interaction succeeded.

spy

public boolean spy(Unit unit,
                   Map.Direction direction)
Server query-response for spying on a colony.

Parameters:
unit - The Unit that is spying.
direction - The Direction of a colony to spy on.
Returns:
True if the client/server interaction succeeded.

startSkipping

public boolean startSkipping()
Server query-response for starting to skip turns.

Returns:
True if the server interaction succeeded.

trainUnitInEurope

public boolean trainUnitInEurope(UnitType type)
Server query-response for training a unit in Europe.

Parameters:
type - The UnitType to train.
Returns:
True if the server interaction succeeded.

unloadCargo

public boolean unloadCargo(Goods goods)
Server query-response for unloading cargo.

Parameters:
goods - The Goods to unload.
Returns:
True if the query-response succeeds.

updateCurrentStop

public boolean updateCurrentStop(Unit unit)
Server query-response for updating the current stop.

Parameters:
unit - The Unit whose stop is to be updated.
Returns:
True if the query-response succeeds.

updateTradeRoute

public boolean updateTradeRoute(TradeRoute route)
Server query-response for asking for updating the trade route.

Parameters:
route - The trade route to update.
Returns:
True if the server interaction succeeded.

work

public boolean work(Unit unit,
                    WorkLocation workLocation)
Server query-response for changing a work location.

Parameters:
unit - The Unit to change the workLocation of.
workLocation - The WorkLocation to change to.
Returns:
True if the server interaction succeeded.