Package net.sf.freecol.server.model
Class ServerUnit
- java.lang.Object
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.Unit
Unit.MoveType, Unit.UnitLabelType, Unit.UnitState
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation
UnitLocation.NoAddReason
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
-
Fields inherited from class net.sf.freecol.common.model.Unit
attrition, CARGO_CHANGE, currentStop, decreasingSkillComparator, DEFAULT_UNIT_VALUE, destination, entryLocation, ethnicity, experience, experienceType, hitPoints, increasingSkillComparator, indianSettlement, location, locComparator, MANY_TURNS, MOVE_CHANGE, movesLeft, name, nationality, owner, role, ROLE_CHANGE, roleCount, sentryPred, state, student, TAG, teacher, tradeRoute, treasureAmount, turnsOfTraining, type, typeRoleComparator, visibleGoodsCount, workImprovement, workLeft, workType
-
Fields inherited from class net.sf.freecol.common.model.FreeColGameObject
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
Fields inherited from interface net.sf.freecol.common.model.Consumer
BUILDING_PRIORITY, COLONY_PRIORITY, COMPARATOR, POPULATION_PRIORITY, UNIT_PRIORITY
-
Fields inherited from interface net.sf.freecol.common.model.Location
LOCATION_RANK_EUROPE, LOCATION_RANK_HIGHSEAS, LOCATION_RANK_NOWHERE
-
-
Constructor Summary
Constructors Constructor Description ServerUnit(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.ServerUnit(Game game, Location location, Player owner, UnitType type)
Creates a new ServerUnit.ServerUnit(Game game, Location location, Player owner, UnitType type, Role role)
Creates a new ServerUnit.ServerUnit(Game game, Location location, Unit template)
Create a new ServerUnit from a template.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
csActivateSentries(Tile tile, ChangeSet cs)
Activate sentried units on a tile.void
csCheckDiscoverRegion(Tile tile, ChangeSet cs)
Check for a new region.void
csEmbark(Unit carrier, ChangeSet cs)
Embark a unit.private boolean
csExploreLostCityRumour(java.util.Random random, ChangeSet cs)
Explore a lost city.private void
csImproveTile(java.util.Random random, ChangeSet cs)
Completes a tile improvement.void
csMove(Tile newTile, java.util.Random random, ChangeSet cs)
Move a unit.private void
csNativeBurialGround(ChangeSet cs)
Explores a lost city, finding a native burial ground.void
csNewContactCheck(Tile newTile, boolean firstLanding, ChangeSet cs)
Check for new contacts at a tile.void
csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this unit.void
csRemove(ChangeSet.See see, Location loc, ChangeSet cs)
Remove this unit from the game.void
csRepairUnit(ChangeSet cs)
Repair a unit.void
csVisit(ServerPlayer serverPlayer, IndianSettlement is, int scout, ChangeSet cs)
Visits a native settlement, possibly scouting it fully if as a result of a scout actually asking to speak to the chief, or for other settlement-contacting events such as missionary actions, demanding tribute, learning skills and trading if the settlementActionsContactChief game option is enabled.private Unit
getSlowedBy(Tile newTile, java.util.Random random)
If a unit moves, check if an opposing naval unit slows it down.-
Methods inherited from class net.sf.freecol.common.model.Unit
add, addFeature, atStop, betterDefender, canAmbush, canAttack, canBeStudent, canBuildColony, canCaptureEquipment, canCaptureGoods, canCarryGoods, canCarryTreasure, canCarryUnits, canCashInTreasureTrain, canCashInTreasureTrain, canMoveToHighSeas, changeExperienceType, changeHomeIndianSettlement, changeOwner, changeRole, changeRoleCount, changeType, changeWorkType, checkIntegrity, checkSetState, copyIn, couldCarry, couldCarry, couldMove, damageShip, disposeResources, evaluateFor, findIntermediatePort, findOurNearestOtherSettlement, findOurNearestPort, findOurNearestSettlement, findOurNearestSettlement, findOurNearestSettlement, findPath, findPath, findPath, findPath, findPathToNeighbour, followingTradeRoute, getAbilities, getAdjacentSettlement, getApparentOwnerName, getAttrition, getAutomaticRole, getAvailableRoles, getAvailableRolesList, getBestEntryTile, getBurnProbability, getCargoCapacity, getCargoSpaceTaken, getCarriedUnitById, getCarrier, getClassIndex, getClosestColony, getClosestColony, getCombatLabel, getCombatModifiers, getCompactGoodsList, getConsumedGoods, getConsumptionModifiers, getConvertProbability, getCurrentStop, getCurrentStops, getDescription, getDescription, getDestination, getDestinationLabel, getDisplayObject, getEntryLocation, getEthnicity, getExperience, getExperienceType, getFullEntryLocation, getGoodsCapacity, getGoodsDifference, getGoodsList, getGoodsSpaceTaken, getHitPoints, getHomeIndianSettlement, getInitialMovesLeft, getLabel, getLabel, getLineOfSight, getLinkTarget, getLoadableAmount, getLocation, getLocationLabel, getMilitaryRole, getMissionaryTradeModifiers, getModifiers, getMoveCost, getMoveCost, getMovesAsString, getMovesLeft, getMoveType, getMoveType, getMoveType, getName, getNationality, getNeededTurnsOfTraining, getNeighbourTile, getNoAddReason, getOccupationLabel, getOwner, getPathStartLocation, getPioneerScore, getPriority, getProductionInfo, getRank, getRepairLabel, getRepairLocation, getRole, getRoleCount, getRoleSuffix, getSailTurns, getScoreValue, getScoutScore, getSettlement, getSimpleMoveType, getSimpleMoveType, getSimpleMoveType, getSkillLevel, getSpaceLeft, getSpaceTaken, getState, getStop, getStudent, getTeacher, getTeachingType, getTeachingType, getTile, getTradeLocation, getTradeRoute, getTransportFee, getTreasureAmount, getTrivialPath, getTurnsForRepair, getTurnsOfTraining, getTurnsToReach, getTurnsToReach, getTurnsToReach, getType, getUnitChange, getUnitChange, getUnitChange, getUnitDestinationLabel, getUnitSkillLevel, getUnitSpaceTaken, getVisibleGoodsCount, getVisibleTileSet, getWorkImprovement, getWorkLeft, getWorkLocation, getWorkTile, getWorkTurnsLeft, getWorkType, getXMLTagName, goingToDestination, hasCargo, hasDefaultRole, hasGoodsCargo, hasNativeEthnicity, hasSpaceLeft, hasTile, invalidateCache, isArmed, isAtLocation, isAtSea, isBeached, isBeached, isCarrier, isColonist, isDamaged, isDefensiveUnit, isInColony, isInDanger, isInEurope, isInMission, isMounted, isNaval, isOffensiveUnit, isOnCarrier, isOnTile, isOwnerHidden, isPerson, isReadyToTrade, isTileAccessible, isTradingUnit, isUndead, losingEquipmentDemotesUnit, losingEquipmentKillsUnit, modifyExperience, readAttributes, readChild, readChildren, reduceVisibility, remove, resolveDestination, roleIsAvailable, search, searchForDanger, setAttrition, setCurrentStop, setDestination, setEntryLocation, setEthnicity, setExperience, setHitPoints, setHomeIndianSettlement, setLocation, setLocationNoUpdate, setMovesLeft, setName, setNationality, setOwner, setRole, setRoleCount, setState, setStateToAllChildren, setStateUnchecked, setStudent, setTeacher, setTradeRoute, setTreasureAmount, setTurnsOfTraining, setType, setWorkImprovement, setWorkLeft, setWorkType, shouldTakeTransportTo, swapWork, toShortString, toString, toString, trySwapExpert, up, writeAttributes, writeChildren
-
Methods inherited from class net.sf.freecol.common.model.GoodsLocation
addGoods, addGoods, addGoods, contains, containsGoods, getDisposables, getGoodsContainer, getGoodsCount, moveGoods, removeAll, removeGoods, removeGoods, removeGoods, setGoodsContainer
-
Methods inherited from class net.sf.freecol.common.model.UnitLocation
canAdd, clearUnitList, equipForRole, getCarrierForUnit, getColony, getFirstUnit, getIndianSettlement, getLastUnit, getLocationLabelFor, getNavalUnits, getTotalUnitCount, getUnitCapacity, getUnitCount, getUnitList, getUnits, hasCarrierWithSpace, intern, isEmpty, isFull, moveToFront, priceGoods
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
dispose, equals, fundamentalDispose, getGame, getSpecification, hashCode, internId, isDisposed, isInitialized, isInternable, readFromXML, setGame, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getDefenceModifiers, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toXML, toXML, toXMLPartial, toXMLPartial
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.freecol.common.model.Location
getId, getLocationImageKey
-
-
-
-
Constructor Detail
-
ServerUnit
public ServerUnit(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.- Parameters:
game
- TheGame
in which this unit belongs.id
- The object identifier.
-
ServerUnit
public ServerUnit(Game game, Location location, Player owner, UnitType type)
Creates a new ServerUnit. -vis: Visibility issues depending on location. -til: Changes appearance if unit goes into a colony.- Parameters:
game
- TheGame
in which this unit belongs.location
- TheLocation
to place this at.owner
- ThePlayer
owning this unit.type
- The type of the unit.
-
ServerUnit
public ServerUnit(Game game, Location location, Unit template)
Create a new ServerUnit from a template. Note all FCGOTs are looked up in the specification by id, allowing the template to derive from a different specification as might happen when loading a scenario map. -vis: Visibility issues depending on location. -til: Changes appearance if unit goes into a colony.- Parameters:
game
- TheGame
in which this unit belongs.location
- TheLocation
to place this at.template
- AUnit
to copy from.
-
ServerUnit
public ServerUnit(Game game, Location location, Player owner, UnitType type, Role role)
Creates a new ServerUnit. -vis: Visibility issues depending on location. -til: Changes appearance if unit goes into a colony.- Parameters:
game
- TheGame
in which this unit belongs.location
- TheLocation
to place this at.owner
- ThePlayer
owning this unit.type
- The type of the unit.role
- The role of the unit.
-
-
Method Detail
-
csImproveTile
private void csImproveTile(java.util.Random random, ChangeSet cs)
Completes a tile improvement. +til: Resolves the change of appearance.- Parameters:
random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csEmbark
public void csEmbark(Unit carrier, ChangeSet cs)
Embark a unit.- Parameters:
carrier
- TheUnit
to embark on.cs
- AChangeSet
to update.
-
csRepairUnit
public void csRepairUnit(ChangeSet cs)
Repair a unit.- Parameters:
cs
- AChangeSet
to update.
-
getSlowedBy
private Unit getSlowedBy(Tile newTile, java.util.Random random)
If a unit moves, check if an opposing naval unit slows it down. Note that the unit moves are reduced here.- Parameters:
newTile
- TheTile
the unit is moving to.random
- A pseudo-random number source.- Returns:
- Either an enemy unit that causes a slowdown, or null if none.
-
csNativeBurialGround
private void csNativeBurialGround(ChangeSet cs)
Explores a lost city, finding a native burial ground.- Parameters:
cs
- AChangeSet
to add changes to.
-
csExploreLostCityRumour
private boolean csExploreLostCityRumour(java.util.Random random, ChangeSet cs)
Explore a lost city.- Parameters:
random
- A pseudo-random number source.cs
- AChangeSet
to add changes to.- Returns:
- True if the unit survives.
-
csNewContactCheck
public void csNewContactCheck(Tile newTile, boolean firstLanding, ChangeSet cs)
Check for new contacts at a tile.- Parameters:
newTile
- TheTile
to check.firstLanding
- True if this is the special "first landing"cs
- AChangeSet
to update.
-
csActivateSentries
private void csActivateSentries(Tile tile, ChangeSet cs)
Activate sentried units on a tile.- Parameters:
tile
- TheTile
to activate sentries on.cs
- AChangeSet
to update.
-
csMove
public void csMove(Tile newTile, java.util.Random random, ChangeSet cs)
Move a unit.- Parameters:
newTile
- TheTile
to move to.random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csCheckDiscoverRegion
public void csCheckDiscoverRegion(Tile tile, ChangeSet cs)
Check for a new region.- Parameters:
tile
- TheTile
to check at.cs
- AChangeSet
to update.
-
csVisit
public void csVisit(ServerPlayer serverPlayer, IndianSettlement is, int scout, ChangeSet cs)
Visits a native settlement, possibly scouting it fully if as a result of a scout actually asking to speak to the chief, or for other settlement-contacting events such as missionary actions, demanding tribute, learning skills and trading if the settlementActionsContactChief game option is enabled. It is still unclear what Col1 did here.- Parameters:
serverPlayer
- TheServerPlayer
that is contacting the settlement.is
- TheIndianSettlement
to contact.scout
- Positive if this contact is due to a scout asking to speak to the chief, zero if it is another unit, negative if this is from the greeting dialog generation.cs
- AChangeSet
to update.
-
csRemove
public void csRemove(ChangeSet.See see, Location loc, ChangeSet cs)
Remove this unit from the game.- Parameters:
see
- The visibility of the change.loc
- TheLocation
of the change.cs
- AChangeSet
to update.
-
csNewTurn
public void csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this unit.
-
-