|
|||||||||
| 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.common.model.FreeColGameObjectType
net.sf.freecol.common.model.Limit
public final class Limit
The Limit class encapsulates a limit on the
availability of FreeColObjects. It consists of a left hand side, an
operator and a right hand side, and can be used to limit the number
of units of a particular type (e.g. wagon trains) to the number of
a player's colonies, for example. The left hand side must apply to
the object on which a limit is to be placed.
| Nested Class Summary | |
|---|---|
static class |
Limit.Operator
|
| Field Summary | |
|---|---|
private Operand |
leftHandSide
Describe leftHandSide here. |
private Limit.Operator |
operator
Describe operator here. |
private Operand |
rightHandSide
Describe rightHandSide here. |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, logger, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG |
| Constructor Summary | |
|---|---|
Limit(Specification specification)
|
|
Limit(java.lang.String id,
Operand lhs,
Limit.Operator op,
Operand rhs)
|
|
| Method Summary | |
|---|---|
boolean |
appliesTo(FreeColObject object)
|
boolean |
evaluate(Game game)
Describe evaluate method here. |
private boolean |
evaluate(java.lang.Integer lhs,
java.lang.Integer rhs)
|
boolean |
evaluate(Player player)
Describe evaluate method here. |
boolean |
evaluate(Settlement settlement)
Describe evaluate method here. |
Operand |
getLeftHandSide()
Get the LeftHandSide value. |
Limit.Operator |
getOperator()
Get the Operator value. |
Operand |
getRightHandSide()
Get the RightHandSide value. |
static java.lang.String |
getXMLElementTagName()
Returns the XML tag name for this element. |
boolean |
hasOperandType(Operand.OperandType type)
Returns true if at least one of the Operands has the given OperandType. |
protected void |
readAttributes(javax.xml.stream.XMLStreamReader in)
Reads the attributes of this object from an XML stream. |
protected void |
readChild(javax.xml.stream.XMLStreamReader in)
Reads a child object. |
void |
setLeftHandSide(Operand newLeftHandSide)
Set the LeftHandSide value. |
void |
setOperator(Limit.Operator newOperator)
Set the Operator value. |
void |
setRightHandSide(Operand newRightHandSide)
Set the RightHandSide value. |
java.lang.String |
toString()
Use only for debugging purposes! A human-readable and localized name is returned by getName(). |
void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
This method writes an XML-representation of this object to the given stream. |
protected void |
writeAttributes(javax.xml.stream.XMLStreamWriter out)
Write the attributes of this object to a stream. |
protected void |
writeChildren(javax.xml.stream.XMLStreamWriter out)
Write the children of this object to a stream. |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObjectType |
|---|
addAbility, addModifier, applyDifficultyLevel, getDescriptionKey, getFeatureContainer, getIndex, getModifierIndex, getModifierIndex, getModifierSet, getNameKey, hasAbility, hasAbility, isAbstractType, readChildren, setAbstractType, setFeatureContainer, setIndex, setModifierIndex, toXMLImpl |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private Limit.Operator operator
private Operand leftHandSide
private Operand rightHandSide
| Constructor Detail |
|---|
public Limit(Specification specification)
public Limit(java.lang.String id,
Operand lhs,
Limit.Operator op,
Operand rhs)
| Method Detail |
|---|
public Limit.Operator getOperator()
Operator value.
Operator valuepublic void setOperator(Limit.Operator newOperator)
Operator value.
newOperator - The new Operator value.public Operand getLeftHandSide()
LeftHandSide value.
Operand valuepublic void setLeftHandSide(Operand newLeftHandSide)
LeftHandSide value.
newLeftHandSide - The new LeftHandSide value.public Operand getRightHandSide()
RightHandSide value.
Operand valuepublic void setRightHandSide(Operand newRightHandSide)
RightHandSide value.
newRightHandSide - The new RightHandSide value.public boolean appliesTo(FreeColObject object)
public boolean evaluate(Game game)
evaluate method here.
game - a Game value
boolean valuepublic boolean evaluate(Player player)
evaluate method here.
player - a Player value
boolean valuepublic boolean evaluate(Settlement settlement)
evaluate method here.
settlement - a Settlement value
boolean valuepublic boolean hasOperandType(Operand.OperandType type)
type - an OperandType value
boolean value
private boolean evaluate(java.lang.Integer lhs,
java.lang.Integer rhs)
public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class FreeColGameObjectTypeout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
writeAttributes in class FreeColObjectout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing to
the stream.
protected void writeChildren(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
writeChildren in class FreeColGameObjectTypeout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing to
the stream.
protected void readAttributes(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readAttributes in class FreeColGameObjectTypein - The XML input stream.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
protected void readChild(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readChild in class FreeColGameObjectTypein - The XML stream to read.
javax.xml.stream.XMLStreamException - if an error occurspublic java.lang.String toString()
FreeColGameObjectType
toString in class FreeColGameObjectTypepublic static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||