Class Ship
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.ship.impl.Ship
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringnameName of the shipprotected EShipUpgradeshipUpgradeLevelState of the design standard level
-
Constructor Summary
Constructors Constructor Description Ship()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPassenger(IPerson passanger)Move a passenger to the ship.protected voidclearLoadedWares()Clear all loaded wares.voiddamage(int damage, boolean destroyWeapon)Damage the shipintgetCapacity()Available capacity of the ship, this represent the free storage in barrelsintgetCargoValue()Retrieve the value of the cargo.doublegetCurrentSpeed()Current top speed of the ship.intgetDamage()Retrieve the damage of the ship in percentage [0,100]intgetLoadableSpace()Retrieve the total amount of space that is available to store stuff.javafx.beans.binding.IntegerBindinggetLoadBinding()Retrieve the amount of load in barrels that is loaded in actual wares (no wappen or crew)java.util.Set<IWare>getLoadedWares()Retrieve a list of all loaded waresintgetMaxNumberOfSailors()Retrieve the maximum of sailors that can be put on the ship.intgetNumberOfSailors()Retrieve the number of sailors on the ship.intgetOccupiedSpaceByWeapons()Retrieve the amount of space used for the weapons.IShipOwnergetOwner()Retrieve the owner of the ship.booleangetPirateFlag()Indicate if the vessel has hissed the pirate flag (Jolly Roger) and the vessel therefore should be considered a pirate vessel.doublegetTopSpeed()Retrieve the speed of the vessel in kilometer per hourintgetUpgradeSpaceReduction()Retrieve the reduction of the load capacity based on the upgrade level.intgetValue()Retrieve the current value of the ship without its cargoAmountablePrice<IWare>getWare(IWare ware)Retrieve the amount of ware loadedintgetWeaponAmount(IWeapon weaponType)Retrieve the amount of weapons on the shipprotected voidinitializeProperties(ShipProperties.Ship shipConfiguration)booleanisUpgradable()Check if the ship can be upgradedvoidleavePassenger()Passenger leave ship.intload(IWare ware, int amount, int avgPrice)Load the ware in the specified amount onto the ship.javafx.beans.property.IntegerPropertynumberOfSailorsProperty()Retrieve the number of sailors as IntegerProperty.javafx.beans.property.ObjectProperty<IShip>parentShipProperty()Property holding the parent ship in case of a grouping (convoy or group).javafx.beans.binding.BooleanBindingpassengerPresentProperty()Binding indicating if a passenger is present.javafx.beans.property.BooleanPropertypirateFlagProperty()Property defining the pirate activit y of the vessel.voidrepair()Repair the damagevoidsetAutoTrading(IShipAutoTrading autoTrading)Set the ship auto trading.voidsetCaptain(ICaptain captain)Set the captain on the shipvoidsetNumberOfSailors(int nbSailors)Set the number of sailors.voidsetOwner(IShipOwner owner)Define the owner of the shipvoidsetTravelState(EShipTravelState state)Set the ships travel state.voidtogglePirateFlag()Hiss or lower the pirate flag (Jolly Roger).java.lang.StringtoString()javafx.beans.property.ObjectProperty<EShipTravelState>travelState()Traveling state of the ship.intunload(IWare ware, int amount)Unload the specified quantity of the ware.voidupdateHandweapon(int delta)Update the amount of handweapons on board.voidupgrade()Upgrade the ship if it is upgradable-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ch.sahits.game.openpatrician.model.ship.INavigableVessel
getAutotrading, getCaptian, getLocation, getMinNumberOfSailors, getName, getSize, getUuid, setLocation
-
Methods inherited from interface ch.sahits.game.openpatrician.model.ship.IShip
getDistanceInKmForOneHealthPointReduction, getOccupiedSpace, getPassenger, getShipType, getShipUpgradeLevel, getWeaponSlots, isAvailable, setAvailable, setName, setOccupiedSpace, setWeaponSlots
-
-
-
-
Field Detail
-
shipUpgradeLevel
protected EShipUpgrade shipUpgradeLevel
State of the design standard level
-
name
protected java.lang.String name
Name of the ship
-
-
Method Detail
-
initializeProperties
protected final void initializeProperties(ShipProperties.Ship shipConfiguration)
-
getMaxNumberOfSailors
public int getMaxNumberOfSailors()
Description copied from interface:IShipRetrieve the maximum of sailors that can be put on the ship. This amount depends on the ship type as well as the amount of load.- Specified by:
getMaxNumberOfSailorsin interfaceIShip- Returns:
- maximum number of sailors for the ship.
-
setCaptain
public void setCaptain(ICaptain captain)
Description copied from interface:IShipSet the captain on the ship- Specified by:
setCaptainin interfaceIShip- Parameters:
captain- to be assigned to the ship
-
isUpgradable
public boolean isUpgradable()
Description copied from interface:IShipCheck if the ship can be upgraded- Specified by:
isUpgradablein interfaceIShip- Returns:
- true if the ship is upgradable
-
upgrade
public void upgrade()
Description copied from interface:IShipUpgrade the ship if it is upgradable
-
getLoadedWares
public java.util.Set<IWare> getLoadedWares()
Description copied from interface:INavigableVesselRetrieve a list of all loaded wares- Specified by:
getLoadedWaresin interfaceINavigableVessel- Returns:
- set of loaded wares.
-
load
public int load(IWare ware, int amount, int avgPrice)
Load the ware in the specified amount onto the ship. The amount uses the size specified by the ware This method is not thread safe as it is only intended to be accessed by one thread at a time- Specified by:
loadin interfaceINavigableVessel- Parameters:
ware- to be loadedamount- of items the wareavgPrice- average price of one item of the ware- Returns:
- amount actually loaded
-
unload
public int unload(IWare ware, int amount)
Unload the specified quantity of the ware. The amount uses the size specified by the ware This method is not thread safe as it is only intended to be accessed by one thread at a time- Specified by:
unloadin interfaceINavigableVessel- Parameters:
ware- to be unloadedamount- amount of items of ware to unload- Returns:
- amount of the ware unloaded
-
getLoadBinding
public javafx.beans.binding.IntegerBinding getLoadBinding()
Description copied from interface:INavigableVesselRetrieve the amount of load in barrels that is loaded in actual wares (no wappen or crew)- Specified by:
getLoadBindingin interfaceINavigableVessel- Returns:
- amount of loaded wares in barrels
-
clearLoadedWares
protected void clearLoadedWares()
Clear all loaded wares. This method is only intended for testing
-
getWare
public AmountablePrice<IWare> getWare(IWare ware)
Description copied from interface:INavigableVesselRetrieve the amount of ware loaded- Specified by:
getWarein interfaceINavigableVessel- Parameters:
ware- for which to retrieve price and amount- Returns:
- price and amount loaded on the vessel.
-
getValue
public int getValue()
Description copied from interface:IShipRetrieve the current value of the ship without its cargo
-
getCargoValue
public int getCargoValue()
Description copied from interface:IShipRetrieve the value of the cargo.- Specified by:
getCargoValuein interfaceIShip- Returns:
- summed up cargo value.
-
getNumberOfSailors
public int getNumberOfSailors()
Description copied from interface:INavigableVesselRetrieve the number of sailors on the ship.- Specified by:
getNumberOfSailorsin interfaceINavigableVessel- Returns:
- number of sailors on the vessel
-
setNumberOfSailors
public void setNumberOfSailors(int nbSailors)
Description copied from interface:IShipSet the number of sailors.- Specified by:
setNumberOfSailorsin interfaceIShip- Parameters:
nbSailors- number of sailors.
-
numberOfSailorsProperty
public javafx.beans.property.IntegerProperty numberOfSailorsProperty()
Description copied from interface:IShipRetrieve the number of sailors as IntegerProperty.- Specified by:
numberOfSailorsPropertyin interfaceIShip- Returns:
- integer property of the number of sailors.
-
getWeaponAmount
public int getWeaponAmount(IWeapon weaponType)
Description copied from interface:INavigableVesselRetrieve the amount of weapons on the ship- Specified by:
getWeaponAmountin interfaceINavigableVessel- Parameters:
weaponType- any ship weapon or big weapon.- Returns:
- amount available on the ship
-
addPassenger
public void addPassenger(IPerson passanger)
Description copied from interface:IShipMove a passenger to the ship. The ship may only contain one passanger.- Specified by:
addPassengerin interfaceIShip- Parameters:
passanger- going oon board.
-
getOwner
public IShipOwner getOwner()
Description copied from interface:INavigableVesselRetrieve the owner of the ship. The owner cannot be retrieved if the pirate flag is set.- Specified by:
getOwnerin interfaceINavigableVessel- Returns:
- owner of the vessel.
-
setOwner
public void setOwner(IShipOwner owner)
Description copied from interface:IShipDefine the owner of the ship
-
leavePassenger
public void leavePassenger()
Passenger leave ship.- Specified by:
leavePassengerin interfaceIShip
-
getCapacity
public int getCapacity()
Description copied from interface:INavigableVesselAvailable capacity of the ship, this represent the free storage in barrels- Specified by:
getCapacityin interfaceINavigableVessel- Returns:
- free capacity of the vessel in barrels
-
getUpgradeSpaceReduction
public int getUpgradeSpaceReduction()
Description copied from interface:IShipRetrieve the reduction of the load capacity based on the upgrade level. The reduction is in barrel that reduces the initial size- Specified by:
getUpgradeSpaceReductionin interfaceIShip- Returns:
- reduction in barrels
-
passengerPresentProperty
public javafx.beans.binding.BooleanBinding passengerPresentProperty()
Description copied from interface:IShipBinding indicating if a passenger is present.- Specified by:
passengerPresentPropertyin interfaceIShip- Returns:
- boolean binding for the passenger presence.
-
getDamage
public int getDamage()
Description copied from interface:INavigableVesselRetrieve the damage of the ship in percentage [0,100]- Specified by:
getDamagein interfaceINavigableVessel- Returns:
- damage of the vessel.
-
damage
public void damage(int damage, boolean destroyWeapon)Description copied from interface:INavigableVesselDamage the ship- Specified by:
damagein interfaceINavigableVessel- Parameters:
damage- amount of damage that is inflicteddestroyWeapon- flag indicating if weapons may be destroyed.
-
repair
public void repair()
Description copied from interface:IShipRepair the damage
-
getLoadableSpace
public int getLoadableSpace()
Description copied from interface:INavigableVesselRetrieve the total amount of space that is available to store stuff. This is the total amount of space minus any space due to upgrades.- Specified by:
getLoadableSpacein interfaceINavigableVessel- Returns:
- avalable space in barrels
-
getTopSpeed
public double getTopSpeed()
Description copied from interface:INavigableVesselRetrieve the speed of the vessel in kilometer per hour- Specified by:
getTopSpeedin interfaceINavigableVessel- Returns:
- speed of the vessel in kilometer per hour.
-
getPirateFlag
public boolean getPirateFlag()
Description copied from interface:INavigableVesselIndicate if the vessel has hissed the pirate flag (Jolly Roger) and the vessel therefore should be considered a pirate vessel.- Specified by:
getPirateFlagin interfaceINavigableVessel- Returns:
- true if the Jolly Roger is hissed.
-
togglePirateFlag
public void togglePirateFlag()
Description copied from interface:INavigableVesselHiss or lower the pirate flag (Jolly Roger).- Specified by:
togglePirateFlagin interfaceINavigableVessel
-
pirateFlagProperty
public javafx.beans.property.BooleanProperty pirateFlagProperty()
Description copied from interface:INavigableVesselProperty defining the pirate activit y of the vessel.- Specified by:
pirateFlagPropertyin interfaceINavigableVessel- Returns:
- bolean property for the pirate flag.
-
getCurrentSpeed
public double getCurrentSpeed()
Description copied from interface:INavigableVesselCurrent top speed of the ship.- Specified by:
getCurrentSpeedin interfaceINavigableVessel- Returns:
- speed of the vessel in kilometer per hour.
-
parentShipProperty
public javafx.beans.property.ObjectProperty<IShip> parentShipProperty()
Description copied from interface:IShipProperty holding the parent ship in case of a grouping (convoy or group). The property value can be null.- Specified by:
parentShipPropertyin interfaceIShip- Returns:
- parent ship property.
-
updateHandweapon
public void updateHandweapon(int delta)
Description copied from interface:IShipUpdate the amount of handweapons on board.- Specified by:
updateHandweaponin interfaceIShip- Parameters:
delta- difference to be changed.
-
getOccupiedSpaceByWeapons
public int getOccupiedSpaceByWeapons()
Description copied from interface:IShipRetrieve the amount of space used for the weapons.- Specified by:
getOccupiedSpaceByWeaponsin interfaceIShip- Returns:
- occupied space in barrels by weapons.
-
travelState
public javafx.beans.property.ObjectProperty<EShipTravelState> travelState()
Description copied from interface:IShipTraveling state of the ship.- Specified by:
travelStatein interfaceIShip- Returns:
-
setTravelState
public void setTravelState(EShipTravelState state)
Description copied from interface:IShipSet the ships travel state.- Specified by:
setTravelStatein interfaceIShip- Parameters:
state- new travel state.
-
setAutoTrading
public void setAutoTrading(IShipAutoTrading autoTrading)
Description copied from interface:INavigableVesselSet the ship auto trading.- Specified by:
setAutoTradingin interfaceINavigableVessel- Parameters:
autoTrading- definition of the autorading, may be null to remove auto trading.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-