Package net.sf.freecol.server.model
Class ServerEurope
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColGameObject
-
- net.sf.freecol.common.model.UnitLocation
-
- net.sf.freecol.common.model.Europe
-
- net.sf.freecol.server.model.ServerEurope
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,Location
,Named
,Ownable
,TradeLocation
,ObjectWithId
,TurnTaker
public class ServerEurope extends Europe implements TurnTaker
The server version of Europe.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.Europe
Europe.MigrationType
-
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.Europe
ABILITY_DRESS_MISSIONARY, baseRecruitPrice, recruitables, recruitLowerCap, TAG, UNIT_CHANGE, unitPrices
-
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.Location
LOCATION_RANK_EUROPE, LOCATION_RANK_HIGHSEAS, LOCATION_RANK_NOWHERE
-
-
Constructor Summary
Constructors Constructor Description ServerEurope(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.ServerEurope(Game game, Player owner)
Creates a new ServerEurope.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
csEquipForRole(Unit unit, Role role, int roleCount, java.util.Random random, ChangeSet cs)
Equip a unit for a specific role.void
csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this colony tile.boolean
equipForRole(Unit unit, Role role, int roleCount)
Equip a unit for a role using resources at this location.AbstractUnit
extractRecruitable(int slot, java.util.Random random)
Extract the recruitable at a given slot, and replace it with the given new recruitable type.private void
fillRecruitables(java.util.Random random)
Fill out to the full amount of recruits.java.util.List<Unit>
generateFountainRecruits(int n, java.util.Random random)
Generate new recruits following a Fountain of Youth discovery.private java.util.List<RandomChoice<UnitType>>
generateRecruitablesList()
Generate a weighted list of unit types recruitable by this player.void
increasePrice(UnitType unitType, int price)
Increases the price for a unit.void
increaseRecruitmentDifficulty()
Increases the base price and lower cap for recruits.void
initializeMigration(java.util.Random random)
Generates the initial recruits for this player.boolean
replaceRecruits(java.util.Random random)
Replace any non-recruitable recruits.-
Methods inherited from class net.sf.freecol.common.model.Europe
add, addRecruitable, addRecruitable, canAdd, canBeInput, copyIn, disposeResources, getAbilities, getAvailableGoodsCount, getBaseRecruitPrice, getClassIndex, getCurrentRecruitPrice, getExpandedRecruitables, getExportAmount, getFeatureContainer, getImmigration, getImportAmount, getLinkTarget, getLocationImageKey, getLocationLabel, getLocationName, getNameAsJlabel, getNameKey, getOwner, getRank, getRecruitables, getRecruitLowerCap, getUnitPrice, getUnitPrices, getXMLTagName, priceGoods, readAttributes, readChild, readChildren, setOwner, setUnitPrices, toShortString, toString, up, writeAttributes, writeChildren
-
Methods inherited from class net.sf.freecol.common.model.UnitLocation
clearUnitList, contains, getCarrierForUnit, getColony, getDisposables, getFirstUnit, getGoodsContainer, getIndianSettlement, getLastUnit, getLocationLabelFor, getNavalUnits, getNoAddReason, getSettlement, getSpaceTaken, getTile, getTotalUnitCount, getUnitCapacity, getUnitCount, getUnitList, getUnits, hasCarrierWithSpace, intern, isEmpty, isFull, moveToFront, remove
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
checkIntegrity, 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, getDisplayObject, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, 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
-
-
-
-
Constructor Detail
-
ServerEurope
public ServerEurope(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.- Parameters:
game
- TheGame
this object belongs to.id
- The object identifier.
-
-
Method Detail
-
equipForRole
public boolean equipForRole(Unit unit, Role role, int roleCount)
Equip a unit for a role using resources at this location.- Overrides:
equipForRole
in classEurope
- Parameters:
unit
- TheUnit
to equip.role
- TheRole
to build for.roleCount
- The role count.- Returns:
- True if the equipping succeeded.
-
initializeMigration
public void initializeMigration(java.util.Random random)
Generates the initial recruits for this player. Recruits may be determined by the difficulty level, or generated randomly.- Parameters:
random
- A pseudo-random number source.
-
fillRecruitables
private void fillRecruitables(java.util.Random random)
Fill out to the full amount of recruits.- Parameters:
random
- A pseudo-random number source.
-
increaseRecruitmentDifficulty
public void increaseRecruitmentDifficulty()
Increases the base price and lower cap for recruits.
-
extractRecruitable
public AbstractUnit extractRecruitable(int slot, java.util.Random random)
Extract the recruitable at a given slot, and replace it with the given new recruitable type. Note that we shift the old units down, because the AI always recruits from the lowest slot.- Parameters:
slot
- The slot to recruit with.random
- A pseudo-random number source.- Returns:
- The recruited
AbstractUnit
.
-
generateRecruitablesList
private java.util.List<RandomChoice<UnitType>> generateRecruitablesList()
Generate a weighted list of unit types recruitable by this player.- Returns:
- A weighted list of recruitable unit types.
-
replaceRecruits
public boolean replaceRecruits(java.util.Random random)
Replace any non-recruitable recruits.- Parameters:
random
- A pseudo-random number source.- Returns:
- True if any recruit was replaced.
-
generateFountainRecruits
public java.util.List<Unit> generateFountainRecruits(int n, java.util.Random random)
Generate new recruits following a Fountain of Youth discovery. FIXME: Get rid of this, it is only used because the AI is stupid.- Parameters:
n
- The number of new units.random
- A pseudo-random number source.- Returns:
- The generated units.
-
increasePrice
public void increasePrice(UnitType unitType, int price)
Increases the price for a unit.- Parameters:
unitType
- TheUnitType
, trained or purchasedprice
- The current price of the unit
-
csEquipForRole
public boolean csEquipForRole(Unit unit, Role role, int roleCount, java.util.Random random, ChangeSet cs)
Equip a unit for a specific role.- Parameters:
unit
- TheUnit
to equip.role
- TheRole
to equip for.roleCount
- The role count.random
- A pseudo-random number source.cs
- AChangeSet
to update.- Returns:
- True if the equipping succeeds.
-
csNewTurn
public void csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this colony tile. FIXME: give Europe a shipyard and remove this?
-
-