Class Convoy
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.ship.impl.Convoy
-
- All Implemented Interfaces:
IConvoy,IGroupableVessel,INavigableVessel
public class Convoy extends java.lang.Object implements IConvoy
Implementation of the Convoy.- Author:
- Andi Hotz, (c) Sahits GmbH, 2015 Created on Dec 23, 2015
-
-
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)Apply the damage to all ships.java.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.Map<IPlayer,java.lang.Integer>getCapacityPerOwner()Collect the convoys capacity per player who has ships in the convoy.java.util.Optional<ICaptain>getCaptian()Retrieve the captain of the Orleg ship.doublegetCurrentSpeed()Current top speed of the ship.intgetDamage()Retrieve the damage of the ship that is damaged the most.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()The name of the convoy is the name of the Orleg ship.intgetNumberOfSailors()Retrieve the number of sailors on the ship.IShipgetOrlegShip()Retrieve the lead ship of the convoy.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<IPlayer>getPlayers()Get all players who have a ship in the convoy.java.util.List<IShip>getShips()Retrieve a list of the ships in the convoy.java.util.List<IShip>getShips(IPlayer player)Get all the ships in the convoi that belong to a player.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 shipbooleanhasWeapons()Though a convoy has always weapons this is only something that is handled on the level of a single ship.intload(IWare ware, int amount, int avgPrice)The wares are loaded onto the ships in the convoy in the iteration order.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 wares from the ships in the convoy in the iteration order.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ch.sahits.game.openpatrician.model.ship.IConvoy
isPublicConvoy
-
-
-
-
Constructor Detail
-
Convoy
public Convoy(IShip orlegShip, boolean publicConvoy)
-
-
Method Detail
-
hasWeapons
public boolean hasWeapons()
Description copied from interface:IConvoyThough a convoy has always weapons this is only something that is handled on the level of a single ship. Therefore this method will always return false.- Specified by:
hasWeaponsin interfaceIConvoy- Returns:
- false
-
getOrlegShip
public IShip getOrlegShip()
Description copied from interface:IConvoyRetrieve the lead ship of the convoy.- Specified by:
getOrlegShipin interfaceIConvoy- Returns:
- reference to the orleg ship.
-
getShips
public java.util.List<IShip> getShips()
Description copied from interface:IConvoyRetrieve a list of the ships in the convoy.- Specified by:
getShipsin interfaceIConvoy- Specified by:
getShipsin interfaceIGroupableVessel- Returns:
- list of ships in the convoy.
-
addShip
public void addShip(IShip ship)
Description copied from interface:IConvoyAdd a ship to the convoy.
-
removeShip
public void removeShip(IShip ship)
Description copied from interface:IConvoyRemove a ship from the convoy.- Specified by:
removeShipin interfaceIConvoy- Parameters:
ship- to be removed.
-
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()
The name of the convoy is the name of the Orleg ship.- Specified by:
getNamein interfaceINavigableVessel- Returns:
- name of the orleg ship.
-
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)
The wares are loaded onto the ships in the convoy in the iteration order. There is no guarantee which ware is put on which ship.- Specified by:
loadin interfaceINavigableVessel- Parameters:
ware- to be loadedamount- of items the wareavgPrice- average price of one item of the ware- Returns:
- amount that is loaded.
-
unload
public int unload(IWare ware, int amount)
Unload the wares from the ships in the convoy in the iteration order. There is no guarantee from which ship the ware will be unloaded if thot the compleate loaded amount is unloaded.- Specified by:
unloadin interfaceINavigableVessel- Parameters:
ware- to be unloadedamount- amount of items of ware to unload- Returns:
- amount of the ware that is actually unloaded.
-
getDamage
public int getDamage()
Retrieve the damage of the ship that is damaged the most.- Specified by:
getDamagein interfaceINavigableVessel- Returns:
- damage of the most damaged ship in range [100,0]
-
damage
public void damage(int damage, boolean destroyWeapon)Apply the damage to all ships. the actual damage varies based on ship type and some random factor.- Specified by:
damagein interfaceINavigableVessel- Parameters:
damage- average damage by shipdestroyWeapon- 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()
Retrieve the captain of the Orleg ship.- Specified by:
getCaptianin interfaceINavigableVessel- Returns:
- Optional captain of the orleg ship.
-
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
-
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.
-
getShips
public java.util.List<IShip> getShips(IPlayer player)
Description copied from interface:IConvoyGet all the ships in the convoi that belong to a player.
-
getPlayers
public java.util.List<IPlayer> getPlayers()
Description copied from interface:IConvoyGet all players who have a ship in the convoy.- Specified by:
getPlayersin interfaceIConvoy- Returns:
- list of players.
-
getCapacityPerOwner
public java.util.Map<IPlayer,java.lang.Integer> getCapacityPerOwner()
Description copied from interface:IConvoyCollect the convoys capacity per player who has ships in the convoy.- Specified by:
getCapacityPerOwnerin interfaceIConvoy- Returns:
- map of IPlayer to capacity.
-
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.
-
getAutotrading
public java.util.Optional<IShipAutoTrading> getAutotrading()
Description copied from interface:INavigableVesselGet the auto trading for the ship. If nothing is defined, empty.- Specified by:
getAutotradingin interfaceINavigableVessel- Returns:
- Optional of
IShipAutoTrading.
-
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.
-
-