Class BaseBuyWeaponStrategy

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      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.
      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.
      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)  
      int getNumberOfEmptyLargeWeaponSlots​(ch.sahits.game.openpatrician.model.ship.IShip ship)  
      int getNumberOfEmptyWeaponSlots​(ch.sahits.game.openpatrician.model.ship.IShip ship)  
      protected int getNumberOfWeaponSlots​(ch.sahits.game.openpatrician.model.ship.IShip ship)
      Retrieve the number of weapon slots on the ship.
      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.
      • 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.IAIBuyWeaponStrategy

        shouldBuyWeapons
    • Constructor Detail

      • BaseBuyWeaponStrategy

        public BaseBuyWeaponStrategy()
    • 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:
        getNumberOfEmptyWeaponSlots in interface ch.sahits.game.openpatrician.model.player.IAIBuyWeaponStrategy
      • getNumberOfEmptyLargeWeaponSlots

        public int getNumberOfEmptyLargeWeaponSlots​(ch.sahits.game.openpatrician.model.ship.IShip ship)
        Specified by:
        getNumberOfEmptyLargeWeaponSlots in interface ch.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:
        buyWeapons in interface ch.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 bought
        player - who is purchasing the weapons
        city - 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:
        buyWeaponsOrdered in interface ch.sahits.game.openpatrician.model.player.IAIBuyWeaponStrategy