Class BaseBuyWeaponStrategy
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.player.strategy.BaseBuyWeaponStrategy
-
- All Implemented Interfaces:
ch.sahits.game.openpatrician.model.player.IAIBuyWeaponStrategy
- Direct Known Subclasses:
BuyWeaponHighPirateActivityHalfSlotsFilledStrategy,BuyWeaponHighPirateSuccessAllSlotsFilledStrategy,BuyWeaponHighPirateSuccessHalfSlotsFilledStrategy
public abstract class BaseBuyWeaponStrategy extends java.lang.Object implements ch.sahits.game.openpatrician.model.player.IAIBuyWeaponStrategyBase class for buying weapons strategy implementing common services.- Author:
- Andi Hotz, (c) Sahits GmbH, 2017 Created on Oct 18, 2017
-
-
Constructor Summary
Constructors Constructor Description BaseBuyWeaponStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ch.sahits.game.openpatrician.model.weapon.EWeaponbuyLargeWeapon(ch.sahits.game.openpatrician.model.weapon.IArmory armory, int capacity)Randomly select a large weapon available in the armory and buy it.protected ch.sahits.game.openpatrician.model.weapon.EWeaponbuySmallWeapon(ch.sahits.game.openpatrician.model.weapon.IArmory armory, int capacity)Randomly select a small weapon available in the armory and buy it.voidbuyWeapons(ch.sahits.game.openpatrician.model.player.BuyWeapons target, ch.sahits.game.openpatrician.model.ship.IShip ship, ch.sahits.game.openpatrician.model.IAIPlayer player, ch.sahits.game.openpatrician.model.city.ICity city)First the hand weapons are bought.voidbuyWeaponsOrdered(ch.sahits.game.openpatrician.model.player.BuyWeapons target, ch.sahits.game.openpatrician.model.ship.IShip ship, ch.sahits.game.openpatrician.model.IAIPlayer player, ch.sahits.game.openpatrician.model.city.ICity city)intgetNumberOfEmptyLargeWeaponSlots(ch.sahits.game.openpatrician.model.ship.IShip ship)intgetNumberOfEmptyWeaponSlots(ch.sahits.game.openpatrician.model.ship.IShip ship)protected intgetNumberOfWeaponSlots(ch.sahits.game.openpatrician.model.ship.IShip ship)Retrieve the number of weapon slots on the ship.protected intgetWeaponAmount(ch.sahits.game.openpatrician.model.weapon.IArmory armory, ch.sahits.game.openpatrician.model.weapon.EWeapon weapon)Retrieve the amount of weapons available in the armory.
-
-
-
Method Detail
-
getNumberOfWeaponSlots
protected int getNumberOfWeaponSlots(ch.sahits.game.openpatrician.model.ship.IShip ship)
Retrieve the number of weapon slots on the ship.
-
getNumberOfEmptyWeaponSlots
public int getNumberOfEmptyWeaponSlots(ch.sahits.game.openpatrician.model.ship.IShip ship)
- Specified by:
getNumberOfEmptyWeaponSlotsin interfacech.sahits.game.openpatrician.model.player.IAIBuyWeaponStrategy
-
getNumberOfEmptyLargeWeaponSlots
public int getNumberOfEmptyLargeWeaponSlots(ch.sahits.game.openpatrician.model.ship.IShip ship)
- Specified by:
getNumberOfEmptyLargeWeaponSlotsin interfacech.sahits.game.openpatrician.model.player.IAIBuyWeaponStrategy
-
getWeaponAmount
protected int getWeaponAmount(ch.sahits.game.openpatrician.model.weapon.IArmory armory, ch.sahits.game.openpatrician.model.weapon.EWeapon weapon)Retrieve the amount of weapons available in the armory.
-
buyLargeWeapon
protected ch.sahits.game.openpatrician.model.weapon.EWeapon buyLargeWeapon(ch.sahits.game.openpatrician.model.weapon.IArmory armory, int capacity)Randomly select a large weapon available in the armory and buy it. No cash transfer.- Parameters:
armory- from which to buy weapons- Returns:
- bought weapon or null, if there is no weapon to be bought.
-
buySmallWeapon
protected ch.sahits.game.openpatrician.model.weapon.EWeapon buySmallWeapon(ch.sahits.game.openpatrician.model.weapon.IArmory armory, int capacity)Randomly select a small weapon available in the armory and buy it. No cash transfer.- Parameters:
armory- from which to buy weapons- Returns:
- bought weapon or null, if there is no weapon to be bought.
-
buyWeapons
public void buyWeapons(ch.sahits.game.openpatrician.model.player.BuyWeapons target, ch.sahits.game.openpatrician.model.ship.IShip ship, ch.sahits.game.openpatrician.model.IAIPlayer player, ch.sahits.game.openpatrician.model.city.ICity city)First the hand weapons are bought. Then the large weapons are purchased one at a time to ensure, that the weapon can be bought (there might not be enough available in the armory. The buying of the large weapons is limited by the number that should be bought and the overall strength. As a last step the small weapons are bought in the same manner with the same limitations. In the end the blacksmith is paid.- Specified by:
buyWeaponsin interfacech.sahits.game.openpatrician.model.player.IAIBuyWeaponStrategy- Parameters:
target- defining the target that should be met by buying the weapons.ship- for which the weapons should be boughtplayer- who is purchasing the weaponscity- in which to buy weapons
-
buyWeaponsOrdered
public void buyWeaponsOrdered(ch.sahits.game.openpatrician.model.player.BuyWeapons target, ch.sahits.game.openpatrician.model.ship.IShip ship, ch.sahits.game.openpatrician.model.IAIPlayer player, ch.sahits.game.openpatrician.model.city.ICity city)- Specified by:
buyWeaponsOrderedin interfacech.sahits.game.openpatrician.model.player.IAIBuyWeaponStrategy
-
-