|
|||||||||
| 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.FreeColGameObject
net.sf.freecol.common.model.TileItem
net.sf.freecol.common.model.TileImprovement
public class TileImprovement
Represents a tile improvement, such as a river or road.
| Field Summary | |
|---|---|
static int |
FJORD_RIVER
|
static int |
LARGE_RIVER
|
private static java.util.logging.Logger |
logger
|
private int |
magnitude
Default is type.getMagnitude(), but this will override. |
static int |
NO_RIVER
River magnitudes |
static int |
SMALL_RIVER
|
private int |
style
To store the style of multi-image TileImprovements (eg. |
private int |
turnsToComplete
|
private TileImprovementType |
type
|
private boolean |
virtual
Whether this is a virtual improvement granted by some structure on the tile (a Colony, for example). |
| Fields inherited from class net.sf.freecol.common.model.TileItem |
|---|
RESOURCE_ZINDEX, RUMOUR_ZINDEX, tile |
| Fields inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
UNITS_TAG_NAME |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG |
| Constructor Summary | |
|---|---|
TileImprovement(Game game,
java.lang.String id)
Initiates a new TileImprovement with the given ID. |
|
TileImprovement(Game game,
Tile tile,
TileImprovementType type)
Creates a standard TileImprovement-instance. |
|
TileImprovement(Game game,
javax.xml.stream.XMLStreamReader in)
|
|
| Method Summary | |
|---|---|
void |
compileStyleBreakdown(int[] base,
int[] breakdown)
|
static int[] |
getBase(Map.Direction[] directions,
int baseNumber)
Returns an int[NUMBER_OF_DIRECTIONS] array based on the baseNumber and the 'active' directions given. |
int |
getBonus(GoodsType goodsType)
Returns the bonus (if any). |
TileType |
getChange(TileType tileType)
Returns any change of TileType |
int |
getExpendedAmount()
|
EquipmentType |
getExpendedEquipmentType()
|
int |
getMagnitude()
|
int |
getMovementCost(int moveCost,
Tile fromTile)
Performs reduction of the movement-cost. |
java.lang.String |
getNameKey()
Gets the name of this Named. |
Modifier |
getProductionModifier(GoodsType goodsType)
Returns the bonus Modifier (if any). |
int |
getStyle()
Returns the Style of this Improvement - used for Rivers |
int[] |
getStyleBreakdown(int[] base)
Breaks the Style of this Improvement into 8 directions - used for Rivers (at the moment) Possible TODO: Modify this later should we modify the usage of Style. |
int[] |
getStyleBreakdown(Map.Direction[] directions,
int baseNumber)
Breaks the Style of this Improvement into 8 directions - used for Rivers (at the moment) |
int |
getTurnsToComplete()
|
TileImprovementType |
getType()
|
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
int |
getZIndex()
Get the ZIndex value. |
boolean |
isComplete()
|
boolean |
isRiver()
Is this TileImprovement a river? |
boolean |
isRoad()
Is this TileImprovement a road? |
boolean |
isTileTypeAllowed(TileType tileType)
Returns true if the TileItem is compatible with the given . |
boolean |
isVirtual()
Get the Virtual value. |
boolean |
isWorkerAllowed(Unit unit)
Checks if a given worker can work at this Improvement |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
setMagnitude(int magnitude)
|
void |
setStyle(int style)
Sets the Style of this Improvement - used for Rivers |
void |
setTurnsToComplete(int turns)
Update the turns required to complete the improvement. |
void |
setVirtual(boolean newVirtual)
Set the Virtual value. |
java.lang.String |
toString()
Returns a textual representation of this object. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
This method writes an XML-representation of this object to the given stream. |
| Methods inherited from class net.sf.freecol.common.model.TileItem |
|---|
getLocation, getSpaceTaken, getTile, setLocation |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
dispose, disposeList, equals, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, getSpecification, hashCode, isDisposed, isUninitialized, newLocation, readFromXML, readFromXMLPartialByClass, setDefaultId, setGame, setId, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static java.util.logging.Logger logger
private TileImprovementType type
private int turnsToComplete
private int magnitude
public static final int NO_RIVER
public static final int SMALL_RIVER
public static final int LARGE_RIVER
public static final int FJORD_RIVER
private int style
Map,
Riverprivate boolean virtual
| Constructor Detail |
|---|
public TileImprovement(Game game,
Tile tile,
TileImprovementType type)
TileImprovement-instance.
This constructor asserts that the game, tile and type are valid.
game - The Game in which this object belongs.tile - The Tile on which this object sits.type - The TileImprovementType of this TileImprovement.
public TileImprovement(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public TileImprovement(Game game,
java.lang.String id)
TileImprovement with the given ID. The object
should later be initialized by calling either
FreeColGameObject.readFromXML(XMLStreamReader) or
FreeColObject.readFromXMLElement(Element).
game - The Game in which this object belong.id - The unique identifier for this object.| Method Detail |
|---|
public TileImprovementType getType()
public int getMagnitude()
public void setMagnitude(int magnitude)
public final boolean isVirtual()
Virtual value.
boolean valuepublic final void setVirtual(boolean newVirtual)
Virtual value.
newVirtual - The new Virtual value.public boolean isRoad()
TileImprovement a road?
boolean valuepublic boolean isRiver()
TileImprovement a river?
boolean valuepublic java.lang.String getNameKey()
NamedNamed.
getNameKey in interface NamedNamed.public java.lang.String toString()
toString in class FreeColGameObjectString of either:
public int getTurnsToComplete()
public void setTurnsToComplete(int turns)
turns - an int valuepublic final int getZIndex()
ZIndex value.
getZIndex in class TileItemint valuepublic boolean isComplete()
public EquipmentType getExpendedEquipmentType()
public int getExpendedAmount()
public int getBonus(GoodsType goodsType)
goodsType - a GoodsType value
int valuepublic Modifier getProductionModifier(GoodsType goodsType)
goodsType - a GoodsType value
Modifier value
public int getMovementCost(int moveCost,
Tile fromTile)
moveCost - Original movement cost
public TileType getChange(TileType tileType)
public int getStyle()
public void setStyle(int style)
style - The style
public static int[] getBase(Map.Direction[] directions,
int baseNumber)
directions - An int[] that gives the active directions eg
{Map.N, Map.NE, Map.E, Map.SE, Map.S, Map.SW, Map.W, Map.NW},
or {Map.E, Map.SW};baseNumber - The base to be used to create the base array.
public int[] getStyleBreakdown(Map.Direction[] directions,
int baseNumber)
directions - An int[] that gives the active directions
eg {Map.N, Map.NE, Map.E, Map.SE, Map.S, Map.SW, Map.W, Map.NW},
or {Map.E, Map.SW};baseNumber - The base to be used to create the base array.
public int[] getStyleBreakdown(int[] base)
base - Use getBase(net.sf.freecol.common.model.Map.Direction[], int)
public void compileStyleBreakdown(int[] base,
int[] breakdown)
public boolean isWorkerAllowed(Unit unit)
public boolean isTileTypeAllowed(TileType tileType)
isTileTypeAllowed in class TileItemtileType - a TileType value
boolean value
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
Player will be added
to that representation if showAll is set to
false.
toXMLImpl in class FreeColGameObjectout - The target stream.player - The Player this XML-representation should be
made for, or null if
showAll == true.showAll - Only attributes visible to player will be
added to the representation if showAll is set
to false.toSavedGame - If true then information that is only
needed when saving a game is added.
javax.xml.stream.XMLStreamException - if there are any problems writing to the
stream.
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.public static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||