Class BaseShipConstructionSelectionStrategy
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.player.strategy.BaseShipConstructionSelectionStrategy
-
- All Implemented Interfaces:
IAIConstructionSelectionStrategy
- Direct Known Subclasses:
BiggestShipConstructionSelectionStrategy
,RandomShipConstructionSelectionStrategy
public abstract class BaseShipConstructionSelectionStrategy extends java.lang.Object implements 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
-
-
Field Summary
Fields Modifier and Type Field Description private int
constructMaxShips
Maximum ships being orderedprivate int
maxFeetSize
The maximal fleet size up to which ships are ordered.private int
maxTotalCargoCapacity
The macimal cargo capacity of the fleet above which no ships are ordered.private int
minCash
The minimum of cash that is required before considering building a ship.private ShipFactory
shipFactory
private Shipyards
shipyards
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseShipConstructionSelectionStrategy(int minCash, int maxFeetSize, int maxTotalCargoCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getFleetCapacity(java.util.List<IShip> fleet)
Calculate the fleets total capacity.private boolean
isVesselEligibleForCollecting(IAIPlayer player, INavigableVessel vessel)
java.util.Optional<INavigableVessel>
selectCollectingVessel(IAIPlayer player, EShipType shipType)
Find a vessel that will do the collection.boolean
shouldOrderNewConstruction(IAIPlayer player)
Check if a new ship should be ordered.-
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
-
-
-
-
Field Detail
-
constructMaxShips
private int constructMaxShips
Maximum ships being ordered
-
shipFactory
@Autowired private ShipFactory shipFactory
-
shipyards
@Autowired private Shipyards shipyards
-
minCash
private final int minCash
The minimum of cash that is required before considering building a ship.
-
maxFeetSize
private final int maxFeetSize
The maximal fleet size up to which ships are ordered.
-
maxTotalCargoCapacity
private final int maxTotalCargoCapacity
The macimal cargo capacity of the fleet above which no ships are ordered.
-
-
Method Detail
-
shouldOrderNewConstruction
public boolean shouldOrderNewConstruction(IAIPlayer player)
Check if a new ship should be ordered. 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 interfaceIAIConstructionSelectionStrategy
- Parameters:
player
- for which the check should be done.- Returns:
-
getFleetCapacity
protected int getFleetCapacity(java.util.List<IShip> fleet)
Calculate the fleets total capacity.- Parameters:
fleet
- list of ships- Returns:
- capacity of all ships in
fleet
-
selectCollectingVessel
public java.util.Optional<INavigableVessel> selectCollectingVessel(IAIPlayer player, EShipType shipType)
Description copied from interface:IAIConstructionSelectionStrategy
Find a vessel that will do the collection.- Specified by:
selectCollectingVessel
in interfaceIAIConstructionSelectionStrategy
- Parameters:
player
- owning the vesselshipType
- of the ship to be built and thereby the definition of the required wares.- Returns:
- vessel that is to be used for collecting the wares.
-
isVesselEligibleForCollecting
private boolean isVesselEligibleForCollecting(IAIPlayer player, INavigableVessel vessel)
-
-