Class ShipGroup
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.ship.impl.ShipGroup
-
- All Implemented Interfaces:
IGroupableVessel,INavigableVessel,IShipGroup
public class ShipGroup extends java.lang.Object implements IShipGroup
Implementation of a group of ships mainly used by pirates.- Author:
- Andi Hotz, (c) Sahits GmbH, 2016 Created on Apr 10, 2016
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddShip(IShip ship)Add a ship to the convoy.voiddamage(int damage, boolean destroyWeapon)Damage the shipjava.util.Optional<IShipAutoTrading>getAutotrading()Get the auto trading for the ship.intgetCapacity()Available capacity of the ship, this represent the free storage in barrelsjava.util.Optional<ICaptain>getCaptian()Retrieve the captain of the ship.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 waresjavafx.geometry.Point2DgetLocation()Retrieve the location of the ship.intgetMinNumberOfSailors()Retrieve the minimum of sailors needed to operate the ship.java.lang.StringgetName()Retrieve the name of the of the shipintgetNumberOfSailors()Retrieve the number of sailors on the ship.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.java.util.List<IShip>getShips()Retrieve a list of the ships in the convoy.intgetSize()Total capacity of the ship in barrels.doublegetTopSpeed()Retrieve the speed of the vessel in kilometer per hourjava.lang.StringgetUuid()Retrieve a universal unique identifier for the vessel.AmountablePrice<IWare>getWare(IWare ware)Retrieve the amount of ware loadedintgetWeaponAmount(IWeapon weaponType)Retrieve the amount of weapons on the shipintload(IWare ware, int amount, int avgPrice)Load the ware in the specified amount onto the ship.javafx.beans.property.BooleanPropertypirateFlagProperty()Property defining the pirate activit y of the vessel.voidremoveShip(IShip ship)Remove a ship from the convoy.voidsetAutoTrading(IShipAutoTrading autoTrading)Set the ship auto trading.voidsetLocation(javafx.geometry.Point2D location)Set the location of the ship.voidtogglePirateFlag()Hiss or lower the pirate flag (Jolly Roger).intunload(IWare ware, int amount)Unload the specified quantity of the ware.
-
-
-
Constructor Detail
-
ShipGroup
public ShipGroup(IShip leadShip)
-
-
Method Detail
-
getSize
public int getSize()
Description copied from interface:INavigableVesselTotal capacity of the ship in barrels.- Specified by:
getSizein interfaceINavigableVessel- Returns:
- total holding capacity of the vessel in barrels
-
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
-
getName
public java.lang.String getName()
Description copied from interface:INavigableVesselRetrieve the name of the of the ship- Specified by:
getNamein interfaceINavigableVessel- Returns:
- name of the vessel.
-
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)
Description copied from interface:INavigableVesselLoad the ware in the specified amount onto the ship. The amount uses the size specified by the ware- 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)
Description copied from interface:INavigableVesselUnload the specified quantity of the ware. The amount uses the size specified by the ware- Specified by:
unloadin interfaceINavigableVessel- Parameters:
ware- to be unloadedamount- amount of items of ware to unload- Returns:
- amount of the ware unloaded
-
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.
-
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
-
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.
-
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
-
getMinNumberOfSailors
public int getMinNumberOfSailors()
Description copied from interface:INavigableVesselRetrieve the minimum of sailors needed to operate the ship.- Specified by:
getMinNumberOfSailorsin interfaceINavigableVessel- Returns:
- minimum required amount of sailors.
-
getCaptian
public java.util.Optional<ICaptain> getCaptian()
Description copied from interface:INavigableVesselRetrieve the captain of the ship. There might not be a captain present.- Specified by:
getCaptianin interfaceINavigableVessel- Returns:
- Optional captain on the vessel. Empty if none is present.
-
getLocation
public javafx.geometry.Point2D getLocation()
Description copied from interface:INavigableVesselRetrieve the location of the ship.- Specified by:
getLocationin interfaceINavigableVessel- Returns:
- current location of the vessel.
-
setLocation
public void setLocation(javafx.geometry.Point2D location)
Description copied from interface:INavigableVesselSet the location of the ship.- Specified by:
setLocationin interfaceINavigableVessel- Parameters:
location- of the ship
-
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.
-
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
-
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.
-
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.
-
getUuid
public java.lang.String getUuid()
Description copied from interface:INavigableVesselRetrieve a universal unique identifier for the vessel.- Specified by:
getUuidin interfaceINavigableVessel- Returns:
- UUID as string.
-
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.
-
getShips
public java.util.List<IShip> getShips()
Description copied from interface:IShipGroupRetrieve a list of the ships in the convoy.- Specified by:
getShipsin interfaceIGroupableVessel- Specified by:
getShipsin interfaceIShipGroup- Returns:
- list of ships in the group
-
addShip
public void addShip(IShip ship)
Description copied from interface:IShipGroupAdd a ship to the convoy.- Specified by:
addShipin interfaceIShipGroup- Parameters:
ship- to be added.
-
removeShip
public void removeShip(IShip ship)
Description copied from interface:IShipGroupRemove a ship from the convoy.- Specified by:
removeShipin interfaceIShipGroup- Parameters:
ship- to be removed.
-
getAutotrading
public java.util.Optional<IShipAutoTrading> getAutotrading()
Get the auto trading for the ship. If nothing is defined, empty. A ship group does not support autotrading.- Specified by:
getAutotradingin interfaceINavigableVessel- Returns:
- empty
-
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.
-
-