|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.client.control.InGameController
public final class InGameController
The controller that will be used while the game is played.
| Field Summary | |
|---|---|
private java.util.ArrayList<java.io.File> |
allSaveGames
A list of save game files. |
private boolean |
canAutoEndTurn
If true, then at least one unit has been active and the turn may automatically be ended. |
private boolean |
endingTurn
Sets that the turn will be ended when all going-to units have been moved. |
private boolean |
executeGoto
Sets that all going-to orders should be executed. |
private FreeColClient |
freeColClient
|
private static java.util.logging.Logger |
logger
|
private java.util.HashMap<java.lang.String,java.lang.Integer> |
messagesToIgnore
A hash map of messages to be ignored. |
private short |
UNIT_LAST_MOVE_DELAY
|
| Fields inherited from interface net.sf.freecol.common.networking.NetworkConstants |
|---|
NO_NEED_FOR_THE_GOODS, NO_TRADE |
| Constructor Summary | |
|---|---|
InGameController(FreeColClient freeColClient)
The constructor to use. |
|
| Method Summary | |
|---|---|
void |
abandonColony(Colony colony)
Abandon a colony with no units |
private org.w3c.dom.Element |
askExpecting(Client client,
org.w3c.dom.Element element,
java.lang.String tag)
Sends the specified message to the server and returns the reply, if it has the specified tag. |
void |
assignTeacher(Unit student,
Unit teacher)
Assigns a unit to a teacher Unit. |
void |
assignTradeRoute(Unit unit)
Assigns a trade route to a unit. |
void |
assignTradeRoute(Unit unit,
TradeRoute tradeRoute)
|
private void |
attack(Unit unit,
Map.Direction direction)
Ask for attack or demand a tribute when attacking an indian settlement, attack in other cases |
private void |
attemptBuyFromSettlement(Unit unit,
Settlement settlement)
User interaction for buying from the natives. |
private void |
attemptGiftToSettlement(Unit unit,
Settlement settlement)
User interaction for delivering a gift to the natives. |
private void |
attemptSellToSettlement(Unit unit,
Settlement settlement)
User interaction for selling to the natives. |
void |
autosaveGame()
|
boolean |
boardShip(Unit unit,
Unit carrier)
Boards a specified unit onto a carrier. |
void |
buildColony()
Uses the active unit to build a colony. |
private void |
buyFromSettlement(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Buys the given goods from the natives. |
void |
buyGoods(GoodsType type,
int amount,
Unit carrier)
Buys goods in Europe. |
private void |
buyTradeGoodsFromEurope(Unit unit)
|
void |
centerActiveUnit()
Centers the map on the selected tile. |
void |
centerOnUnit(Unit unit)
Centers the map on the given unit location. |
void |
changeState(Unit unit,
Unit.UnitState state)
Changes the state of this Unit. |
void |
changeWorkImprovementType(Unit unit,
TileImprovementType improvementType)
Changes the work type of this Unit. |
void |
changeWorkType(Unit unit,
GoodsType workType)
Changes the work type of this Unit. |
boolean |
checkCashInTreasureTrain(Unit unit)
Check if a unit is a treasure train, and if it should be cashed in. |
private void |
checkTradeRoutesInEurope()
|
boolean |
claimLand(Tile tile,
Colony colony,
int offer)
Claim a piece of land. |
void |
clearGotoOrders(Unit unit)
Clears the orders of the given Unit. |
void |
clearOrders(Unit unit)
Clears the orders of the given Unit The orders are cleared
by making the unit Unit.UnitState.ACTIVE and setting a null
destination |
void |
clearSpeciality(Unit unit)
Clear the speciality of a Unit. |
private void |
closeTransactionSession(Unit unit,
Settlement settlement)
Close a transaction session. |
private boolean |
confirmHostileAction(Unit attacker,
Tile target)
Check if an attack results in a transition from peace or cease fire to war and, if so, warn the player. |
private boolean |
confirmPreCombat(Unit attacker,
Tile target)
If the client options include a pre-combat dialog, allow the user to view the odds and possibly cancel the attack. |
void |
debugForeignColony(Tile tile)
|
void |
declareIndependence()
Declares independence for the home country. |
private void |
deliverGiftToSettlement(Unit unit,
Settlement settlement,
Goods goods)
Give the given goods to the natives. |
void |
disbandActiveUnit()
Disbands the active unit. |
private void |
disembark(Unit unit,
Map.Direction direction)
Disembarks the specified unit in a specified direction. |
void |
displayModelMessages(boolean allMessages)
|
private void |
embark(Unit unit,
Map.Direction direction)
Embarks the specified unit in a specified direction. |
private void |
emigrateUnitInEurope(int slot)
Request a unit to migrate from a specified "slot" in Europe. |
void |
endTurn()
End the turn. |
void |
equipUnit(Unit unit,
EquipmentType type,
int amount)
Equips or unequips a Unit with a certain type of
Goods. |
void |
executeGotoOrders()
Executes the units' goto orders. |
private void |
exploreLostCityRumour(Unit unit,
Map.Direction direction)
Confirm exploration of a lost city rumour, moving if accepted. |
private void |
followTradeRoute(Unit unit)
|
protected org.w3c.dom.Element |
getChildElement(org.w3c.dom.Element element,
java.lang.String tagName)
Convenience method: returns the first child element with the specified tagname. |
org.w3c.dom.Element |
getForeignAffairsReport()
Gathers information about opponents. |
private java.util.List<Goods> |
getGoodsForSaleInSettlement(Unit unit,
Settlement settlement)
Get a list of goods for sale from a settlement. |
org.w3c.dom.Element |
getHighScores()
Retrieves high scores from server. |
java.util.List<AbstractUnit> |
getREFUnits()
Gathers information about the REF. |
StatisticsMessage |
getServerStatistics()
Retrieves server statistics |
private java.util.Map<java.lang.String,java.lang.Boolean> |
getTransactionSession(Unit unit,
Settlement settlement)
Get the transaction session for a trade. |
private java.lang.Integer |
getTurnForMessageIgnored(java.lang.String key)
|
void |
ignoreMessage(ModelMessage message,
boolean flag)
Ignore this ModelMessage from now on until it is not generated in a turn. |
private boolean |
knownEnemyOnLastTile(PathNode path)
|
private void |
learnSkillAtIndianSettlement(Unit unit,
Map.Direction direction)
Moves the specified free colonist into an Indian settlement to learn a skill. |
void |
leaveShip(Unit unit)
Leave a ship. |
void |
loadCargo(Goods goods,
Unit carrier)
Loads a cargo onto a carrier. |
void |
loadGame()
Opens a dialog where the user should specify the filename and loads the game. |
private void |
loadTradeGoodsFromColony(Unit unit)
|
void |
move(Unit unit,
Map.Direction direction)
Moves the specified unit in a specified direction. |
void |
moveActiveUnit(Map.Direction direction)
Moves the active unit in a specified direction. |
private void |
moveHighSeas(Unit unit,
Map.Direction direction)
Moves the specified unit in the "high seas" in a specified direction. |
void |
moveToAmerica(Unit unit)
Moves the specified unit to America. |
void |
moveToDestination(Unit unit)
Moves the given unit towards the destination given by Unit.getDestination(). |
void |
moveToEurope(Unit unit)
Moves the specified unit to Europe. |
private void |
negotiate(Unit unit,
Map.Direction direction)
Initiates a negotiation with a foreign power. |
void |
nextActiveUnit()
Makes a new unit active. |
void |
nextActiveUnit(Tile tile)
Makes a new unit active. |
void |
nextModelMessage()
Displays the next ModelMessage. |
void |
payArrears(Goods goods)
Pays the tax arrears on this type of goods. |
void |
payArrears(GoodsType type)
Pays the tax arrears on this type of goods. |
void |
payForBuilding(Colony colony)
Buys the remaining hammers and tools for the Building currently
being built in the given Colony. |
private int |
proposeToBuyFromSettlement(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Ask the natives if a purchase is acceptable. |
private int |
proposeToSellToSettlement(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Ask the natives if a sale is acceptable. |
void |
purchaseUnitFromEurope(UnitType unitType)
Purchases a unit of a specified type in Europe. |
private void |
purgeOldMessagesFromMessagesToIgnore(int thisTurn)
|
boolean |
putOutsideColony(Unit unit)
Puts the specified unit outside the colony. |
private void |
reallyAttack(Unit unit,
Map.Direction direction)
Performs an attack in a specified direction. |
private void |
reallyMove(Unit unit,
Map.Direction direction)
Actually moves a unit in a specified direction. |
void |
recruitUnitInEurope(int slot)
Recruit a unit from a specified "slot" in Europe. |
private void |
removeUnitsOutsideLOS()
Removes the units we cannot see anymore from the map. |
void |
rename(Nameable object)
Renames a Nameable. |
void |
saveGame()
Opens a dialog where the user should specify the filename and saves the game. |
void |
saveGame(java.io.File file)
Saves the game to the given file. |
private void |
scoutForeignColony(Unit unit,
Map.Direction direction)
Ask for spy the foreign colony, negotiate with the foreign power or attack the colony |
private void |
scoutIndianSettlement(Unit unit,
Map.Direction direction)
Moves the specified scout into an Indian settlement to speak with the chief or demand a tribute etc. |
void |
selectDestination(Unit unit)
Selects a destination for this unit. |
void |
sellGoods(Goods goods)
Sells goods in Europe. |
private void |
sellToSettlement(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Sells the given goods to the natives. |
private void |
sellTradeGoodsInEurope(Unit unit)
|
void |
sendChat(java.lang.String message)
Sends a public chat message. |
void |
setBuildQueue(Colony colony,
java.util.List<BuildableType> buildQueue)
Changes the current construction project of a Colony. |
void |
setCurrentPlayer(Player currentPlayer)
Sets player as the new currentPlayer of the
game. |
void |
setDestination(Unit unit,
Location destination)
Sets the destination of the given unit and send the server a message for this action. |
void |
setGoodsLevels(Colony colony,
GoodsType goodsType)
Sets the export settings of the custom house. |
void |
setInDebugMode(boolean debug)
Sets the "debug mode" to be active or not. |
void |
setTradeRoutes(java.util.List<TradeRoute> routes)
Sets the trade routes for this player |
private boolean |
shouldAllowMessage(ModelMessage message)
Provides an opportunity to filter the messages delivered to the canvas. |
private boolean |
showColonyWarnings(Tile tile,
Unit unit)
A colony is proposed to be built. |
private void |
spy(Unit unit,
Map.Direction direction)
Spy on a foreign colony. |
private void |
startIgnoringMessage(java.lang.String key,
int turn)
|
private void |
stopIgnoringMessage(java.lang.String key)
|
private void |
tradeWithSettlement(Unit unit,
Map.Direction direction)
Trading with the natives, including buying, selling and delivering gifts. |
void |
trainUnitInEurope(UnitType unitType)
Trains a unit of a specified type in Europe. |
void |
unloadCargo(Goods goods)
Unload cargo. |
void |
unloadCargo(Goods goods,
boolean dump)
Unload cargo. |
private void |
unloadTradeGoodsToColony(Unit unit)
|
void |
updateTradeRoute(TradeRoute route)
Updates a trade route. |
private void |
useMissionary(Unit unit,
Map.Direction direction)
Moves a missionary into an indian settlement. |
void |
work(Unit unit,
WorkLocation workLocation)
Moves a Unit to a WorkLocation. |
| 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 final FreeColClient freeColClient
private final short UNIT_LAST_MOVE_DELAY
private boolean endingTurn
private boolean canAutoEndTurn
private boolean executeGoto
private java.util.HashMap<java.lang.String,java.lang.Integer> messagesToIgnore
private java.util.ArrayList<java.io.File> allSaveGames
| Constructor Detail |
|---|
public InGameController(FreeColClient freeColClient)
freeColClient - The main controller.| Method Detail |
|---|
public void saveGame()
public void saveGame(java.io.File file)
file - The File.public void loadGame()
public void setInDebugMode(boolean debug)
FreeCol.setInDebugMode(boolean) and reinitialize the
FreeColMenuBar.
debug - Should be set to true in order to enable
debug mode.
private org.w3c.dom.Element askExpecting(Client client,
org.w3c.dom.Element element,
java.lang.String tag)
client - a Client valueelement - The Element (root element in a DOM-parsed
XML tree) that holds all the informationtag - The expected tag
null.public void declareIndependence()
public void sendChat(java.lang.String message)
message - The text of the message.public void setCurrentPlayer(Player currentPlayer)
player as the new currentPlayer of the
game.
currentPlayer - The player.public void autosaveGame()
public void rename(Nameable object)
Nameable.
object - The object to rename.private void removeUnitsOutsideLOS()
public void buildColony()
private boolean showColonyWarnings(Tile tile,
Unit unit)
tile - The Tile on which the colony is to be built.unit - The Unit which is to build the colony.public void moveActiveUnit(Map.Direction direction)
direction - The direction in which to move the active unit.public void selectDestination(Unit unit)
unit - The unit for which to select a destination.
public void setDestination(Unit unit,
Location destination)
unit - The Unit to direct.destination - The destination Location.Unit.setDestination(Location)public void moveToDestination(Unit unit)
Unit.getDestination().
unit - The Unit to move.private boolean knownEnemyOnLastTile(PathNode path)
private void checkTradeRoutesInEurope()
private void followTradeRoute(Unit unit)
private void loadTradeGoodsFromColony(Unit unit)
private void unloadTradeGoodsToColony(Unit unit)
private void sellTradeGoodsInEurope(Unit unit)
private void buyTradeGoodsFromEurope(Unit unit)
public void move(Unit unit,
Map.Direction direction)
unit - The unit to be moved.direction - The direction in which to move the Unit.
private void negotiate(Unit unit,
Map.Direction direction)
unit - The Unit negotiating.direction - The direction of a settlement to negotiate with.
private void spy(Unit unit,
Map.Direction direction)
unit - The Unit that is spying.direction - The direction of a colony to spy on.public void debugForeignColony(Tile tile)
private void exploreLostCityRumour(Unit unit,
Map.Direction direction)
unit - The Unit that is exploring.direction - The direction of a rumour.
public boolean claimLand(Tile tile,
Colony colony,
int offer)
tile - The land to claim.colony - An optional Colony to own the land.offer - An offer to pay.
private java.util.Map<java.lang.String,java.lang.Boolean> getTransactionSession(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
private void closeTransactionSession(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
private java.util.List<Goods> getGoodsForSaleInSettlement(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
private void tradeWithSettlement(Unit unit,
Map.Direction direction)
unit - The Unit that is a carrier containing goods.direction - The direction the unit could move in order to enter a
Settlement.
java.lang.IllegalArgumentException - if the unit is not a carrier, or if
there is no Settlement in the given
direction.Settlement
private void attemptBuyFromSettlement(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
private int proposeToBuyFromSettlement(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).
private void 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.
private void attemptSellToSettlement(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
private int proposeToSellToSettlement(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).
private void 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.
private void attemptGiftToSettlement(Unit unit,
Settlement settlement)
unit - The Unit that is trading.settlement - The Settlement that is trading.
private void 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 checkCashInTreasureTrain(Unit unit)
owner.
unit - The Unit to be checked.
private void reallyMove(Unit unit,
Map.Direction direction)
unit - The unit to be moved.direction - The direction in which to move the Unit.
private void attack(Unit unit,
Map.Direction direction)
unit - The unit to perform the attack.direction - The direction in which to attack.
private boolean confirmHostileAction(Unit attacker,
Tile target)
attacker - The potential attacker.target - The target tile.
private boolean confirmPreCombat(Unit attacker,
Tile target)
attacker - The attacker.target - The target tile.
private void reallyAttack(Unit unit,
Map.Direction direction)
unit - The unit to perform the attack.direction - The direction in which to attack.
private void disembark(Unit unit,
Map.Direction direction)
unit - The unit to be disembarked.direction - The direction in which to disembark the Unit.
private void embark(Unit unit,
Map.Direction direction)
unit - The unit to be embarked.direction - The direction in which to embark the Unit.
public boolean boardShip(Unit unit,
Unit carrier)
unit - The unit who is going to board the carrier.carrier - The carrier.
unit actually gets on the
carrier.public void clearSpeciality(Unit unit)
Unit. That is, makes it a
Unit.FREE_COLONIST.
unit - The Unit to clear the speciality of.public void leaveShip(Unit unit)
unit - The unit who is going to leave the ship where it is located.
public void loadCargo(Goods goods,
Unit carrier)
goods - The goods which are going aboard the carrier.carrier - The carrier.public void unloadCargo(Goods goods)
goods - The goods which are going to leave the ship where it is
located.
public void unloadCargo(Goods goods,
boolean dump)
goods - The goods which are going to leave the ship where it is
located.dump - a boolean value
public void buyGoods(GoodsType type,
int amount,
Unit carrier)
carrier.
type - The type of goods to buy.amount - The amount of goods to buy.carrier - The carrier.public void sellGoods(Goods goods)
goods - The goods to be sold.
public void setGoodsLevels(Colony colony,
GoodsType goodsType)
colony - The colony with the custom house.goodsType - The goods for which to set the settings.
public void equipUnit(Unit unit,
EquipmentType type,
int amount)
Unit with a certain type of
Goods.
unit - The Unit.type - an EquipmentType valueamount - How many of these goods the unit should have.
public void work(Unit unit,
WorkLocation workLocation)
Unit to a WorkLocation.
unit - The Unit.workLocation - The WorkLocation.public boolean putOutsideColony(Unit unit)
unit - The Unit
public void changeWorkType(Unit unit,
GoodsType workType)
Unit.
unit - The UnitworkType - The new GoodsType to produce.
public void changeWorkImprovementType(Unit unit,
TileImprovementType improvementType)
Unit.
unit - The UnitimprovementType - a TileImprovementType value
public void assignTeacher(Unit student,
Unit teacher)
Unit.
student - an Unit valueteacher - an Unit value
public void setBuildQueue(Colony colony,
java.util.List<BuildableType> buildQueue)
Colony.
colony - The Colony
public void changeState(Unit unit,
Unit.UnitState state)
Unit.
unit - The Unitstate - The state of the unit.public void clearOrders(Unit unit)
Unit The orders are cleared
by making the unit Unit.UnitState.ACTIVE and setting a null
destination
unit - The Unit.public void clearGotoOrders(Unit unit)
Unit. The orders are
cleared by making the unit Unit.UnitState.ACTIVE.
unit - The Unit.
private void moveHighSeas(Unit unit,
Map.Direction direction)
unit - The unit to be moved.direction - The direction in which to move the Unit.
private void learnSkillAtIndianSettlement(Unit unit,
Map.Direction direction)
unit - The unit to learn the skill.direction - The direction in which the Indian settlement lies.
private void scoutForeignColony(Unit unit,
Map.Direction direction)
unit - The unit that will spy, negotiate or attack.direction - The direction in which the foreign colony lies.
private void scoutIndianSettlement(Unit unit,
Map.Direction direction)
unit - The unit that will speak, attack or ask tribute.direction - The direction in which the Indian settlement lies.
private void useMissionary(Unit unit,
Map.Direction direction)
unit - The unit that will enter the settlement.direction - The direction in which the Indian settlement lies.public void moveToEurope(Unit unit)
unit - The unit to be moved to Europe.public void moveToAmerica(Unit unit)
unit - The unit to be moved to America.public void trainUnitInEurope(UnitType unitType)
unitType - The type of unit to be trained.public void payForBuilding(Colony colony)
Building currently
being built in the given Colony.
colony - The Colony where the building should be bought.public void recruitUnitInEurope(int slot)
slot - The slot to recruit the unit from. Either 1, 2 or 3.private void emigrateUnitInEurope(int slot)
slot - The slot from which the unit migrates, 1-3 selects a specific
one, otherwise the server will choose one.public void updateTradeRoute(TradeRoute route)
route - The trade route to update.public void setTradeRoutes(java.util.List<TradeRoute> routes)
routes - The trade routes to set.public void assignTradeRoute(Unit unit)
unit - The unit to assign a trade route to.
public void assignTradeRoute(Unit unit,
TradeRoute tradeRoute)
public void payArrears(Goods goods)
goods - The goods for which to pay arrears.public void payArrears(GoodsType type)
type - The type of goods for which to pay arrears.public void purchaseUnitFromEurope(UnitType unitType)
unitType - The type of unit to be purchased.public org.w3c.dom.Element getForeignAffairsReport()
public org.w3c.dom.Element getHighScores()
public java.util.List<AbstractUnit> getREFUnits()
List valuepublic void disbandActiveUnit()
public void centerActiveUnit()
public void centerOnUnit(Unit unit)
public void executeGotoOrders()
public void nextActiveUnit()
public void nextActiveUnit(Tile tile)
ModelMessages
(uses nextModelMessage()).
tile - The tile to select if no new unit can be made active.
public void ignoreMessage(ModelMessage message,
boolean flag)
message - a ModelMessage valueflag - whether to ignore the ModelMessage or notpublic void nextModelMessage()
ModelMessage.
ModelMessagepublic void displayModelMessages(boolean allMessages)
private java.lang.Integer getTurnForMessageIgnored(java.lang.String key)
private void startIgnoringMessage(java.lang.String key,
int turn)
private void stopIgnoringMessage(java.lang.String key)
private void purgeOldMessagesFromMessagesToIgnore(int thisTurn)
private boolean shouldAllowMessage(ModelMessage message)
message - the message that is candidate for delivery to the canvas
public void endTurn()
protected org.w3c.dom.Element getChildElement(org.w3c.dom.Element element,
java.lang.String tagName)
element - The Element to search for the child
element.tagName - The tag name of the child element to be found.
Element with the given
tagName or null if no such child
exists.public void abandonColony(Colony colony)
colony - The colony to be abandonedpublic StatisticsMessage getServerStatistics()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||