|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.server.ai.AIObject
net.sf.freecol.server.ai.AIPlayer
net.sf.freecol.server.ai.StandardAIPlayer
public class StandardAIPlayer
Objects of this class contains AI-information for a single Player
and
is used for controlling this player.
The method startWorking()
gets called by the
AIInGameInputHandler
when it is this player's turn.
Field Summary |
---|
Fields inherited from class net.sf.freecol.common.model.FreeColObject |
---|
ID_ATTRIBUTE_TAG |
Constructor Summary | |
---|---|
StandardAIPlayer(AIMain aiMain,
org.w3c.dom.Element element)
Creates a new AIPlayer and reads the information from the
given Element . |
|
StandardAIPlayer(AIMain aiMain,
ServerPlayer player)
Creates a new AIPlayer . |
|
StandardAIPlayer(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
Creates a new AIPlayer . |
Method Summary | |
---|---|
boolean |
acceptDiplomaticTrade(DiplomaticTrade agreement)
|
boolean |
acceptIndianDemand(Unit unit,
Colony colony,
Goods goods,
int gold)
Decides whether to accept an Indian demand, or not. |
boolean |
acceptMercenaryOffer()
Decides whether to accept a mercenary offer, or not. |
boolean |
acceptTax(int tax)
Decides whether to accept the monarch's tax raise or not. |
int |
buyProposition(Unit unit,
Goods goods,
int gold)
Called when another Player proposes a trade. |
java.util.Iterator<TileImprovementPlan> |
getTileImprovementPlanIterator()
Returns an Iterator over all the
TileImprovement s needed by all of this player's colonies. |
java.util.Iterator<Wish> |
getWishIterator()
Returns an Iterator for all the wishes. |
static java.lang.String |
getXMLElementTagName()
Returns the tag name of the root element representing this object. |
boolean |
hasFewColonies()
This is a temporary method which are used for forcing the computer players into building more colonies. |
void |
registerSellGoods(Goods goods)
Called after another Player sends a trade message |
void |
removeTileImprovementPlan(TileImprovementPlan plan)
Remove a TileImprovementPlan from the list |
FoundingFather |
selectFoundingFather(java.util.List<FoundingFather> foundingFathers)
Selects the most useful founding father offered. |
void |
startWorking()
Tells this AIPlayer to make decisions. |
int |
tradeProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Called when another Player proposes a trade. |
Methods inherited from class net.sf.freecol.server.ai.AIPlayer |
---|
getConnection, getId, getPlayer, recruitAIUnitInEurope, setDebuggingConnection, trainAIUnitInEurope |
Methods inherited from class net.sf.freecol.server.ai.AIObject |
---|
dispose, getAIMain, getGame, isUninitialized, readFromXML |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StandardAIPlayer(AIMain aiMain, ServerPlayer player)
AIPlayer
.
aiMain
- The main AI-class.player
- The player that should be associated with this
AIPlayer
.public StandardAIPlayer(AIMain aiMain, org.w3c.dom.Element element)
AIPlayer
and reads the information from the
given Element
.
aiMain
- The main AI-class.element
- The XML-element containing information.public StandardAIPlayer(AIMain aiMain, javax.xml.stream.XMLStreamReader in) throws javax.xml.stream.XMLStreamException
AIPlayer
.
aiMain
- The main AI-object.in
- The input stream containing the XML.
javax.xml.stream.XMLStreamException
- if a problem was encountered during parsing.Method Detail |
---|
public void startWorking()
AIPlayer
to make decisions. The
AIPlayer
is done doing work this turn when this method
returns.
startWorking
in class AIPlayer
public java.util.Iterator<TileImprovementPlan> getTileImprovementPlanIterator()
Iterator
over all the
TileImprovement
s needed by all of this player's colonies.
getTileImprovementPlanIterator
in class AIPlayer
Iterator
.TileImprovement
public void removeTileImprovementPlan(TileImprovementPlan plan)
TileImprovementPlan
from the list
removeTileImprovementPlan
in class AIPlayer
public boolean hasFewColonies()
hasFewColonies
in class AIPlayer
true
if the AI should build more colonies.public java.util.Iterator<Wish> getWishIterator()
Iterator
for all the wishes. The items are
sorted by the value
, with the item having the
highest value appearing first in the Iterator
.
getWishIterator
in class AIPlayer
Iterator
.Wish
public FoundingFather selectFoundingFather(java.util.List<FoundingFather> foundingFathers)
selectFoundingFather
in class AIPlayer
foundingFathers
- The founding fathers on offer.
public boolean acceptTax(int tax)
acceptTax
in class AIPlayer
tax
- The new tax rate to be considered.
true
if the tax raise should be accepted.public boolean acceptIndianDemand(Unit unit, Colony colony, Goods goods, int gold)
acceptIndianDemand
in class AIPlayer
unit
- The unit making demands.colony
- The colony where demands are being made.goods
- The goods demanded.gold
- The amount of gold demanded.
true
if this AIPlayer
accepts the
indian demand and false
otherwise.public boolean acceptMercenaryOffer()
acceptMercenaryOffer
in class AIPlayer
true
if this AIPlayer
accepts the
offer and false
otherwise.public boolean acceptDiplomaticTrade(DiplomaticTrade agreement)
acceptDiplomaticTrade
in class AIPlayer
public void registerSellGoods(Goods goods)
Player
sends a trade
message
registerSellGoods
in class AIPlayer
goods
- The goods which we are going to offerpublic int buyProposition(Unit unit, Goods goods, int gold)
Player
proposes a trade.
buyProposition
in class AIPlayer
unit
- The foreign Unit
trying to trade.goods
- The goods the given Unit
is trying to sell.gold
- The suggested price.
AIPlayer
suggests or
NetworkConstants.NO_TRADE
.public int tradeProposition(Unit unit, Settlement settlement, Goods goods, int gold)
Player
proposes a trade.
tradeProposition
in class AIPlayer
unit
- The foreign Unit
trying to trade.settlement
- The Settlement
this player owns and
which the given Unit
if trying to sell goods.goods
- The goods the given Unit
is trying to sell.gold
- The suggested price.
AIPlayer
suggests or
NetworkConstants.NO_TRADE
.public static java.lang.String getXMLElementTagName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |