Class MerchantBehaviour

Direct Known Subclasses:
BuyerBehaviour, OutfitChangerBehaviour, SellerBehaviour

public abstract class MerchantBehaviour extends TransactionBehaviour
Represents the behaviour of a NPC who is able to either sell items to a player, or buy items from a player.
  • Field Details

  • Constructor Details

    • MerchantBehaviour

      public MerchantBehaviour()
    • MerchantBehaviour

      public MerchantBehaviour(Map<String,​Integer> priceList)
  • Method Details

    • dealtItems

      public Set<String> dealtItems()
      Returns a set of the names of all items that the NPC deals with.
      Returns:
      the dealt items
    • hasItem

      public boolean hasItem(String item)
      Checks whether the NPC deals with the specified item.
      Parameters:
      item - the name of the item
      Returns:
      true iff the NPC deals with the item
    • getUnitPrice

      public int getUnitPrice(String item)
      Returns the price of one unit of a given item.
      Parameters:
      item - the name of the item
      Returns:
      the unit price
    • getCharge

      public int getCharge(ItemParserResult res, Player player)
      Returns the price of the desired amount of the chosen item.
      Parameters:
      res -
      player - The player who considers buying/selling
      Returns:
      The price; 0 if no item was chosen or if the amount is 0.