Class Ship

    • Field Detail

      • shipUpgradeLevel

        protected EShipUpgrade shipUpgradeLevel
        State of the design standard level
      • name

        protected java.lang.String name
        Name of the ship
    • Constructor Detail

      • Ship

        public Ship()
    • Method Detail

      • initializeProperties

        protected final void initializeProperties​(ShipProperties.Ship shipConfiguration)
      • getMaxNumberOfSailors

        public int getMaxNumberOfSailors()
        Description copied from interface: IShip
        Retrieve 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:
        getMaxNumberOfSailors in interface IShip
        Returns:
        maximum number of sailors for the ship.
      • setCaptain

        public void setCaptain​(ICaptain captain)
        Description copied from interface: IShip
        Set the captain on the ship
        Specified by:
        setCaptain in interface IShip
        Parameters:
        captain - to be assigned to the ship
      • isUpgradable

        public boolean isUpgradable()
        Description copied from interface: IShip
        Check if the ship can be upgraded
        Specified by:
        isUpgradable in interface IShip
        Returns:
        true if the ship is upgradable
      • upgrade

        public void upgrade()
        Description copied from interface: IShip
        Upgrade the ship if it is upgradable
        Specified by:
        upgrade in interface IShip
      • 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:
        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)
        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:
        unload in interface INavigableVessel
        Parameters:
        ware - to be unloaded
        amount - amount of items of ware to unload
        Returns:
        amount of the ware unloaded
      • 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
      • clearLoadedWares

        protected void clearLoadedWares()
        Clear all loaded wares. This method is only intended for testing
      • getValue

        public int getValue()
        Description copied from interface: IShip
        Retrieve the current value of the ship without its cargo
        Specified by:
        getValue in interface IShip
        Returns:
        value of the ship
      • getCargoValue

        public int getCargoValue()
        Description copied from interface: IShip
        Retrieve the value of the cargo.
        Specified by:
        getCargoValue in interface IShip
        Returns:
        summed up cargo value.
      • 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
      • setNumberOfSailors

        public void setNumberOfSailors​(int nbSailors)
        Description copied from interface: IShip
        Set the number of sailors.
        Specified by:
        setNumberOfSailors in interface IShip
        Parameters:
        nbSailors - number of sailors.
      • numberOfSailorsProperty

        public javafx.beans.property.IntegerProperty numberOfSailorsProperty()
        Description copied from interface: IShip
        Retrieve the number of sailors as IntegerProperty.
        Specified by:
        numberOfSailorsProperty in interface IShip
        Returns:
        integer property of the number of sailors.
      • 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
      • addPassenger

        public void addPassenger​(IPerson passanger)
        Description copied from interface: IShip
        Move a passenger to the ship. The ship may only contain one passanger.
        Specified by:
        addPassenger in interface IShip
        Parameters:
        passanger - going oon board.
      • 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.
      • setOwner

        public void setOwner​(IShipOwner owner)
        Description copied from interface: IShip
        Define the owner of the ship
        Specified by:
        setOwner in interface IShip
        Parameters:
        owner - owner of the ship.
      • leavePassenger

        public void leavePassenger()
        Passenger leave ship.
        Specified by:
        leavePassenger in interface IShip
      • 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
      • getUpgradeSpaceReduction

        public int getUpgradeSpaceReduction()
        Description copied from interface: IShip
        Retrieve the reduction of the load capacity based on the upgrade level. The reduction is in barrel that reduces the initial size
        Specified by:
        getUpgradeSpaceReduction in interface IShip
        Returns:
        reduction in barrels
      • passengerPresentProperty

        public javafx.beans.binding.BooleanBinding passengerPresentProperty()
        Description copied from interface: IShip
        Binding indicating if a passenger is present.
        Specified by:
        passengerPresentProperty in interface IShip
        Returns:
        boolean binding for the passenger presence.
      • 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.
      • repair

        public void repair()
        Description copied from interface: IShip
        Repair the damage
        Specified by:
        repair in interface IShip
      • 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.
      • 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.
      • 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.
      • parentShipProperty

        public javafx.beans.property.ObjectProperty<IShip> parentShipProperty()
        Description copied from interface: IShip
        Property holding the parent ship in case of a grouping (convoy or group). The property value can be null.
        Specified by:
        parentShipProperty in interface IShip
        Returns:
        parent ship property.
      • updateHandweapon

        public void updateHandweapon​(int delta)
        Description copied from interface: IShip
        Update the amount of handweapons on board.
        Specified by:
        updateHandweapon in interface IShip
        Parameters:
        delta - difference to be changed.
      • getOccupiedSpaceByWeapons

        public int getOccupiedSpaceByWeapons()
        Description copied from interface: IShip
        Retrieve the amount of space used for the weapons.
        Specified by:
        getOccupiedSpaceByWeapons in interface IShip
        Returns:
        occupied space in barrels by weapons.
      • travelState

        public javafx.beans.property.ObjectProperty<EShipTravelState> travelState()
        Description copied from interface: IShip
        Traveling state of the ship.
        Specified by:
        travelState in interface IShip
        Returns:
      • setTravelState

        public void setTravelState​(EShipTravelState state)
        Description copied from interface: IShip
        Set the ships travel state.
        Specified by:
        setTravelState in interface IShip
        Parameters:
        state - new travel state.
      • 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.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object