Class ShipyardState
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.city.impl.ShipyardState
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<IShipDueDate,java.util.Optional<TimedTask>>
buildList
private int
buildTimeCog
private int
buildTimeCrayer
private int
buildTimeHolk
private int
buildTimeSnaikka
private ICity
city
private Date
date
private double
experience
Value between 0 and 1 detailing the experience of the ship yard crew (the higher the better)private static org.slf4j.Logger
LOGGER
private IMap
map
private DependentPropertyInitializer
propertyInitializer
private java.util.Map<IShipDueDate,java.util.Optional<TimedTask>>
refitList
private java.util.Map<IShipDueDate,java.util.Optional<TimedTask>>
repairList
private int
repairTimeCog
private int
repairTimeCrayer
private int
repairTimeHolk
private int
repairTimeSnaikka
private java.util.Random
rnd
private ShipyardProperties
shipyardProperties
private TimedUpdatableTaskList
taskList
-
Constructor Summary
Constructors Constructor Description ShipyardState(ICity city)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addShipBuildingOrder(IShipDueDate dueDate, java.util.Optional<TimedTask> task)
Add an order for building a new ship to the list.void
addShipRefitOrder(IShipDueDate dueDate, java.util.Optional<TimedTask> task)
Add an order for refitting a ship to the list.void
addShipRepairOrder(IShipDueDate dueDate, java.util.Optional<TimedTask> task)
Add an order for repairing a ship to the list.int
calculateBuildTime(EShipType type)
Calculate the build time for the ship of type.int
calculateConstructionCosts(EShipType type)
Calculate the labor costs for building a new ship of the indicated type.int
calculateRefitCosts(EShipType type, int levels)
Calculate the labor costs for the refit based on the ship type and how many levels should be upgraded.int
calculateRefitTime(EShipType type)
Calculate the time in days it takes for refitting.int
calculateRepairCosts(int repairTime, int materialCosts)
Calculate the repair costs.int
calculateRepairMaterialCosts(IShip ship, int damage)
Calculate the material costs for the repair.int
calculateRepairTime(EShipType type)
Calculate the repair time for the ship of type.private int
calculateSaleryPerDay()
Salery is defined by the experiancevoid
cancelRepair(IShip ship)
Cancel the repair of the ship.void
cancelShipBuildingOrder(java.time.LocalDateTime finish)
Cancel the order of the building, finished on the given date.private int
getBaseRepairTime(EShipType type)
EShipType[]
getBuildableShipTypes()
Retrieve a list of all the types of ships this yard can build.java.time.LocalDateTime
getBuildCompleteDate(EShipType type)
Retrieve the date when the building of a new ship will be finished.java.util.List<IShipDueDate>
getShipBuildingList()
Retrieve an immutable list of the ships that are ordered to be built on this shipyard.java.util.List<IShipDueDate>
getShipRepairList()
Retrieve the list of all ships that are to be repaired.private double
getShipSize(IShip ship)
java.util.List<IShipDueDate>
getShipUpgradeList()
Retrieve the list of all ships that are to be upgraded.void
initializeExperience()
void
removeCompletedConstruction(IShip ship)
Remove the build entry once it is completed.void
removeCompletedRepair(IShip ship)
Remove the repair entry once it is completed.void
removeCompletedUpgrade(IShip ship)
Remove the upgrade entry once it is completed.private void
removeEntry(IShip ship, java.util.Map<IShipDueDate,java.util.Optional<TimedTask>> list)
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
buildTimeSnaikka
@DependentValue("shipyard.build.time.snaikka") private int buildTimeSnaikka
-
buildTimeCrayer
@DependentValue("shipyard.build.time.crayer") private int buildTimeCrayer
-
buildTimeCog
@DependentValue("shipyard.build.time.cog") private int buildTimeCog
-
buildTimeHolk
@DependentValue("shipyard.build.time.holk") private int buildTimeHolk
-
repairTimeSnaikka
@DependentValue("shipyard.repair.time.snaikka") private int repairTimeSnaikka
-
repairTimeCrayer
@DependentValue("shipyard.repair.time.crayer") private int repairTimeCrayer
-
repairTimeCog
@DependentValue("shipyard.repair.time.cog") private int repairTimeCog
-
repairTimeHolk
@DependentValue("shipyard.repair.time.holk") private int repairTimeHolk
-
repairList
private final java.util.Map<IShipDueDate,java.util.Optional<TimedTask>> repairList
-
buildList
private final java.util.Map<IShipDueDate,java.util.Optional<TimedTask>> buildList
-
refitList
private final java.util.Map<IShipDueDate,java.util.Optional<TimedTask>> refitList
-
experience
private double experience
Value between 0 and 1 detailing the experience of the ship yard crew (the higher the better)
-
date
@Autowired private Date date
-
rnd
@Autowired private java.util.Random rnd
-
city
private final ICity city
-
taskList
@Autowired private TimedUpdatableTaskList taskList
-
map
@Autowired private IMap map
-
propertyInitializer
@Autowired private DependentPropertyInitializer propertyInitializer
-
shipyardProperties
@Autowired private ShipyardProperties shipyardProperties
-
-
Constructor Detail
-
ShipyardState
public ShipyardState(ICity city)
-
-
Method Detail
-
initializeExperience
@PostConstruct public void initializeExperience()
-
getShipBuildingList
public java.util.List<IShipDueDate> getShipBuildingList()
Description copied from interface:IShipyard
Retrieve an immutable list of the ships that are ordered to be built on this shipyard.- Specified by:
getShipBuildingList
in interfaceIShipyard
- Returns:
- immutable list of ship due dates.
-
getShipUpgradeList
public java.util.List<IShipDueDate> getShipUpgradeList()
Description copied from interface:IShipyard
Retrieve the list of all ships that are to be upgraded.- Specified by:
getShipUpgradeList
in interfaceIShipyard
- Returns:
- immutable list of all the upgrading ships
-
addShipBuildingOrder
public void addShipBuildingOrder(IShipDueDate dueDate, java.util.Optional<TimedTask> task)
Description copied from interface:IShipyard
Add an order for building a new ship to the list.- Specified by:
addShipBuildingOrder
in interfaceIShipyard
- Parameters:
dueDate
- when the ship is finished buildingtask
- that is executed on completion.
-
cancelShipBuildingOrder
public void cancelShipBuildingOrder(java.time.LocalDateTime finish)
Description copied from interface:IShipyard
Cancel the order of the building, finished on the given date.- Specified by:
cancelShipBuildingOrder
in interfaceIShipyard
- Parameters:
finish
- date
-
getShipRepairList
public java.util.List<IShipDueDate> getShipRepairList()
Description copied from interface:IShipyard
Retrieve the list of all ships that are to be repaired.- Specified by:
getShipRepairList
in interfaceIShipyard
- Returns:
- immutable list of all the repairing ships
-
addShipRepairOrder
public void addShipRepairOrder(IShipDueDate dueDate, java.util.Optional<TimedTask> task)
Description copied from interface:IShipyard
Add an order for repairing a ship to the list.- Specified by:
addShipRepairOrder
in interfaceIShipyard
- Parameters:
dueDate
- when the ship is finished repairingtask
- that is executed on completion.
-
calculateRepairMaterialCosts
public int calculateRepairMaterialCosts(IShip ship, int damage)
Description copied from interface:IShipyard
Calculate the material costs for the repair.- Specified by:
calculateRepairMaterialCosts
in interfaceIShipyard
- Parameters:
ship
- for which to calculate the material costs.damage
- of the ship- Returns:
- total material costs.
-
getShipSize
private double getShipSize(IShip ship)
-
calculateRepairCosts
public int calculateRepairCosts(int repairTime, int materialCosts)
Description copied from interface:IShipyard
Calculate the repair costs.- Specified by:
calculateRepairCosts
in interfaceIShipyard
- Parameters:
repairTime
- number of days it takes for the repairmaterialCosts
- costs of material that are required to be bought- Returns:
- total cost of the repair.
-
calculateSaleryPerDay
private int calculateSaleryPerDay()
Salery is defined by the experiance- Returns:
- salery per day.
-
cancelRepair
public void cancelRepair(IShip ship)
Description copied from interface:IShipyard
Cancel the repair of the ship. No damage will be repaired- Specified by:
cancelRepair
in interfaceIShipyard
- Parameters:
ship
- which's repair order is to be canceled
-
addShipRefitOrder
public void addShipRefitOrder(IShipDueDate dueDate, java.util.Optional<TimedTask> task)
Description copied from interface:IShipyard
Add an order for refitting a ship to the list.- Specified by:
addShipRefitOrder
in interfaceIShipyard
- Parameters:
dueDate
- when the ship is refittedtask
- that is executed on completion.
-
calculateRefitTime
public int calculateRefitTime(EShipType type)
Description copied from interface:IShipyard
Calculate the time in days it takes for refitting.- Specified by:
calculateRefitTime
in interfaceIShipyard
- Parameters:
type
- destination level- Returns:
- time in days.
-
getBuildCompleteDate
public java.time.LocalDateTime getBuildCompleteDate(EShipType type)
Description copied from interface:IShipyard
Retrieve the date when the building of a new ship will be finished.- Specified by:
getBuildCompleteDate
in interfaceIShipyard
- Parameters:
type
- of the ship to be built- Returns:
- end date of the building
-
calculateBuildTime
public int calculateBuildTime(EShipType type)
Description copied from interface:IShipyard
Calculate the build time for the ship of type.- Specified by:
calculateBuildTime
in interfaceIShipyard
- Parameters:
type
- ship type- Returns:
- total build time for a ship of type
type
-
calculateRepairTime
public int calculateRepairTime(EShipType type)
Description copied from interface:IShipyard
Calculate the repair time for the ship of type.- Specified by:
calculateRepairTime
in interfaceIShipyard
- Parameters:
type
- ship type- Returns:
- total repair time for a ship of type
type
-
getBaseRepairTime
private int getBaseRepairTime(EShipType type)
-
calculateRefitCosts
public int calculateRefitCosts(EShipType type, int levels)
Description copied from interface:IShipyard
Calculate the labor costs for the refit based on the ship type and how many levels should be upgraded.- Specified by:
calculateRefitCosts
in interfaceIShipyard
- Parameters:
type
- ship type that should be upgradedlevels
- number of upgrade levels- Returns:
- total work costs for the refit.
-
calculateConstructionCosts
public int calculateConstructionCosts(EShipType type)
Description copied from interface:IShipyard
Calculate the labor costs for building a new ship of the indicated type.- Specified by:
calculateConstructionCosts
in interfaceIShipyard
- Parameters:
type
- of the ship- Returns:
- costs.
-
getBuildableShipTypes
public EShipType[] getBuildableShipTypes()
Description copied from interface:IShipyard
Retrieve a list of all the types of ships this yard can build.- Specified by:
getBuildableShipTypes
in interfaceIShipyard
- Returns:
- array of ship types that can be constructed.
-
removeCompletedRepair
public void removeCompletedRepair(IShip ship)
Description copied from interface:IShipyard
Remove the repair entry once it is completed.- Specified by:
removeCompletedRepair
in interfaceIShipyard
- Parameters:
ship
- that is to be repaired.
-
removeEntry
private void removeEntry(IShip ship, java.util.Map<IShipDueDate,java.util.Optional<TimedTask>> list)
-
removeCompletedConstruction
public void removeCompletedConstruction(IShip ship)
Description copied from interface:IShipyard
Remove the build entry once it is completed.- Specified by:
removeCompletedConstruction
in interfaceIShipyard
- Parameters:
ship
- that is to be built.
-
removeCompletedUpgrade
public void removeCompletedUpgrade(IShip ship)
Description copied from interface:IShipyard
Remove the upgrade entry once it is completed.- Specified by:
removeCompletedUpgrade
in interfaceIShipyard
- Parameters:
ship
- that is to be upgraded.
-
-