Class BaseShipConstructionSelectionStrategy

  • All Implemented Interfaces:
    ch.sahits.game.openpatrician.model.player.IAIConstructionSelectionStrategy
    Direct Known Subclasses:
    BiggestShipConstructionSelectionStrategy, RandomShipConstructionSelectionStrategy

    public abstract class BaseShipConstructionSelectionStrategy
    extends java.lang.Object
    implements ch.sahits.game.openpatrician.model.player.IAIConstructionSelectionStrategy
    Base implementation for a ship construction selection strategy that can be easily configured through the non default constructor.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2016 Created on Jul 30, 2016
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int getFleetCapacity​(java.util.List<ch.sahits.game.openpatrician.model.ship.IShip> fleet)
      Calculate the fleets total capacity.
      java.util.Optional<ch.sahits.game.openpatrician.model.ship.INavigableVessel> selectCollectingVessel​(ch.sahits.game.openpatrician.model.IAIPlayer player, ch.sahits.game.openpatrician.model.ship.EShipType shipType)  
      boolean shouldOrderNewConstruction​(ch.sahits.game.openpatrician.model.IAIPlayer player)
      Ship is ordered if enough cash is available and the fleet size and fleet capacity is below certain thresholds, as defined at construction time.
      • 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.player.IAIConstructionSelectionStrategy

        getBuildLocation, initShipConstruction, shouldBuildShipType
    • Constructor Detail

      • BaseShipConstructionSelectionStrategy

        protected BaseShipConstructionSelectionStrategy​(int minCash,
                                                        int maxFeetSize,
                                                        int maxTotalCargoCapacity)
    • Method Detail

      • shouldOrderNewConstruction

        public boolean shouldOrderNewConstruction​(ch.sahits.game.openpatrician.model.IAIPlayer player)
        Ship is ordered if enough cash is available and the fleet size and fleet capacity is below certain thresholds, as defined at construction time.
        Specified by:
        shouldOrderNewConstruction in interface ch.sahits.game.openpatrician.model.player.IAIConstructionSelectionStrategy
        Parameters:
        player - for which the check should be done.
        Returns:
      • getFleetCapacity

        protected int getFleetCapacity​(java.util.List<ch.sahits.game.openpatrician.model.ship.IShip> fleet)
        Calculate the fleets total capacity.
        Parameters:
        fleet - list of ships
        Returns:
        capacity of all ships in fleet
      • selectCollectingVessel

        public java.util.Optional<ch.sahits.game.openpatrician.model.ship.INavigableVessel> selectCollectingVessel​(ch.sahits.game.openpatrician.model.IAIPlayer player,
                                                                                                                   ch.sahits.game.openpatrician.model.ship.EShipType shipType)
        Specified by:
        selectCollectingVessel in interface ch.sahits.game.openpatrician.model.player.IAIConstructionSelectionStrategy