|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.networking.ServerAPI
public class ServerAPI
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 |
|---|
private static final java.util.logging.Logger logger
private FreeColClient freeColClient
| Constructor Detail |
|---|
public ServerAPI(FreeColClient freeColClient)
ServerAPI.
freeColClient - The FreeColClient that is
communicating with a server.| Method Detail |
|---|
private java.util.HashMap<java.lang.String,java.lang.String> loadMap(java.lang.String... queries)
queries - Query strings.
private boolean send(DOMMessage message)
message - The DOMMessage to send.
private org.w3c.dom.Element askExpecting(DOMMessage message,
java.lang.String tag,
java.util.HashMap<java.lang.String,java.lang.String> results)
message - A DOMMessage to send.tag - The expected tagresults - A Map to store special attribute results in.
null.private void handleReply(org.w3c.dom.Element reply)
reply - The reply Element to handle.
private boolean askHandling(DOMMessage message,
java.lang.String tag,
java.util.HashMap<java.lang.String,java.lang.String> results)
message - A DOMMessage to send.tag - The expected tagresults - A Map to store special attribute results in.
public boolean abandonColony(Colony colony)
colony - The Colony to abandon.
public boolean answerMonarch(Monarch.MonarchAction action,
boolean accept)
action - The monarch action responded to.accept - Accept or reject the offer.
public boolean askSkill(Unit unit,
Map.Direction direction)
unit - The Unit that is asking.direction - The direction to a settlement to ask.
public boolean assignTeacher(Unit student,
Unit teacher)
student - The student Unit.teacher - The teacher Unit.
public boolean assignTradeRoute(Unit unit,
TradeRoute tradeRoute)
unit - The Unit to assign a trade route to.tradeRoute - The TradeRoute to assign.
public boolean attack(Unit unit,
Map.Direction direction)
unit - The Unit to perform the attack.direction - The direction in which to attack.
public boolean buildColony(java.lang.String name,
Unit unit)
name - The name for the colony.unit - The Unit that will build.
public boolean buyFromSettlement(Unit unit,
Settlement settlement,
Goods goods,
int gold)
unit - The Unit that is trading.settlement - The Settlement that is trading.goods - The Goods to buy.gold - The agreed price.
public boolean buyGoods(Unit carrier,
GoodsType type,
int amount)
carrier - The Unit to load with the goods.type - The type of goods to buy.amount - The amount of goods to buy.
public int buyProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
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).
public boolean cashInTreasureTrain(Unit unit)
unit - The treasure train Unit to cash in.
public boolean changeState(Unit unit,
Unit.UnitState state)
unit - The Unit to change the state of.state - The new UnitState.
public boolean changeWorkImprovementType(Unit unit,
TileImprovementType type)
unit - The Unit to change the work type of.type - The new TileImprovementType to work on.
public boolean changeWorkType(Unit unit,
GoodsType workType)
unit - The Unit to change the work type of.workType - The new GoodsType to produce.
public boolean checkHighScore()
public boolean claimLand(Tile tile,
Colony colony,
int price)
tile - The land to claim.colony - An optional Colony to own the land.price - The amount to pay.
public boolean clearSpeciality(Unit unit)
unit - The Unit to operate on.
public boolean closeTransactionSession(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
public boolean chat(java.lang.String chat)
chat - The text of the message.
public boolean declareIndependence(java.lang.String nation,
java.lang.String country)
nation - The name for the new nation.country - The name for the new country.
public boolean declineMounds(Unit unit,
Map.Direction direction)
unit - The Unit that is exploring.direction - The Direction to move.
public boolean deliverGiftToSettlement(Unit unit,
Settlement settlement,
Goods goods)
unit - The Unit that is trading.settlement - The Settlement that is trading.goods - The Goods to give.
public boolean demandTribute(Unit unit,
Map.Direction direction)
unit - The Unit that demands.direction - The direction to demand in.
public DiplomaticTrade diplomacy(Unit unit,
Settlement settlement,
DiplomaticTrade agreement)
unit - The Unit conducting the diplomacy.settlement - The Settlement to negotiate with.agreement - The DiplomaticTrade agreement to propose.
public boolean disbandUnit(Unit unit)
unit - The Unit to operate on.
public boolean disembark(Unit unit)
unit - The Unit that is disembarking.
public boolean embark(Unit unit,
Unit carrier,
Map.Direction direction)
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.
public boolean emigrate(int slot)
slot - The slot from which the unit migrates, 1-3 selects
a specific one, otherwise the server will choose one.
public boolean endTurn()
public boolean enterRevengeMode()
public boolean equipUnit(Unit unit,
EquipmentType type,
int amount)
unit - The Unit to equip on.type - The EquipmentType to equip with.amount - The amount of equipment.
public java.util.List<HighScore> getHighScores()
public boolean getNewTradeRoute()
public java.util.List<AbstractUnit> getREFUnits()
public java.util.List<Goods> getGoodsForSaleInSettlement(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
public java.util.Map<java.lang.String,java.lang.String> getStatistics()
public int incite(Unit unit,
Map.Direction direction,
Player enemy,
int gold)
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.
public boolean joinColony(Unit unit,
Colony colony)
unit - The Unit that will join.colony - The Colony to join.
public boolean learnSkill(Unit unit,
Map.Direction direction)
unit - The Unit that is asking.direction - The direction to a settlement to ask.
public boolean loadCargo(Goods goods,
Unit carrier)
goods - The Goods to load.carrier - The Unit to load onto.
public boolean loot(Unit winner,
java.lang.String defenderId,
java.util.List<Goods> goods)
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.
public boolean missionary(Unit unit,
Map.Direction direction,
boolean denounce)
unit - The missionary Unit.direction - The direction to a settlement to establish with.denounce - True if this is a denouncement.
public boolean move(Unit unit,
Map.Direction direction)
unit - The Unit to move.direction - The direction to move in.
public boolean moveTo(Unit unit,
Location destination)
unit - The Unit to move.destination - The Location to move to.
public NationSummary getNationSummary(Player player)
player - The Player to summarize.
public boolean newLandName(Unit unit,
java.lang.String name,
Player welcomer,
boolean accept)
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.
public boolean newRegionName(Region region,
Tile tile,
java.lang.String name)
region - The Region that is being discovered.tile - The Tile where the region is discovered.name - The new region name.
public boolean[] openTransactionSession(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
public boolean payArrears(GoodsType type)
type - The GoodsType to pay the arrears for.
public boolean payForBuilding(Colony colony)
colony - The Colony that is building.
public boolean rename(FreeColGameObject object,
java.lang.String name)
object - A FreeColGameObject to rename.name - The name to apply.
public boolean retire()
public boolean putOutsideColony(Unit unit)
unit - The Unit to put out.
public java.lang.String scoutSpeak(Unit unit,
Map.Direction direction)
unit - The Unit that is speaking.direction - The direction to a settlement to ask.
public boolean sellGoods(Goods goods,
Unit carrier)
goods - The Goods to sell.carrier - The Unit in Europe with the goods.
public int sellProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
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).
public boolean sellToSettlement(Unit unit,
Settlement settlement,
Goods goods,
int gold)
unit - The Unit that is trading.settlement - The Settlement that is trading.goods - The Goods to sell.gold - The agreed price.
public boolean setBuildQueue(Colony colony,
java.util.List<BuildableType> buildQueue)
colony - the ColonybuildQueue - the new values for the build queue
public boolean setDestination(Unit unit,
Location destination)
unit - The Unit to direct.destination - The destination Location.
Unit.setDestination(Location)
public boolean setGoodsLevels(Colony colony,
ExportData data)
colony - The Colony where the levels are set.data - The ExportData setting.
public boolean setTradeRoutes(java.util.List<TradeRoute> routes)
routes - A list of trade routes to update.
public boolean spy(Unit unit,
Map.Direction direction)
unit - The Unit that is spying.direction - The Direction of a colony to spy on.
public boolean startSkipping()
public boolean trainUnitInEurope(UnitType type)
type - The UnitType to train.
public boolean unloadCargo(Goods goods)
goods - The Goods to unload.
public boolean updateCurrentStop(Unit unit)
unit - The Unit whose stop is to be updated.
public boolean updateTradeRoute(TradeRoute route)
route - The trade route to update.
public boolean work(Unit unit,
WorkLocation workLocation)
unit - The Unit to change the workLocation of.workLocation - The WorkLocation to change to.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||