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.Loggerlogger-
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 voidcsActivateSentries(Tile tile, ChangeSet cs)Activate sentried units on a tile.voidcsCheckDiscoverRegion(Tile tile, ChangeSet cs)Check for a new region.voidcsEmbark(Unit carrier, ChangeSet cs)Embark a unit.private booleancsExploreLostCityRumour(java.util.Random random, ChangeSet cs)Explore a lost city.private voidcsImproveTile(java.util.Random random, ChangeSet cs)Completes a tile improvement.voidcsMove(Tile newTile, java.util.Random random, ChangeSet cs)Move a unit.private voidcsNativeBurialGround(ChangeSet cs)Explores a lost city, finding a native burial ground.voidcsNewContactCheck(Tile newTile, boolean firstLanding, ChangeSet cs)Check for new contacts at a tile.voidcsNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)New turn for this unit.voidcsRemove(ChangeSet.See see, Location loc, ChangeSet cs)Remove this unit from the game.voidcsRepairUnit(ChangeSet cs)Repair a unit.voidcsVisit(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 UnitgetSlowedBy(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- TheGamein 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- TheGamein which this unit belongs.location- TheLocationto place this at.owner- ThePlayerowning 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- TheGamein which this unit belongs.location- TheLocationto place this at.template- AUnitto 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- TheGamein which this unit belongs.location- TheLocationto place this at.owner- ThePlayerowning 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- AChangeSetto update.
-
csEmbark
public void csEmbark(Unit carrier, ChangeSet cs)
Embark a unit.- Parameters:
carrier- TheUnitto embark on.cs- AChangeSetto update.
-
csRepairUnit
public void csRepairUnit(ChangeSet cs)
Repair a unit.- Parameters:
cs- AChangeSetto 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- TheTilethe 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- AChangeSetto 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- AChangeSetto 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- TheTileto check.firstLanding- True if this is the special "first landing"cs- AChangeSetto update.
-
csActivateSentries
private void csActivateSentries(Tile tile, ChangeSet cs)
Activate sentried units on a tile.- Parameters:
tile- TheTileto activate sentries on.cs- AChangeSetto update.
-
csMove
public void csMove(Tile newTile, java.util.Random random, ChangeSet cs)
Move a unit.- Parameters:
newTile- TheTileto move to.random- A pseudo-random number source.cs- AChangeSetto update.
-
csCheckDiscoverRegion
public void csCheckDiscoverRegion(Tile tile, ChangeSet cs)
Check for a new region.- Parameters:
tile- TheTileto check at.cs- AChangeSetto 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- TheServerPlayerthat is contacting the settlement.is- TheIndianSettlementto 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- AChangeSetto 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- TheLocationof the change.cs- AChangeSetto update.
-
csNewTurn
public void csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)New turn for this unit.
-
-