Class 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
    • Constructor Summary

      Constructors 
      Constructor Description
      ShipGroup​(IShip leadShip)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addShip​(IShip ship)
      Add a ship to the convoy.
      void damage​(int damage, boolean destroyWeapon)
      Damage the ship
      java.util.Optional<IShipAutoTrading> getAutotrading()
      Get the auto trading for the ship.
      int getCapacity()
      Available capacity of the ship, this represent the free storage in barrels
      java.util.Optional<ICaptain> getCaptian()
      Retrieve the captain of the ship.
      double getCurrentSpeed()
      Current top speed of the ship.
      int getDamage()
      Retrieve the damage of the ship in percentage [0,100]
      int getLoadableSpace()
      Retrieve the total amount of space that is available to store stuff.
      javafx.beans.binding.IntegerBinding getLoadBinding()
      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 wares
      javafx.geometry.Point2D getLocation()
      Retrieve the location of the ship.
      int getMinNumberOfSailors()
      Retrieve the minimum of sailors needed to operate the ship.
      java.lang.String getName()
      Retrieve the name of the of the ship
      int getNumberOfSailors()
      Retrieve the number of sailors on the ship.
      IShipOwner getOwner()
      Retrieve the owner of the ship.
      boolean getPirateFlag()
      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.
      int getSize()
      Total capacity of the ship in barrels.
      double getTopSpeed()
      Retrieve the speed of the vessel in kilometer per hour
      java.lang.String getUuid()
      Retrieve a universal unique identifier for the vessel.
      AmountablePrice<IWare> getWare​(IWare ware)
      Retrieve the amount of ware loaded
      int getWeaponAmount​(IWeapon weaponType)
      Retrieve the amount of weapons on the ship
      int load​(IWare ware, int amount, int avgPrice)
      Load the ware in the specified amount onto the ship.
      javafx.beans.property.BooleanProperty pirateFlagProperty()
      Property defining the pirate activit y of the vessel.
      void removeShip​(IShip ship)
      Remove a ship from the convoy.
      void setAutoTrading​(IShipAutoTrading autoTrading)
      Set the ship auto trading.
      void setLocation​(javafx.geometry.Point2D location)
      Set the location of the ship.
      void togglePirateFlag()
      Hiss or lower the pirate flag (Jolly Roger).
      int unload​(IWare ware, int amount)
      Unload the specified quantity of the ware.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShipGroup

        public ShipGroup​(IShip leadShip)
    • Method Detail

      • getSize

        public int getSize()
        Description copied from interface: INavigableVessel
        Total capacity of the ship in barrels.
        Specified by:
        getSize in interface INavigableVessel
        Returns:
        total holding capacity of the vessel in barrels
      • getCapacity

        public int getCapacity()
        Description copied from interface: INavigableVessel
        Available capacity of the ship, this represent the free storage in barrels
        Specified by:
        getCapacity in interface INavigableVessel
        Returns:
        free capacity of the vessel in barrels
      • getName

        public java.lang.String getName()
        Description copied from interface: INavigableVessel
        Retrieve the name of the of the ship
        Specified by:
        getName in interface INavigableVessel
        Returns:
        name of the vessel.
      • load

        public int load​(IWare ware,
                        int amount,
                        int avgPrice)
        Description copied from interface: INavigableVessel
        Load the ware in the specified amount onto the ship. The amount uses the size specified by the ware
        Specified by:
        load in interface INavigableVessel
        Parameters:
        ware - to be loaded
        amount - of items the ware
        avgPrice - average price of one item of the ware
        Returns:
        amount actually loaded
      • unload

        public int unload​(IWare ware,
                          int amount)
        Description copied from interface: INavigableVessel
        Unload the specified quantity of the ware. The amount uses the size specified by the ware
        Specified by:
        unload in interface INavigableVessel
        Parameters:
        ware - to be unloaded
        amount - amount of items of ware to unload
        Returns:
        amount of the ware unloaded
      • getDamage

        public int getDamage()
        Description copied from interface: INavigableVessel
        Retrieve the damage of the ship in percentage [0,100]
        Specified by:
        getDamage in interface INavigableVessel
        Returns:
        damage of the vessel.
      • damage

        public void damage​(int damage,
                           boolean destroyWeapon)
        Description copied from interface: INavigableVessel
        Damage the ship
        Specified by:
        damage in interface INavigableVessel
        Parameters:
        damage - amount of damage that is inflicted
        destroyWeapon - flag indicating if weapons may be destroyed.
      • getLoadBinding

        public javafx.beans.binding.IntegerBinding getLoadBinding()
        Description copied from interface: INavigableVessel
        Retrieve the amount of load in barrels that is loaded in actual wares (no wappen or crew)
        Specified by:
        getLoadBinding in interface INavigableVessel
        Returns:
        amount of loaded wares in barrels
      • getNumberOfSailors

        public int getNumberOfSailors()
        Description copied from interface: INavigableVessel
        Retrieve the number of sailors on the ship.
        Specified by:
        getNumberOfSailors in interface INavigableVessel
        Returns:
        number of sailors on the vessel
      • getMinNumberOfSailors

        public int getMinNumberOfSailors()
        Description copied from interface: INavigableVessel
        Retrieve the minimum of sailors needed to operate the ship.
        Specified by:
        getMinNumberOfSailors in interface INavigableVessel
        Returns:
        minimum required amount of sailors.
      • getCaptian

        public java.util.Optional<ICaptain> getCaptian()
        Description copied from interface: INavigableVessel
        Retrieve the captain of the ship. There might not be a captain present.
        Specified by:
        getCaptian in interface INavigableVessel
        Returns:
        Optional captain on the vessel. Empty if none is present.
      • getLocation

        public javafx.geometry.Point2D getLocation()
        Description copied from interface: INavigableVessel
        Retrieve the location of the ship.
        Specified by:
        getLocation in interface INavigableVessel
        Returns:
        current location of the vessel.
      • setLocation

        public void setLocation​(javafx.geometry.Point2D location)
        Description copied from interface: INavigableVessel
        Set the location of the ship.
        Specified by:
        setLocation in interface INavigableVessel
        Parameters:
        location - of the ship
      • getOwner

        public IShipOwner getOwner()
        Description copied from interface: INavigableVessel
        Retrieve the owner of the ship. The owner cannot be retrieved if the pirate flag is set.
        Specified by:
        getOwner in interface INavigableVessel
        Returns:
        owner of the vessel.
      • getWeaponAmount

        public int getWeaponAmount​(IWeapon weaponType)
        Description copied from interface: INavigableVessel
        Retrieve the amount of weapons on the ship
        Specified by:
        getWeaponAmount in interface INavigableVessel
        Parameters:
        weaponType - any ship weapon or big weapon.
        Returns:
        amount available on the ship
      • getLoadableSpace

        public int getLoadableSpace()
        Description copied from interface: INavigableVessel
        Retrieve 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:
        getLoadableSpace in interface INavigableVessel
        Returns:
        avalable space in barrels
      • getTopSpeed

        public double getTopSpeed()
        Description copied from interface: INavigableVessel
        Retrieve the speed of the vessel in kilometer per hour
        Specified by:
        getTopSpeed in interface INavigableVessel
        Returns:
        speed of the vessel in kilometer per hour.
      • getCurrentSpeed

        public double getCurrentSpeed()
        Description copied from interface: INavigableVessel
        Current top speed of the ship.
        Specified by:
        getCurrentSpeed in interface INavigableVessel
        Returns:
        speed of the vessel in kilometer per hour.
      • getUuid

        public java.lang.String getUuid()
        Description copied from interface: INavigableVessel
        Retrieve a universal unique identifier for the vessel.
        Specified by:
        getUuid in interface INavigableVessel
        Returns:
        UUID as string.
      • getPirateFlag

        public boolean getPirateFlag()
        Description copied from interface: INavigableVessel
        Indicate if the vessel has hissed the pirate flag (Jolly Roger) and the vessel therefore should be considered a pirate vessel.
        Specified by:
        getPirateFlag in interface INavigableVessel
        Returns:
        true if the Jolly Roger is hissed.
      • pirateFlagProperty

        public javafx.beans.property.BooleanProperty pirateFlagProperty()
        Description copied from interface: INavigableVessel
        Property defining the pirate activit y of the vessel.
        Specified by:
        pirateFlagProperty in interface INavigableVessel
        Returns:
        bolean property for the pirate flag.
      • addShip

        public void addShip​(IShip ship)
        Description copied from interface: IShipGroup
        Add a ship to the convoy.
        Specified by:
        addShip in interface IShipGroup
        Parameters:
        ship - to be added.
      • removeShip

        public void removeShip​(IShip ship)
        Description copied from interface: IShipGroup
        Remove a ship from the convoy.
        Specified by:
        removeShip in interface IShipGroup
        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:
        getAutotrading in interface INavigableVessel
        Returns:
        empty
      • setAutoTrading

        public void setAutoTrading​(IShipAutoTrading autoTrading)
        Description copied from interface: INavigableVessel
        Set the ship auto trading.
        Specified by:
        setAutoTrading in interface INavigableVessel
        Parameters:
        autoTrading - definition of the autorading, may be null to remove auto trading.